mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
update menu generate algorithm
This commit is contained in:
@@ -392,6 +392,10 @@ class DirentGridView extends React.Component{
|
||||
menuList: menuList,
|
||||
};
|
||||
|
||||
if (menuList.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
showMenu(showMenuConfig);
|
||||
}
|
||||
|
||||
@@ -408,11 +412,17 @@ class DirentGridView extends React.Component{
|
||||
let contextmenuList = [];
|
||||
if (isContextmenu) {
|
||||
let { SHARE, DOWNLOAD, DELETE } = TextTranslation;
|
||||
contextmenuList = this.props.showShareBtn ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider'];
|
||||
contextmenuList = this.props.showShareBtn ? [SHARE] : [];
|
||||
|
||||
if (dirent.type === 'file') {
|
||||
contextmenuList = canGenerateShareLink ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider'];
|
||||
if (dirent.permission === 'rw' || dirent.permission === 'r') {
|
||||
contextmenuList = [...contextmenuList, DOWNLOAD];
|
||||
}
|
||||
|
||||
if (dirent.permission === 'rw') {
|
||||
contextmenuList = [...contextmenuList, DELETE];
|
||||
}
|
||||
|
||||
contextmenuList = [...contextmenuList, 'Divider'];
|
||||
}
|
||||
|
||||
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG } = TextTranslation;
|
||||
|
@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import MD5 from 'MD5';
|
||||
import { UncontrolledTooltip } from 'reactstrap';
|
||||
import { gettext, siteRoot, mediaUrl, username, canGenerateShareLink } from '../../utils/constants';
|
||||
import { gettext, siteRoot, mediaUrl, username } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import URLDecorator from '../../utils/url-decorator';
|
||||
@@ -470,9 +470,11 @@ class DirentListItem extends React.Component {
|
||||
{this.state.isOperationShow && !dirent.isSelected &&
|
||||
<div className="operations">
|
||||
<ul className="operation-group">
|
||||
<li className="operation-group-item">
|
||||
<i className="op-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemDownload}></i>
|
||||
</li>
|
||||
{(dirent.permission === 'rw' || dirent.permission === 'r') && (
|
||||
<li className="operation-group-item">
|
||||
<i className="op-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemDownload}></i>
|
||||
</li>
|
||||
)}
|
||||
{showShareBtn && (
|
||||
<li className="operation-group-item">
|
||||
<i className="op-icon sf2-icon-share" title={gettext('Share')} onClick={this.onItemShare}></i>
|
||||
@@ -502,9 +504,11 @@ class DirentListItem extends React.Component {
|
||||
{this.state.isOperationShow &&
|
||||
<div className="operations">
|
||||
<ul className="operation-group">
|
||||
<li className="operation-group-item">
|
||||
<i className="op-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemDownload}></i>
|
||||
</li>
|
||||
{(dirent.permission === 'rw' || dirent.permission === 'r') && (
|
||||
<li className="operation-group-item">
|
||||
<i className="op-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemDownload}></i>
|
||||
</li>
|
||||
)}
|
||||
{showShareBtn && (
|
||||
<li className="operation-group-item">
|
||||
<i className="op-icon sf2-icon-share" title={gettext('Share')} onClick={this.onItemShare}></i>
|
||||
|
@@ -320,6 +320,10 @@ class DirentListView extends React.Component {
|
||||
menuList: menuList,
|
||||
};
|
||||
|
||||
if (menuList.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
showMenu(showMenuConfig);
|
||||
}
|
||||
|
||||
@@ -467,21 +471,28 @@ class DirentListView extends React.Component {
|
||||
|
||||
let menuList = [];
|
||||
let contextmenuList = [];
|
||||
|
||||
if (isContextmenu) {
|
||||
let { SHARE, DOWNLOAD, DELETE } = TextTranslation;
|
||||
contextmenuList = this.props.showShareBtn ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider'];
|
||||
contextmenuList = this.props.showShareBtn ? [SHARE] : [];
|
||||
|
||||
if (dirent.type === 'file') {
|
||||
contextmenuList = canGenerateShareLink ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider'];
|
||||
if (dirent.permission === 'rw' || dirent.permission === 'r') {
|
||||
contextmenuList = [...contextmenuList, DOWNLOAD];
|
||||
}
|
||||
|
||||
if (dirent.permission === 'rw') {
|
||||
contextmenuList = [...contextmenuList, DELETE];
|
||||
}
|
||||
|
||||
contextmenuList = [...contextmenuList, 'Divider'];
|
||||
}
|
||||
|
||||
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG, TAGS } = TextTranslation;
|
||||
if (type === 'dir' && permission === 'rw') {
|
||||
if (can_set_folder_perm) {
|
||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
|
||||
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
|
||||
} else {
|
||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
Reference in New Issue
Block a user