mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
Wiki optimized third (#2406)
This commit is contained in:
committed by
Daniel Pan
parent
5cffd4cb69
commit
3ab4cbff4f
142
frontend/src/components/dirent-operation/operation-menu.js
Normal file
142
frontend/src/components/dirent-operation/operation-menu.js
Normal file
@@ -0,0 +1,142 @@
|
||||
import React from 'react';
|
||||
import { gettext } from '../constants';
|
||||
|
||||
class OperationMenu extends React.Component {
|
||||
|
||||
getItemType() {
|
||||
return this.props.currentItem.type;
|
||||
}
|
||||
|
||||
renderDirentDirMenu() {
|
||||
let position = this.props.menuPosition;
|
||||
let style = {position: 'fixed', left: position.left, top: position.top, display: 'block'};
|
||||
if (this.props.currentItem.permission === 'rw') {
|
||||
return (
|
||||
<ul className="dropdown-menu operation-menu" style={style}>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Rename')} aria-label={gettext('Rename')}>{gettext('Rename')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Move')} aria-label={gettext('Move')}>{gettext('Move')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Copy')} aria-label={gettext('Copy')}>{gettext('Copy')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item menu-inner-divider"></li>
|
||||
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Permission')} aria-label={gettext('Permission')}>{gettext('Permission')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Details')} aria-label={gettext('Details')}>{gettext('Details')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item menu-inner-divider"></li>
|
||||
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Open via Client')} aria-label={gettext('Open via Client')}>{gettext('Open via Client')}</span>
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
if (this.props.currentItem.permission === 'r') {
|
||||
return (
|
||||
<ul className="dropdown-menu operation-menu" style={style}>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Copy')} aria-label={gettext('Copy')}>{gettext('Copy')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Details')} aria-label={gettext('Details')}>{gettext('Details')}</span>
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
renderDirentFileMenu() {
|
||||
let position = this.props.menuPosition;
|
||||
let style = {position: 'fixed', left: position.left, top: position.top, display: 'block'};
|
||||
if (this.props.currentItem.permission === 'rw') {
|
||||
return (
|
||||
<ul className="dropdown-menu operation-menu" style={style}>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Rename')} aria-label={gettext('Rename')}>{gettext('Rename')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Move')} aria-label={gettext('Move')}>{gettext('Move')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Copy')} aria-label={gettext('Copy')}>{gettext('Copy')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Lock')} aria-label={gettext('Lock')}>{gettext('Lock')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Unlock')} aria-label={gettext('Unlock')}>{gettext('Unlock')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('New Draft')} aria-label={gettext('New Draft')}>{gettext('New Draft')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item menu-inner-divider"></li>
|
||||
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Comment')} aria-label={gettext('Comment')}>{gettext('Comment')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="" title={gettext('History')} aria-label={gettext('History')}>{gettext('History')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Access Log')} aria-label={gettext('Access Log')}>{gettext('Access Log')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Details')} aria-label={gettext('Details')}>{gettext('Details')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item menu-inner-divider"></li>
|
||||
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Open via Client')} aria-label={gettext('Open via Client')}>{gettext('Open via Client')}</span>
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
if (this.props.currentItem.permission === "r") {
|
||||
return (
|
||||
<ul className="dropdown-menu operation-menu" style={style}>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Copy')} aria-label={gettext('Copy')}>{gettext('Copy')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Comment')} aria-label={gettext('Comment')}>{gettext('Comment')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('History')} aria-label={gettext('History')}>{gettext('History')}</span>
|
||||
</li>
|
||||
<li className="dropdown-item operation-menu-item">
|
||||
<span className="user-select-none" title={gettext('Details')} aria-label={gettext('Details')}>{gettext('Details')}</span>
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
let type = this.getItemType();
|
||||
let menu = null;
|
||||
switch(type) {
|
||||
case 'file':
|
||||
menu = this.renderDirentFileMenu();
|
||||
break;
|
||||
case 'dir':
|
||||
menu = this.renderDirentDirMenu();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
export default OperationMenu;
|
Reference in New Issue
Block a user