1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 01:12:03 +00:00

[system admin] modifications (#4266)

* cleaned up the code, removed multiple *-op-menu.js files,
added a common component op-menu.js
* make the 'vertical dots' icon's clickable area be 24*24
* institution member: added confirm to 'set admin'
* improved code
This commit is contained in:
llj
2019-11-18 10:30:35 +08:00
committed by Daniel Pan
parent 9926e2870c
commit b6162d8393
33 changed files with 212 additions and 589 deletions

View File

@@ -0,0 +1,69 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap';
import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
const propTypes = {
onFreezedItem: PropTypes.func.isRequired,
onUnfreezedItem: PropTypes.func.isRequired,
onMenuItemClick: PropTypes.func.isRequired,
operations: PropTypes.array.isRequired,
translateOperations: PropTypes.func.isRequired
};
class OpMenu extends React.Component {
constructor(props) {
super(props);
this.state = {
isItemMenuShow: false
};
}
onMenuItemClick = (e) => {
let operation = Utils.getEventData(e, 'op');
this.props.onMenuItemClick(operation);
}
onDropdownToggleClick = (e) => {
this.toggleOperationMenu(e);
}
toggleOperationMenu = (e) => {
this.setState(
{isItemMenuShow: !this.state.isItemMenuShow},
() => {
if (this.state.isItemMenuShow) {
this.props.onFreezedItem();
} else {
this.props.onUnfreezedItem();
}
}
);
}
render() {
const { operations, translateOperations } = this.props;
return (
<Dropdown isOpen={this.state.isItemMenuShow} toggle={this.toggleOperationMenu}>
<DropdownToggle
tag="i"
className="d-flex w-5 h-5 align-items-center justify-content-center sf-dropdown-toggle fa fa-ellipsis-v"
title={gettext('More Operations')}
data-toggle="dropdown"
aria-expanded={this.state.isItemMenuShow}
/>
<DropdownMenu className="my-1 mr-2">
{operations.map((item, index )=> {
return (<DropdownItem key={index} data-op={item} onClick={this.onMenuItemClick}>{translateOperations(item)}</DropdownItem>);
})}
</DropdownMenu>
</Dropdown>
);
}
}
OpMenu.propTypes = propTypes;
export default OpMenu;