2019-02-21 17:37:04 +08:00
import React , { Fragment } from 'react' ;
import PropTypes from 'prop-types' ;
2019-03-15 10:10:24 +08:00
import { gettext } from '../../utils/constants' ;
2019-02-21 17:37:04 +08:00
import CommonToolbar from '../../components/toolbar/common-toolbar' ;
import ViewModeToolbar from '../../components/toolbar/view-mode-toolbar' ;
import DirOperationToolBar from '../../components/toolbar/dir-operation-toolbar' ;
2019-08-29 15:28:54 +08:00
import MultipleDirOperationToolbar from '../../components/toolbar/multiple-dir-operation-toolbar' ;
2019-03-15 10:10:24 +08:00
import ViewFileToolbar from '../../components/toolbar/view-file-toolbar' ;
2021-09-13 10:37:07 +08:00
import { Utils } from '../../utils/utils' ;
2019-02-21 17:37:04 +08:00
const propTypes = {
isViewFile : PropTypes . bool . isRequired ,
2019-04-19 15:50:27 +08:00
filePermission : PropTypes . string ,
2019-02-21 17:37:04 +08:00
isDraft : PropTypes . bool . isRequired ,
hasDraft : PropTypes . bool . isRequired ,
2019-03-15 10:10:24 +08:00
fileTags : PropTypes . array . isRequired ,
2019-03-19 20:04:40 +08:00
onFileTagChanged : PropTypes . func . isRequired , // for file-view-toolbar
2019-02-21 17:37:04 +08:00
// side-panel
onSideNavMenuClick : PropTypes . func . isRequired ,
// mutiple-dir
isDirentSelected : PropTypes . bool . isRequired ,
repoID : PropTypes . string . isRequired ,
path : PropTypes . string . isRequired ,
selectedDirentList : PropTypes . array . isRequired ,
onItemsMove : PropTypes . func . isRequired ,
onItemsCopy : PropTypes . func . isRequired ,
onItemsDelete : PropTypes . func . isRequired ,
// dir
direntList : PropTypes . array . isRequired ,
repoName : PropTypes . string . isRequired ,
repoEncrypted : PropTypes . bool . isRequired ,
isGroupOwnedRepo : PropTypes . bool . isRequired ,
userPerm : PropTypes . string . isRequired ,
showShareBtn : PropTypes . bool . isRequired ,
enableDirPrivateShare : PropTypes . bool . isRequired ,
onAddFile : PropTypes . func . isRequired ,
onAddFolder : PropTypes . func . isRequired ,
onUploadFile : PropTypes . func . isRequired ,
onUploadFolder : PropTypes . func . isRequired ,
// view-mode
currentMode : PropTypes . string . isRequired ,
switchViewMode : PropTypes . func . isRequired ,
// search
onSearchedClick : PropTypes . func . isRequired ,
2019-03-18 17:32:49 +08:00
isRepoOwner : PropTypes . bool . isRequired ,
// selected menu
2019-03-19 20:04:40 +08:00
onFilesTagChanged : PropTypes . func . isRequired , // for mutiple select toolbar
2019-03-18 17:32:49 +08:00
updateDirent : PropTypes . func . isRequired ,
2019-05-30 14:13:23 +08:00
unSelectDirent : PropTypes . func ,
currentRepoInfo : PropTypes . object ,
2023-09-13 08:40:50 +08:00
onItemRename : PropTypes . func ,
showDirentDetail : PropTypes . func ,
2019-02-21 17:37:04 +08:00
} ;
class LibContentToolbar extends React . Component {
2019-02-22 15:35:31 +08:00
render ( ) {
2020-06-24 18:35:38 +08:00
2021-09-13 10:37:07 +08:00
const { userPerm } = this . props ;
const { isCustomPermission } = Utils . getUserPermission ( userPerm ) ;
2019-02-21 17:37:04 +08:00
if ( this . props . isViewFile ) {
return (
< Fragment >
< 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 } > < / s p a n >
2020-11-02 13:56:35 +08:00
< ViewFileToolbar
2019-03-15 10:10:24 +08:00
path = { this . props . path }
repoID = { this . props . repoID }
userPerm = { this . props . userPerm }
repoEncrypted = { this . props . repoEncrypted }
enableDirPrivateShare = { this . props . enableDirPrivateShare }
isGroupOwnedRepo = { this . props . isGroupOwnedRepo }
filePermission = { this . props . filePermission }
isDraft = { this . props . isDraft }
hasDraft = { this . props . hasDraft }
fileTags = { this . props . fileTags }
2019-03-19 20:04:40 +08:00
onFileTagChanged = { this . props . onFileTagChanged }
2019-04-25 18:28:52 +08:00
showShareBtn = { this . props . showShareBtn }
2019-03-15 10:10:24 +08:00
/ >
2021-09-13 10:37:07 +08:00
< ViewModeToolbar currentMode = { this . props . currentMode } switchViewMode = { this . props . switchViewMode } isCustomPermission = { isCustomPermission } / >
2019-02-21 17:37:04 +08:00
< / d i v >
2020-11-16 10:45:19 +08:00
< CommonToolbar isLibView = { true } repoID = { this . props . repoID } repoName = { this . props . repoName } onSearchedClick = { this . props . onSearchedClick } searchPlaceholder = { gettext ( 'Search files in this library' ) } / >
2019-02-21 17:37:04 +08:00
< / F r a g m e n t >
) ;
}
return (
< Fragment >
< 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 } > < / s p a n >
2020-02-29 22:47:48 +08:00
{ this . props . isDirentSelected ?
< MultipleDirOperationToolbar
2020-11-02 13:56:35 +08:00
repoID = { this . props . repoID }
2020-02-29 22:47:48 +08:00
path = { this . props . path }
userPerm = { this . props . userPerm }
repoEncrypted = { this . props . repoEncrypted }
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 }
/ > :
2020-11-02 13:56:35 +08:00
< DirOperationToolBar
2020-02-29 22:47:48 +08:00
path = { this . props . path }
repoID = { this . props . repoID }
repoName = { this . props . repoName }
repoEncrypted = { this . props . repoEncrypted }
direntList = { this . props . direntList }
showShareBtn = { this . props . showShareBtn }
enableDirPrivateShare = { this . props . enableDirPrivateShare }
userPerm = { this . props . userPerm }
isGroupOwnedRepo = { this . props . isGroupOwnedRepo }
onAddFile = { this . props . onAddFile }
onAddFolder = { this . props . onAddFolder }
onUploadFile = { this . props . onUploadFile }
onUploadFolder = { this . props . onUploadFolder }
currentMode = { this . props . currentMode }
switchViewMode = { this . props . switchViewMode }
/ >
}
2019-02-21 17:37:04 +08:00
< / d i v >
2020-11-16 10:45:19 +08:00
< CommonToolbar isLibView = { true } repoID = { this . props . repoID } repoName = { this . props . repoName } onSearchedClick = { this . props . onSearchedClick } searchPlaceholder = { gettext ( 'Search files in this library' ) } / >
2019-02-21 17:37:04 +08:00
< / F r a g m e n t >
) ;
}
}
LibContentToolbar . propTypes = propTypes ;
export default LibContentToolbar ;