fix(fe/panels): sort entries in refreshing
This commit is contained in:
parent
6bd5343673
commit
7831aa7de5
6 changed files with 74 additions and 23 deletions
|
@ -53,7 +53,22 @@ describe("FilesPanel", () => {
|
||||||
expect(updater().props.filesInfo.dirPath).toEqual(newCwd);
|
expect(updater().props.filesInfo.dirPath).toEqual(newCwd);
|
||||||
expect(updater().props.filesInfo.isSharing).toEqual(true);
|
expect(updater().props.filesInfo.isSharing).toEqual(true);
|
||||||
expect(updater().props.filesInfo.items).toEqual(
|
expect(updater().props.filesInfo.items).toEqual(
|
||||||
List(filesResps.listHomeMockResp.data.metadatas)
|
List([
|
||||||
|
{
|
||||||
|
name: "mock_dir",
|
||||||
|
size: 0,
|
||||||
|
modTime: "0",
|
||||||
|
isDir: true,
|
||||||
|
sha1: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "mock_file",
|
||||||
|
size: 5,
|
||||||
|
modTime: "0",
|
||||||
|
isDir: false,
|
||||||
|
sha1: "mock_file_sha1",
|
||||||
|
},
|
||||||
|
])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,22 @@ describe("State Manager", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(coreState.filesInfo.items).toEqual(
|
expect(coreState.filesInfo.items).toEqual(
|
||||||
List(filesResps.listHomeMockResp.data.metadatas)
|
List([
|
||||||
|
{
|
||||||
|
name: "mock_dir",
|
||||||
|
size: 0,
|
||||||
|
modTime: "0",
|
||||||
|
isDir: true,
|
||||||
|
sha1: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "mock_file",
|
||||||
|
size: 5,
|
||||||
|
modTime: "0",
|
||||||
|
isDir: false,
|
||||||
|
sha1: "mock_file_sha1",
|
||||||
|
},
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
// login
|
// login
|
||||||
|
@ -182,7 +197,22 @@ describe("State Manager", () => {
|
||||||
expect(coreState.filesInfo.dirPath.join("/")).toEqual(sharingPath);
|
expect(coreState.filesInfo.dirPath.join("/")).toEqual(sharingPath);
|
||||||
expect(coreState.filesInfo.isSharing).toEqual(true);
|
expect(coreState.filesInfo.isSharing).toEqual(true);
|
||||||
expect(coreState.filesInfo.items).toEqual(
|
expect(coreState.filesInfo.items).toEqual(
|
||||||
List(filesResps.listMockResp.data.metadatas)
|
List([
|
||||||
|
{
|
||||||
|
name: "mock_dir",
|
||||||
|
size: 0,
|
||||||
|
modTime: "0",
|
||||||
|
isDir: true,
|
||||||
|
sha1: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "mock_file",
|
||||||
|
size: 5,
|
||||||
|
modTime: "0",
|
||||||
|
isDir: false,
|
||||||
|
sha1: "mock_file_sha1",
|
||||||
|
},
|
||||||
|
])
|
||||||
);
|
);
|
||||||
expect(coreState.sharingsInfo.sharings).toEqual(Map<string, string>());
|
expect(coreState.sharingsInfo.sharings).toEqual(Map<string, string>());
|
||||||
expect(coreState.uploadingsInfo.uploadings).toEqual(List<UploadEntry>([]));
|
expect(coreState.uploadingsInfo.uploadings).toEqual(List<UploadEntry>([]));
|
||||||
|
|
|
@ -767,7 +767,12 @@ export class FilesPanel extends React.Component<Props, State, {}> {
|
||||||
};
|
};
|
||||||
|
|
||||||
orderBy = (columnName: string) => {
|
orderBy = (columnName: string) => {
|
||||||
updater().sortFiles(columnName);
|
const order =
|
||||||
|
this.props.filesInfo.orderBy === columnName
|
||||||
|
? !this.props.filesInfo.order
|
||||||
|
: true;
|
||||||
|
|
||||||
|
updater().sortFiles(columnName, order);
|
||||||
this.props.update(updater().updateFilesInfo);
|
this.props.update(updater().updateFilesInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,15 @@ export class SharingsPanel extends React.Component<Props, State, {}> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
CronTable().setInterval("refreshUploadings", {
|
CronTable().setInterval("listSharings", {
|
||||||
func: updater().refreshUploadings,
|
func: updater().listSharings,
|
||||||
args: [],
|
args: [],
|
||||||
delay: 5000,
|
delay: 5000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
CronTable().clearInterval("refreshUploadings");
|
CronTable().clearInterval("listSharings");
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading = (state: boolean) => {
|
setLoading = (state: boolean) => {
|
||||||
|
@ -153,7 +153,8 @@ export class SharingsPanel extends React.Component<Props, State, {}> {
|
||||||
};
|
};
|
||||||
|
|
||||||
orderBy = (columnName: string) => {
|
orderBy = (columnName: string) => {
|
||||||
updater().sortSharings(columnName);
|
const order = !this.props.sharingsInfo.order;
|
||||||
|
updater().sortSharings(columnName, order);
|
||||||
this.props.update(updater().updateSharingsInfo);
|
this.props.update(updater().updateSharingsInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,8 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
};
|
};
|
||||||
|
|
||||||
orderBy = (columnName: string) => {
|
orderBy = (columnName: string) => {
|
||||||
updater().sortUploadings(columnName);
|
const order = !this.props.uploadingsInfo.order;
|
||||||
|
updater().sortUploadings(columnName, order);
|
||||||
this.props.update(updater().updateUploadingsInfo);
|
this.props.update(updater().updateUploadingsInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,10 @@ export class Updater {
|
||||||
return errServer;
|
return errServer;
|
||||||
}
|
}
|
||||||
this.props.sharingsInfo.sharings = Map<string, string>(resp.data.IDs);
|
this.props.sharingsInfo.sharings = Map<string, string>(resp.data.IDs);
|
||||||
|
this.sortSharings(
|
||||||
|
this.props.sharingsInfo.orderBy,
|
||||||
|
this.props.sharingsInfo.order
|
||||||
|
);
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -242,12 +246,11 @@ export class Updater {
|
||||||
if (status !== "") {
|
if (status !== "") {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this part is duplicated in the panel_files.tsx
|
// TODO: this part is duplicated in the panel_files.tsx
|
||||||
const sortKeys = List<string>([
|
// const sortKeys = List<string>([
|
||||||
this.props.msg.pkg.get("item.type"),
|
// this.props.msg.pkg.get("item.type"),
|
||||||
this.props.msg.pkg.get("item.name"),
|
// this.props.msg.pkg.get("item.name"),
|
||||||
]);
|
// ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
setItems = async (dirParts: List<string>): Promise<string> => {
|
setItems = async (dirParts: List<string>): Promise<string> => {
|
||||||
|
@ -257,6 +260,7 @@ export class Updater {
|
||||||
if (listResp.status === 200) {
|
if (listResp.status === 200) {
|
||||||
this.props.filesInfo.dirPath = dirParts;
|
this.props.filesInfo.dirPath = dirParts;
|
||||||
this.props.filesInfo.items = List<MetadataResp>(listResp.data.metadatas);
|
this.props.filesInfo.items = List<MetadataResp>(listResp.data.metadatas);
|
||||||
|
this.sortFiles(this.props.filesInfo.orderBy, this.props.filesInfo.order);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
this.props.filesInfo.dirPath = List<string>([]);
|
this.props.filesInfo.dirPath = List<string>([]);
|
||||||
|
@ -270,6 +274,7 @@ export class Updater {
|
||||||
if (listResp.status === 200) {
|
if (listResp.status === 200) {
|
||||||
this.props.filesInfo.dirPath = List<string>(listResp.data.cwd.split("/"));
|
this.props.filesInfo.dirPath = List<string>(listResp.data.cwd.split("/"));
|
||||||
this.props.filesInfo.items = List<MetadataResp>(listResp.data.metadatas);
|
this.props.filesInfo.items = List<MetadataResp>(listResp.data.metadatas);
|
||||||
|
this.sortFiles(this.props.filesInfo.orderBy, this.props.filesInfo.order);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
this.props.filesInfo.dirPath = List<string>([]);
|
this.props.filesInfo.dirPath = List<string>([]);
|
||||||
|
@ -880,7 +885,7 @@ export class Updater {
|
||||||
this.props.sharingsInfo.order = order;
|
this.props.sharingsInfo.order = order;
|
||||||
};
|
};
|
||||||
|
|
||||||
sortFiles = (columnName: string) => {
|
sortFiles = (columnName: string, order: boolean) => {
|
||||||
let orderByKey = 0;
|
let orderByKey = 0;
|
||||||
switch (columnName) {
|
switch (columnName) {
|
||||||
case this.props.msg.pkg.get("item.name"):
|
case this.props.msg.pkg.get("item.name"):
|
||||||
|
@ -892,10 +897,6 @@ export class Updater {
|
||||||
default:
|
default:
|
||||||
orderByKey = 2;
|
orderByKey = 2;
|
||||||
}
|
}
|
||||||
const order =
|
|
||||||
this.props.filesInfo.orderBy === columnName
|
|
||||||
? !this.props.filesInfo.order
|
|
||||||
: true;
|
|
||||||
const rows = this.props.filesInfo.items.map((item: MetadataResp): Row => {
|
const rows = this.props.filesInfo.items.map((item: MetadataResp): Row => {
|
||||||
return {
|
return {
|
||||||
val: item,
|
val: item,
|
||||||
|
@ -913,9 +914,8 @@ export class Updater {
|
||||||
this.updateItems(sortedFiles);
|
this.updateItems(sortedFiles);
|
||||||
};
|
};
|
||||||
|
|
||||||
sortUploadings = (columnName: string) => {
|
sortUploadings = (columnName: string, order: boolean) => {
|
||||||
const orderByKey = 0;
|
const orderByKey = 0;
|
||||||
const order = !this.props.uploadingsInfo.order;
|
|
||||||
const rows = this.props.uploadingsInfo.uploadings.map(
|
const rows = this.props.uploadingsInfo.uploadings.map(
|
||||||
(uploading: UploadEntry): Row => {
|
(uploading: UploadEntry): Row => {
|
||||||
return {
|
return {
|
||||||
|
@ -933,9 +933,8 @@ export class Updater {
|
||||||
this.updateUploadings(sorted);
|
this.updateUploadings(sorted);
|
||||||
};
|
};
|
||||||
|
|
||||||
sortSharings = (columnName: string) => {
|
sortSharings = (columnName: string, order: boolean) => {
|
||||||
const orderByKey = 0;
|
const orderByKey = 0;
|
||||||
const order = !this.props.sharingsInfo.order;
|
|
||||||
const rows = this.props.sharingsInfo.sharings
|
const rows = this.props.sharingsInfo.sharings
|
||||||
.keySeq()
|
.keySeq()
|
||||||
.map((sharingPath: string): Row => {
|
.map((sharingPath: string): Row => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue