From 87868dea4c5b97ed00ebc6a33295d7fe66e99d97 Mon Sep 17 00:00:00 2001 From: hexxa Date: Sun, 29 Aug 2021 18:54:16 +0800 Subject: [PATCH] fix(ui/browser): sort items by type --- src/client/web/src/client/index.ts | 10 ++++++++-- src/client/web/src/components/browser.tsx | 13 ++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/client/web/src/client/index.ts b/src/client/web/src/client/index.ts index 6f81a42..afad508 100644 --- a/src/client/web/src/client/index.ts +++ b/src/client/web/src/client/index.ts @@ -15,6 +15,7 @@ export interface User { pwd: string; role: string; quota: Quota; + usedSpace: string; } export interface ListUsersResp { @@ -55,11 +56,16 @@ export interface ListUploadingsResp { } export interface ListSharingsResp { - sharingDirs: string[]; + sharingDirs: string[]; } export interface IUsersClient { - login: (user: string, pwd: string, captchaId: string, captchaInput:string) => Promise; + login: ( + user: string, + pwd: string, + captchaId: string, + captchaInput: string + ) => Promise; logout: () => Promise; isAuthed: () => Promise; self: () => Promise; diff --git a/src/client/web/src/components/browser.tsx b/src/client/web/src/components/browser.tsx index 800bc7c..63537cf 100644 --- a/src/client/web/src/components/browser.tsx +++ b/src/client/web/src/components/browser.tsx @@ -363,7 +363,18 @@ export class Browser extends React.Component { ); - const itemList = this.props.browser.items.map((item: MetadataResp) => { + const sortedItems = this.props.browser.items.sort( + (item1: MetadataResp, item2: MetadataResp) => { + if (item1.isDir && !item2.isDir) { + return -1; + } else if (!item1.isDir && item2.isDir) { + return 1; + } + return 0; + } + ); + + const itemList = sortedItems.map((item: MetadataResp) => { const isSelected = this.state.selectedItems.has(item.name); const dirPath = this.props.browser.dirPath.join("/"); const itemPath = dirPath.endsWith("/")