1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00
Files
seahub/frontend/src/components/cur-dir-path/dir-tool.js

81 lines
2.8 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import TextTranslation from '../../utils/text-translation';
import ViewModes from '../../components/view-modes';
import SortMenu from '../../components/sort-menu';
import MetadataViewToolBar from '../../metadata/components/view-toolbar';
2025-02-09 17:59:27 +08:00
import TagsTableSearcher from '../../tag/views/all-tags/tags-table/tags-searcher';
2024-07-09 15:09:34 +08:00
import { PRIVATE_FILE_TYPE } from '../../constants';
import { ALL_TAGS_ID } from '../../tag/constants';
2025-03-20 16:29:39 +08:00
import AllTagsSortSetter from '../../tag/views/all-tags/tags-table/sort-setter';
import TagFilesSortSetter from '../../tag/views/tag-files/sort-setter';
2018-09-18 20:57:17 -05:00
2018-09-29 15:47:53 +08:00
const propTypes = {
userPerm: PropTypes.string,
2018-11-28 12:41:49 +08:00
currentPath: PropTypes.string.isRequired,
currentMode: PropTypes.string.isRequired,
switchViewMode: PropTypes.func.isRequired,
isCustomPermission: PropTypes.bool,
sortBy: PropTypes.string,
sortOrder: PropTypes.string,
sortItems: PropTypes.func,
viewId: PropTypes.string,
onToggleDetail: PropTypes.func,
2024-12-24 17:52:18 +08:00
onCloseDetail: PropTypes.func,
2018-09-29 15:47:53 +08:00
};
2018-09-18 20:57:17 -05:00
class DirTool extends React.Component {
2018-09-18 20:57:17 -05:00
onSelectSortOption = (item) => {
const [sortBy, sortOrder] = item.value.split('-');
this.props.sortItems(sortBy, sortOrder);
};
render() {
const { currentMode, currentPath, sortBy, sortOrder, viewId, isCustomPermission, onToggleDetail, onCloseDetail } = this.props;
2024-07-01 11:25:08 +08:00
const propertiesText = TextTranslation.PROPERTIES.value;
const isFileExtended = currentPath.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES + '/');
const isTagView = currentPath.startsWith('/' + PRIVATE_FILE_TYPE.TAGS_PROPERTIES + '/');
const isAllTagsView = currentPath.split('/').pop() === ALL_TAGS_ID;
if (isFileExtended) {
return (
<div className="dir-tool">
2024-11-15 16:08:46 +08:00
<MetadataViewToolBar
viewId={viewId}
isCustomPermission={isCustomPermission}
onToggleDetail={onToggleDetail}
2024-12-24 17:52:18 +08:00
onCloseDetail={onCloseDetail}
2024-11-15 16:08:46 +08:00
/>
</div>
);
}
if (isTagView) {
return (
<div className="dir-tool">
2025-03-20 16:29:39 +08:00
{isAllTagsView && <TagsTableSearcher />}
{isAllTagsView ? <AllTagsSortSetter /> : <TagFilesSortSetter />}
</div>
);
}
return (
<div className="dir-tool d-flex">
<ViewModes currentViewMode={currentMode} switchViewMode={this.props.switchViewMode} />
<SortMenu sortBy={sortBy} sortOrder={sortOrder} onSelectSortOption={this.onSelectSortOption} />
{(!isCustomPermission) &&
<div className="cur-view-path-btn" onClick={onToggleDetail}>
<span className="sf3-font sf3-font-info" aria-label={propertiesText} title={propertiesText}></span>
</div>
2025-03-20 16:32:33 +08:00
}
</div>
);
2018-09-29 15:47:53 +08:00
}
2018-09-18 20:57:17 -05:00
}
DirTool.propTypes = propTypes;
2018-09-29 15:47:53 +08:00
export default DirTool;