Dropdown menu refactors
This commit is contained in:
43
frontend/menus/CollectionMenu.js
Normal file
43
frontend/menus/CollectionMenu.js
Normal file
@ -0,0 +1,43 @@
|
||||
// @flow
|
||||
import React, { Component } from 'react';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import Collection from 'models/Collection';
|
||||
import UiStore from 'stores/UiStore';
|
||||
import Icon from 'components/Icon';
|
||||
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
||||
|
||||
@observer class CollectionMenu extends Component {
|
||||
props: {
|
||||
label?: React$Element<any>,
|
||||
history: Object,
|
||||
ui: UiStore,
|
||||
collection: Collection,
|
||||
};
|
||||
|
||||
onEdit = () => {
|
||||
const { collection } = this.props;
|
||||
this.props.ui.setActiveModal('edit-collection', { collection });
|
||||
};
|
||||
|
||||
onDelete = () => {
|
||||
const { collection } = this.props;
|
||||
this.props.ui.setActiveModal('delete-collection', { collection });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { collection, label } = this.props;
|
||||
const { allowDelete } = collection;
|
||||
|
||||
return (
|
||||
<DropdownMenu label={label || <Icon type="MoreHorizontal" />}>
|
||||
{collection &&
|
||||
<DropdownMenuItem onClick={this.onEdit}>Edit</DropdownMenuItem>}
|
||||
{allowDelete &&
|
||||
<DropdownMenuItem onClick={this.onDelete}>Delete</DropdownMenuItem>}
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(inject('ui')(CollectionMenu));
|
Reference in New Issue
Block a user