fix(fe/panel_uploadings): enable sorting after refreshing
This commit is contained in:
parent
7831aa7de5
commit
662b06a94b
4 changed files with 12 additions and 70 deletions
|
@ -63,7 +63,7 @@ describe("Login", () => {
|
||||||
filePath: info.realFilePath,
|
filePath: info.realFilePath,
|
||||||
size: info.size,
|
size: info.size,
|
||||||
uploaded: info.uploaded,
|
uploaded: info.uploaded,
|
||||||
state: UploadState.Ready,
|
state: UploadState.Stopped,
|
||||||
err: "",
|
err: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ describe("State Manager", () => {
|
||||||
filePath: info.realFilePath,
|
filePath: info.realFilePath,
|
||||||
size: info.size,
|
size: info.size,
|
||||||
uploaded: info.uploaded,
|
uploaded: info.uploaded,
|
||||||
state: UploadState.Ready,
|
state: UploadState.Stopped,
|
||||||
err: "",
|
err: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { List } from "immutable";
|
import { List } from "immutable";
|
||||||
|
|
||||||
import { BiSortUp } from "@react-icons/all-files/bi/BiSortUp";
|
|
||||||
|
|
||||||
import { Flexbox } from "./flexbox";
|
|
||||||
import { sortRows } from "../../common/utils";
|
|
||||||
|
|
||||||
export interface Row {
|
export interface Row {
|
||||||
elem: React.ReactNode; // element to display
|
elem: React.ReactNode; // element to display
|
||||||
val: Object; // original object value
|
val: Object; // original object value
|
||||||
|
@ -13,94 +8,32 @@ export interface Row {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
// sortKeys: List<string>; // display names in order for sorting
|
|
||||||
rows: List<React.ReactNode>;
|
rows: List<React.ReactNode>;
|
||||||
id?: string;
|
id?: string;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
className?: string;
|
className?: string;
|
||||||
// updateRows?: (rows: Object) => void; // this is a callback which update state with re-sorted rows
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface State {}
|
export interface State {}
|
||||||
// // orders: List<boolean>; // asc = true, desc = false
|
|
||||||
// }
|
|
||||||
|
|
||||||
export class Rows extends React.Component<Props, State, {}> {
|
export class Rows extends React.Component<Props, State, {}> {
|
||||||
constructor(p: Props) {
|
constructor(p: Props) {
|
||||||
super(p);
|
super(p);
|
||||||
// this.state = {
|
|
||||||
// orders: p.sortKeys.map((_: string, i: number) => {
|
|
||||||
// return false;
|
|
||||||
// }),
|
|
||||||
// };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sortRows = (key: number) => {
|
|
||||||
// if (this.props.updateRows == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// const sortOption = this.props.sortKeys.get(key);
|
|
||||||
// if (sortOption == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// const currentOrder = this.state.orders.get(key);
|
|
||||||
// if (currentOrder == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// const expectedOrder = !currentOrder;
|
|
||||||
|
|
||||||
// const sortedRows = sortRows(this.props.rows, key, expectedOrder);
|
|
||||||
// const sortedItems = sortedRows.map((row: Row): Object => {
|
|
||||||
// return row.val;
|
|
||||||
// });
|
|
||||||
// const newOrders = this.state.orders.set(key, !currentOrder);
|
|
||||||
// this.setState({ orders: newOrders });
|
|
||||||
// this.props.updateRows(sortedItems);
|
|
||||||
// };
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// const sortBtns = this.props.sortKeys.map(
|
|
||||||
// (displayName: string, i: number): React.ReactNode => {
|
|
||||||
// return (
|
|
||||||
// <button
|
|
||||||
// key={`rows-${i}`}
|
|
||||||
// className="float"
|
|
||||||
// onClick={() => {
|
|
||||||
// this.sortRows(i);
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// {displayName}
|
|
||||||
// </button>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
const bodyRows = this.props.rows.map(
|
const bodyRows = this.props.rows.map(
|
||||||
(row: React.ReactNode, i: number): React.ReactNode => {
|
(row: React.ReactNode, i: number): React.ReactNode => {
|
||||||
return <div key={`rows-r-${i}`}>{row}</div>;
|
return <div key={`rows-r-${i}`}>{row}</div>;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// const orderByList =
|
|
||||||
// sortBtns.size > 0 ? (
|
|
||||||
// <div className="margin-b-l">
|
|
||||||
// <Flexbox
|
|
||||||
// children={List([
|
|
||||||
// <BiSortUp size="3rem" className="black-font margin-r-m" />,
|
|
||||||
// <span>{sortBtns}</span>,
|
|
||||||
// ])}
|
|
||||||
// childrenStyles={List([{ flex: "0 0 auto" }, { flex: "0 0 auto" }])}
|
|
||||||
// />
|
|
||||||
// </div>
|
|
||||||
// ) : null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
id={this.props.id}
|
id={this.props.id}
|
||||||
style={this.props.style}
|
style={this.props.style}
|
||||||
className={this.props.className}
|
className={this.props.className}
|
||||||
>
|
>
|
||||||
{/* {orderByList} */}
|
|
||||||
{bodyRows}
|
{bodyRows}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -97,6 +97,11 @@ export class Updater {
|
||||||
return entry;
|
return entry;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.sortUploadings(
|
||||||
|
this.props.uploadingsInfo.orderBy,
|
||||||
|
this.props.uploadingsInfo.order
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
addSharing = async (): Promise<string> => {
|
addSharing = async (): Promise<string> => {
|
||||||
|
@ -163,7 +168,7 @@ export class Updater {
|
||||||
filePath: remoteInfo.realFilePath,
|
filePath: remoteInfo.realFilePath,
|
||||||
size: remoteInfo.size,
|
size: remoteInfo.size,
|
||||||
uploaded: remoteInfo.uploaded,
|
uploaded: remoteInfo.uploaded,
|
||||||
state: UploadState.Ready,
|
state: UploadState.Stopped,
|
||||||
err: "",
|
err: "",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -179,6 +184,10 @@ export class Updater {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.props.uploadingsInfo.uploadings = updatedUploads;
|
this.props.uploadingsInfo.uploadings = updatedUploads;
|
||||||
|
this.sortUploadings(
|
||||||
|
this.props.uploadingsInfo.orderBy,
|
||||||
|
this.props.uploadingsInfo.order
|
||||||
|
);
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue