1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 02:42:47 +00:00

[dir view] redesigned the top toolbar for the selected dirent(s) (#6111)

* [dir view] redesigned the top toolbar for the selected dirent(s)

* code cleanup
This commit is contained in:
llj
2024-05-24 19:20:36 +08:00
committed by GitHub
parent 34582dbf51
commit eac54b1255
7 changed files with 181 additions and 126 deletions

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import listener from '../context-menu/globalEventListener'; import listener from '../context-menu/globalEventListener';
import { Dropdown, ButtonDropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap'; import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
@@ -9,6 +9,7 @@ const propTypes = {
tagName: PropTypes.string, tagName: PropTypes.string,
item: PropTypes.object.isRequired, item: PropTypes.object.isRequired,
toggleClass: PropTypes.string, toggleClass: PropTypes.string,
toggleChildren: PropTypes.object,
isHandleContextMenuEvent: PropTypes.bool, isHandleContextMenuEvent: PropTypes.bool,
getMenuList: PropTypes.func.isRequired, getMenuList: PropTypes.func.isRequired,
onMenuItemClick: PropTypes.func.isRequired, onMenuItemClick: PropTypes.func.isRequired,
@@ -107,7 +108,7 @@ class ItemDropdownMenu extends React.Component {
render() { render() {
let menuList = this.state.menuList; let menuList = this.state.menuList;
let { toggleClass, tagName } = this.props; let { toggleClass, toggleChildren, tagName } = this.props;
toggleClass = 'sf-dropdown-toggle ' + toggleClass; toggleClass = 'sf-dropdown-toggle ' + toggleClass;
if (!menuList.length) { if (!menuList.length) {
@@ -116,9 +117,9 @@ class ItemDropdownMenu extends React.Component {
if (tagName && tagName === 'button') { if (tagName && tagName === 'button') {
return ( return (
<ButtonDropdown isOpen={this.state.isItemMenuShow} toggle={this.onDropdownToggleClick}> <Dropdown isOpen={this.state.isItemMenuShow} toggle={this.onDropdownToggleClick}>
<DropdownToggle <DropdownToggle
className={toggleClass} className={this.props.toggleClass}
data-toggle="dropdown" data-toggle="dropdown"
title={gettext('More operations')} title={gettext('More operations')}
aria-label={gettext('More operations')} aria-label={gettext('More operations')}
@@ -126,6 +127,7 @@ class ItemDropdownMenu extends React.Component {
onKeyDown={this.onDropdownToggleKeyDown} onKeyDown={this.onDropdownToggleKeyDown}
// onClick={this.onDropdownToggleClick} // onClick={this.onDropdownToggleClick}
> >
{toggleChildren}
</DropdownToggle> </DropdownToggle>
<DropdownMenu> <DropdownMenu>
{menuList.map((menuItem, index) => { {menuList.map((menuItem, index) => {
@@ -138,7 +140,7 @@ class ItemDropdownMenu extends React.Component {
} }
})} })}
</DropdownMenu> </DropdownMenu>
</ButtonDropdown> </Dropdown>
); );
} }

View File

@@ -7,9 +7,9 @@ import { seafileAPI } from '../../utils/seafile-api';
import URLDecorator from '../../utils/url-decorator'; import URLDecorator from '../../utils/url-decorator';
import MoveDirentDialog from '../dialog/move-dirent-dialog'; import MoveDirentDialog from '../dialog/move-dirent-dialog';
import CopyDirentDialog from '../dialog/copy-dirent-dialog'; import CopyDirentDialog from '../dialog/copy-dirent-dialog';
import ShareDialog from '../dialog/share-dialog';
import EditFileTagDialog from '../dialog/edit-filetag-dialog'; import EditFileTagDialog from '../dialog/edit-filetag-dialog';
import ZipDownloadDialog from '../dialog/zip-download-dialog'; import ZipDownloadDialog from '../dialog/zip-download-dialog';
import ShareDialog from '../dialog/share-dialog';
import Rename from '../dialog/rename-dirent'; import Rename from '../dialog/rename-dirent';
import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-dialog'; import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-dialog';
@@ -17,8 +17,6 @@ import ModalPortal from '../modal-portal';
import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu'; import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu';
import toaster from '../toast'; import toaster from '../toast';
import '../../css/dirents-menu.css';
const propTypes = { const propTypes = {
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
userPerm: PropTypes.string.isRequired, userPerm: PropTypes.string.isRequired,
@@ -303,58 +301,108 @@ class MultipleDirOperationToolbar extends React.Component {
const { repoID, repoTags, userPerm } = this.props; const { repoID, repoTags, userPerm } = this.props;
const dirent = this.props.selectedDirentList[0]; const dirent = this.props.selectedDirentList[0];
const direntPath = this.getDirentPath(dirent); const direntPath = this.getDirentPath(dirent);
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm); const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
let canDelete = true;
let canDownload = true; let canModify = false;
let canCopy = true; let canCopy = false;
let canModify = true; let canDelete = false;
let canDownload = false;
switch (userPerm) {
case 'rw':
case 'admin':
canModify = true;
canCopy = true;
canDelete = true;
canDownload = true;
break;
case 'cloud-edit':
canModify = true;
canCopy = true;
canDelete = true;
break;
case 'r':
canCopy = true;
canDownload = true;
break;
}
if (isCustomPermission) { if (isCustomPermission) {
const { permission } = customPermission; const { permission } = customPermission;
canDelete = permission.delete;
canDownload = permission.download;
canCopy = permission.copy;
canModify = permission.modify; canModify = permission.modify;
canCopy = permission.copy;
canDownload = permission.download;
canDelete = permission.delete;
} }
return ( return (
<Fragment> <Fragment>
<div className="dir-operation"> <ButtonGroup className="">
<div className="d-flex">
<ButtonGroup className="flex-row group-operations">
{(userPerm === 'rw' || userPerm === 'admin' || isCustomPermission) && (
<Fragment> <Fragment>
{canModify && <Button className="secondary group-op-item action-icon sf2-icon-move" title={gettext('Move')} aria-label={gettext('Move')} onClick={this.onMoveToggle}></Button>} {canModify &&
{canCopy && <Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} aria-label={gettext('Copy')} onClick={this.onCopyToggle}></Button>} <Button
{canDelete && <Button className="secondary group-op-item action-icon sf3-font-delete1 sf3-font" title={gettext('Delete')} aria-label={gettext('Delete')} onClick={this.onItemsDelete}></Button>} className="op-btn selected-dirent-op-btn"
{canDownload && <Button className="secondary group-op-item action-icon sf2-icon-download" title={gettext('Download')} aria-label={gettext('Download')} onClick={this.onItemsDownload}></Button>} onClick={this.onMoveToggle}
>
<i
className="selected-dirent-op-btn-icon sf3-font-move1 sf3-font"
aria-hidden={true}
></i>
<span className="selected-dirent-op-btn-text">{gettext('Move')}</span>
</Button>
}
{canCopy &&
<Button
className="op-btn selected-dirent-op-btn"
onClick={this.onCopyToggle}
>
<i
className="selected-dirent-op-btn-icon sf3-font-copy1 sf3-font"
aria-hidden={true}
></i>
<span className="selected-dirent-op-btn-text">{gettext('Copy')}</span>
</Button>
}
{canDelete &&
<Button
className="op-btn selected-dirent-op-btn"
onClick={this.onItemsDelete}
>
<i
className="selected-dirent-op-btn-icon sf3-font-delete1 sf3-font"
aria-hidden={true}
></i>
<span className="selected-dirent-op-btn-text">{gettext('Delete')}</span>
</Button>
}
{canDownload &&
<Button
className="op-btn selected-dirent-op-btn"
onClick={this.onItemsDownload}
>
<i
className="selected-dirent-op-btn-icon sf3-font-download1 sf3-font"
aria-hidden={true}
></i>
<span className="selected-dirent-op-btn-text">{gettext('Download')}</span>
</Button>
}
</Fragment> </Fragment>
)}
{userPerm === 'cloud-edit' && (
<Fragment>
{canModify && <Button className="secondary group-op-item action-icon sf2-icon-move" title={gettext('Move')} aria-label={gettext('Move')} onClick={this.onMoveToggle}></Button>}
{canCopy && <Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} aria-label={gettext('Copy')} onClick={this.onCopyToggle}></Button>}
{canDelete && <Button className="secondary group-op-item action-icon sf3-font-delete1 sf3-font" title={gettext('Delete')} aria-label={gettext('Delete')} onClick={this.onItemsDelete}></Button>}
</Fragment>
)}
{userPerm === 'r' && (
<Fragment>
<Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} aria-label={gettext('Copy')} onClick={this.onCopyToggle}></Button>
<Button className="secondary group-op-item action-icon sf2-icon-download" title={gettext('Download')} aria-label={gettext('Download')} onClick={this.onItemsDownload}></Button>
</Fragment>
)}
{this.props.selectedDirentList.length === 1 && {this.props.selectedDirentList.length === 1 &&
<ItemDropdownMenu <ItemDropdownMenu
tagName={'button'} tagName={'button'}
item={this.props.selectedDirentList[0]} item={this.props.selectedDirentList[0]}
toggleClass={'fas fa-ellipsis-v dirents-more-menu'} toggleClass={'op-btn selected-dirent-op-btn selected-dirent-more-op-btn'}
toggleChildren={(<>
<i
className="selected-dirent-op-btn-icon sf3-font-more-vertical sf3-font"
aria-hidden={true}
></i>
<span className="selected-dirent-op-btn-text">{gettext('More')}</span>
</>)}
onMenuItemClick={this.onMenuItemClick} onMenuItemClick={this.onMenuItemClick}
getMenuList={this.getDirentMenuList} getMenuList={this.getDirentMenuList}
/> />
} }
</ButtonGroup> </ButtonGroup>
</div>
</div>
{this.state.isMoveDialogShow && {this.state.isMoveDialogShow &&
<MoveDirentDialog <MoveDirentDialog
path={this.props.path} path={this.props.path}

View File

@@ -1,15 +0,0 @@
.dirents-more-menu {
margin-left: 0;
padding: 4px 15px;
border: 1px solid #ccc;
border-top-right-radius: 2px !important;
border-bottom-right-radius: 2px !important;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
width: 46px;
height: 30px;
}
.dirents-more-menu:hover {
background-color: #fff;
border: 1px solid #ccc;
}

View File

@@ -33,21 +33,29 @@
border-radius: 2px; border-radius: 2px;
} }
.group-operations { .op-btn.selected-dirent-op-btn {
margin-right: 0.25rem; padding: 0 .75rem;
font-weight: normal;
} }
.group-operations .group-op-item { .op-btn.selected-dirent-more-op-btn {
padding: 0 0.5rem; margin-left: -1px;
height: 30px; border-top-left-radius: 0;
min-width: 46px; border-bottom-left-radius: 0;
background-color: #fff;
line-height: 29px;
font-weight: normal;
border: 1px solid #ccc;
border-radius: 2px;
font-size: 1.125rem;
} }
.selected-dirent-op-btn .selected-dirent-op-btn-icon { /* overwrite styles from seafile-ui.css */
font-size: 1rem;
color: #444;
vertical-align: middle;
}
.selected-dirent-op-btn-text {
font-size: .875rem;
margin-left: 6px;
vertical-align: middle;
}
/* end file-operation toolbar */ /* end file-operation toolbar */
/* begin view-mode toolbar */ /* begin view-mode toolbar */

View File

@@ -5,6 +5,7 @@ import CurDirPath from '../../components/cur-dir-path';
import DirentDetail from '../../components/dirent-detail/dirent-details'; import DirentDetail from '../../components/dirent-detail/dirent-details';
import LibDetail from '../../components/dirent-detail/lib-details'; import LibDetail from '../../components/dirent-detail/lib-details';
import DirColumnView from '../../components/dir-view-mode/dir-column-view'; import DirColumnView from '../../components/dir-view-mode/dir-column-view';
import ToolbarForSelectedDirents from '../../components/toolbar/selected-dirents-toolbar';
import '../../css/lib-content-view.css'; import '../../css/lib-content-view.css';
@@ -19,11 +20,13 @@ const propTypes = {
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
pathExist: PropTypes.bool.isRequired, pathExist: PropTypes.bool.isRequired,
// repoinfo // repoinfo
repoEncrypted: PropTypes.bool.isRequired,
currentRepoInfo: PropTypes.object.isRequired, currentRepoInfo: PropTypes.object.isRequired,
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
enableDirPrivateShare: PropTypes.bool.isRequired, enableDirPrivateShare: PropTypes.bool.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired, isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string, userPerm: PropTypes.string,
isRepoOwner: PropTypes.bool.isRequired,
// path func // path func
onTabNavClick: PropTypes.func.isRequired, onTabNavClick: PropTypes.func.isRequired,
onMainNavBarClick: PropTypes.func.isRequired, onMainNavBarClick: PropTypes.func.isRequired,
@@ -88,6 +91,10 @@ const propTypes = {
direntDetailPanelTab: PropTypes.string, direntDetailPanelTab: PropTypes.string,
loadDirentList: PropTypes.func, loadDirentList: PropTypes.func,
fullDirentList: PropTypes.array, fullDirentList: PropTypes.array,
unSelectDirent: PropTypes.func,
onFilesTagChanged: PropTypes.func.isRequired,
showShareBtn: PropTypes.bool.isRequired,
}; };
class LibContentContainer extends React.Component { class LibContentContainer extends React.Component {
@@ -174,6 +181,31 @@ class LibContentContainer extends React.Component {
</div> </div>
} }
<div className="cur-view-path"> <div className="cur-view-path">
{this.props.isDirentSelected ?
<ToolbarForSelectedDirents
repoID={this.props.repoID}
path={this.props.path}
userPerm={this.props.userPerm}
repoEncrypted={this.props.repoEncrypted}
repoTags={this.props.repoTags}
selectedDirentList={this.props.selectedDirentList}
direntList={this.props.direntList}
onItemsMove={this.props.onItemsMove}
onItemsCopy={this.props.onItemsCopy}
onItemsDelete={this.props.onItemsDelete}
onItemRename={this.props.onItemRename}
isRepoOwner={this.props.isRepoOwner}
currentRepoInfo={this.props.currentRepoInfo}
enableDirPrivateShare={this.props.enableDirPrivateShare}
updateDirent={this.props.updateDirent}
unSelectDirent={this.props.unSelectDirent}
onFilesTagChanged={this.props.onFilesTagChanged}
showShareBtn={this.props.showShareBtn}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
showDirentDetail={this.props.showDirentDetail}
currentMode={this.props.currentMode}
switchViewMode={this.props.switchViewMode}
/> :
<CurDirPath <CurDirPath
repoID={repoID} repoID={repoID}
repoName={this.props.currentRepoInfo.repo_name} repoName={this.props.currentRepoInfo.repo_name}
@@ -195,6 +227,7 @@ class LibContentContainer extends React.Component {
switchViewMode={this.props.switchViewMode} switchViewMode={this.props.switchViewMode}
isCustomPermission={this.props.isCustomPermission} isCustomPermission={this.props.isCustomPermission}
/> />
}
</div> </div>
<div className={`cur-view-content lib-content-container ${this.props.isTreePanelShown ? 'view-mode-container' : ''}`} onScroll={this.onItemsScroll}> <div className={`cur-view-content lib-content-container ${this.props.isTreePanelShown ? 'view-mode-container' : ''}`} onScroll={this.onItemsScroll}>
{!this.props.pathExist && this.errMessage} {!this.props.pathExist && this.errMessage}

View File

@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import CommonToolbar from '../../components/toolbar/common-toolbar'; import CommonToolbar from '../../components/toolbar/common-toolbar';
import DirOperationToolBar from '../../components/toolbar/dir-operation-toolbar'; import DirOperationToolBar from '../../components/toolbar/dir-operation-toolbar';
import MultipleDirOperationToolbar from '../../components/toolbar/multiple-dir-operation-toolbar';
import ViewFileToolbar from '../../components/toolbar/view-file-toolbar'; import ViewFileToolbar from '../../components/toolbar/view-file-toolbar';
const propTypes = { const propTypes = {
@@ -87,31 +86,7 @@ class LibContentToolbar extends React.Component {
<Fragment> <Fragment>
<div className="cur-view-toolbar"> <div className="cur-view-toolbar">
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title={gettext('Side Nav Menu')} onClick={this.props.onSideNavMenuClick}></span> <span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title={gettext('Side Nav Menu')} onClick={this.props.onSideNavMenuClick}></span>
{this.props.isDirentSelected ? {!this.props.isDirentSelected &&
<MultipleDirOperationToolbar
repoID={this.props.repoID}
path={this.props.path}
userPerm={this.props.userPerm}
repoEncrypted={this.props.repoEncrypted}
repoTags={this.props.repoTags}
selectedDirentList={this.props.selectedDirentList}
direntList={this.props.direntList}
onItemsMove={this.props.onItemsMove}
onItemsCopy={this.props.onItemsCopy}
onItemsDelete={this.props.onItemsDelete}
onItemRename={this.props.onItemRename}
isRepoOwner={this.props.isRepoOwner}
currentRepoInfo={this.props.currentRepoInfo}
enableDirPrivateShare={this.props.enableDirPrivateShare}
updateDirent={this.props.updateDirent}
unSelectDirent={this.props.unSelectDirent}
onFilesTagChanged={this.props.onFilesTagChanged}
showShareBtn={this.props.showShareBtn}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
showDirentDetail={this.props.showDirentDetail}
currentMode={this.props.currentMode}
switchViewMode={this.props.switchViewMode}
/> :
<DirOperationToolBar <DirOperationToolBar
path={this.props.path} path={this.props.path}
repoID={this.props.repoID} repoID={this.props.repoID}

View File

@@ -2061,6 +2061,10 @@ class LibContentView extends React.Component {
</div> </div>
<div className="main-panel-center flex-row"> <div className="main-panel-center flex-row">
<LibContentContainer <LibContentContainer
repoEncrypted={this.state.repoEncrypted}
isRepoOwner={isRepoOwner}
onFilesTagChanged={this.onFileTagChanged}
unSelectDirent={this.unSelectDirent}
pathPrefix={this.props.pathPrefix} pathPrefix={this.props.pathPrefix}
isTreePanelShown={this.state.isTreePanelShown} isTreePanelShown={this.state.isTreePanelShown}
toggleTreePanel={this.toggleTreePanel} toggleTreePanel={this.toggleTreePanel}