2023-10-09 21:27:44 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2024-05-21 21:06:50 +08:00
|
|
|
import TextTranslation from '../../utils/text-translation';
|
2024-06-17 16:52:44 +08:00
|
|
|
import ViewModes from '../../components/view-modes';
|
2024-11-25 10:23:42 +08:00
|
|
|
import SortMenu from '../../components/sort-menu';
|
2024-09-14 16:31:32 +08:00
|
|
|
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';
|
2025-03-18 17:40:02 +08:00
|
|
|
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 = {
|
2021-09-13 10:37:07 +08:00
|
|
|
userPerm: PropTypes.string,
|
2018-11-28 12:41:49 +08:00
|
|
|
currentPath: PropTypes.string.isRequired,
|
2024-05-21 21:06:50 +08:00
|
|
|
currentMode: PropTypes.string.isRequired,
|
|
|
|
switchViewMode: PropTypes.func.isRequired,
|
|
|
|
isCustomPermission: PropTypes.bool,
|
2024-07-17 11:09:53 +08:00
|
|
|
sortBy: PropTypes.string,
|
|
|
|
sortOrder: PropTypes.string,
|
|
|
|
sortItems: PropTypes.func,
|
2024-08-12 17:15:56 +08:00
|
|
|
viewId: PropTypes.string,
|
2024-12-23 17:47:20 +08:00
|
|
|
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
|
|
|
|
2018-11-27 14:47:19 +08:00
|
|
|
class DirTool extends React.Component {
|
2018-09-18 20:57:17 -05:00
|
|
|
|
2024-07-17 11:09:53 +08:00
|
|
|
onSelectSortOption = (item) => {
|
|
|
|
const [sortBy, sortOrder] = item.value.split('-');
|
|
|
|
this.props.sortItems(sortBy, sortOrder);
|
|
|
|
};
|
|
|
|
|
2024-05-21 21:06:50 +08:00
|
|
|
render() {
|
2025-04-02 16:04:39 +08:00
|
|
|
const { currentMode, currentPath, sortBy, sortOrder, viewId, isCustomPermission, onToggleDetail, onCloseDetail } = this.props;
|
2024-07-01 11:25:08 +08:00
|
|
|
const propertiesText = TextTranslation.PROPERTIES.value;
|
2024-07-22 09:45:08 +08:00
|
|
|
const isFileExtended = currentPath.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES + '/');
|
2024-11-22 17:11:55 +08:00
|
|
|
const isTagView = currentPath.startsWith('/' + PRIVATE_FILE_TYPE.TAGS_PROPERTIES + '/');
|
2025-03-18 17:40:02 +08:00
|
|
|
const isAllTagsView = currentPath.split('/').pop() === ALL_TAGS_ID;
|
2024-07-10 18:18:57 +08:00
|
|
|
|
|
|
|
if (isFileExtended) {
|
|
|
|
return (
|
2024-08-21 17:14:57 +08:00
|
|
|
<div className="dir-tool">
|
2024-11-15 16:08:46 +08:00
|
|
|
<MetadataViewToolBar
|
|
|
|
viewId={viewId}
|
|
|
|
isCustomPermission={isCustomPermission}
|
2024-12-23 17:47:20 +08:00
|
|
|
onToggleDetail={onToggleDetail}
|
2024-12-24 17:52:18 +08:00
|
|
|
onCloseDetail={onCloseDetail}
|
2024-11-15 16:08:46 +08:00
|
|
|
/>
|
2024-07-10 18:18:57 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-11-22 17:11:55 +08:00
|
|
|
if (isTagView) {
|
|
|
|
return (
|
|
|
|
<div className="dir-tool">
|
2025-03-20 16:29:39 +08:00
|
|
|
{isAllTagsView && <TagsTableSearcher />}
|
|
|
|
{isAllTagsView ? <AllTagsSortSetter /> : <TagFilesSortSetter />}
|
2024-11-22 17:11:55 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-10-09 21:27:44 +08:00
|
|
|
return (
|
2025-04-02 16:04:39 +08:00
|
|
|
<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
|
|
|
}
|
2025-04-02 16:04:39 +08:00
|
|
|
</div>
|
2023-10-09 21:27:44 +08:00
|
|
|
);
|
2018-09-29 15:47:53 +08:00
|
|
|
}
|
2024-05-21 21:06:50 +08:00
|
|
|
|
2018-09-18 20:57:17 -05:00
|
|
|
}
|
|
|
|
|
2018-11-27 14:47:19 +08:00
|
|
|
DirTool.propTypes = propTypes;
|
2018-09-29 15:47:53 +08:00
|
|
|
|
2018-11-27 14:47:19 +08:00
|
|
|
export default DirTool;
|