fix(ui/browser): sort items by type

This commit is contained in:
hexxa 2021-08-29 18:54:16 +08:00 committed by Hexxa
parent 008181a9aa
commit 87868dea4c
2 changed files with 20 additions and 3 deletions

View file

@ -15,6 +15,7 @@ export interface User {
pwd: string;
role: string;
quota: Quota;
usedSpace: string;
}
export interface ListUsersResp {
@ -59,7 +60,12 @@ export interface ListSharingsResp {
}
export interface IUsersClient {
login: (user: string, pwd: string, captchaId: string, captchaInput:string) => Promise<Response>;
login: (
user: string,
pwd: string,
captchaId: string,
captchaInput: string
) => Promise<Response>;
logout: () => Promise<Response>;
isAuthed: () => Promise<Response>;
self: () => Promise<Response>;

View file

@ -363,7 +363,18 @@ export class Browser extends React.Component<Props, State, {}> {
</div>
);
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("/")