- {menuItem.key === 'Display files' && this.props.isDisplayFiles && (
+ {menuItem.tick && (
)}
{menuItem.icon_dom || null}
diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js
index 34067c9cf4..c778f3ab97 100644
--- a/frontend/src/pages/lib-content-view/lib-content-view.js
+++ b/frontend/src/pages/lib-content-view/lib-content-view.js
@@ -9,7 +9,7 @@ import { Modal } from 'reactstrap';
import { navigate } from '@gatsbyjs/reach-router';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
-import { gettext, siteRoot, username } from '../../utils/constants';
+import { gettext, SF_DIRECTORY_TREE_SORT_BY_KEY, SF_DIRECTORY_TREE_SORT_ORDER_KEY, siteRoot, username } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import { Utils } from '../../utils/utils';
import { Dirent, FileTag, RepoTag, RepoInfo } from '../../models';
@@ -2095,7 +2095,9 @@ class LibContentView extends React.Component {
let direntList = list.map(item => {
return new Dirent(item);
});
- direntList = Utils.sortDirents(direntList, this.state.sortBy, this.state.sortOrder);
+ const sortBy = cookie.load(SF_DIRECTORY_TREE_SORT_BY_KEY) || 'name';
+ const sortOrder = cookie.load(SF_DIRECTORY_TREE_SORT_ORDER_KEY) || 'asc';
+ direntList = Utils.sortDirents(direntList, sortBy, sortOrder);
let nodeList = direntList.map(object => {
return new TreeNode({ object });
@@ -2186,11 +2188,18 @@ class LibContentView extends React.Component {
cookie.save('seafile-repo-dir-sort-order', sortOrder);
const sortedDirentList = Utils.sortDirents(this.state.direntList, sortBy, sortOrder);
- const sortedTreeData = treeHelper.sortTreeNodes(this.state.treeData, sortBy, sortOrder);
this.setState({
sortBy: sortBy,
sortOrder: sortOrder,
direntList: sortedDirentList,
+ });
+ };
+
+ sortTreeNode = (sortBy, sortOrder) => {
+ cookie.save(SF_DIRECTORY_TREE_SORT_BY_KEY, sortBy);
+ cookie.save(SF_DIRECTORY_TREE_SORT_ORDER_KEY, sortOrder);
+ const sortedTreeData = treeHelper.sortTreeNodes(this.state.treeData, sortBy, sortOrder);
+ this.setState({
treeData: sortedTreeData,
});
};
@@ -2551,6 +2560,7 @@ class LibContentView extends React.Component {
updateCurrentPath={this.updatePath}
toggleShowDirentToolbar={this.toggleShowDirentToolbar}
updateTreeNode={this.updateTreeNode}
+ sortTreeNode={this.sortTreeNode}
/>
:
{gettext('Folder does not exist.')}
diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js
index 357dacd8f6..f2dcda7803 100644
--- a/frontend/src/utils/constants.js
+++ b/frontend/src/utils/constants.js
@@ -233,3 +233,6 @@ export const MimetypesKind = {
export const LARGE_DIALOG_STYLE = { maxWidth: '980px' };
export const SF_COLOR_MODE = 'sf_color_mode';
+
+export const SF_DIRECTORY_TREE_SORT_BY_KEY = 'sf_directory_tree_sort_by';
+export const SF_DIRECTORY_TREE_SORT_ORDER_KEY = 'sf_directory_tree_sort_order';
diff --git a/frontend/src/utils/text-translation.js b/frontend/src/utils/text-translation.js
index c02c8286fb..c99466d2ef 100644
--- a/frontend/src/utils/text-translation.js
+++ b/frontend/src/utils/text-translation.js
@@ -278,6 +278,16 @@ const TextTranslation = {
key: 'New child tag',
value: gettext('New child tag'),
},
+
+ // directory op
+ ASCENDING_BY_NAME: {
+ key: 'Ascending by name',
+ value: gettext('Ascending by name'),
+ },
+ DESCENDING_BY_NAME: {
+ key: 'Descending by name',
+ value: gettext('Descending by name'),
+ },
};
export default TextTranslation;