[arvados-workbench2] updated: 2.6.0-10-g7ff688a4
git repository hosting
git at public.arvados.org
Wed Apr 26 21:21:55 UTC 2023
Summary of changes:
src/components/data-explorer/data-explorer.tsx | 1 -
src/components/data-table/data-table.tsx | 57 +++++++++++++++-----------
src/validators/arrays-are-congruent.tsx | 17 ++++++++
3 files changed, 51 insertions(+), 24 deletions(-)
create mode 100644 src/validators/arrays-are-congruent.tsx
via 7ff688a46feb12ff62afcc35a287048f3e49fb27 (commit)
via d230941e87d4619683e4f3f7b44f19dab5017bd0 (commit)
via 4b6a2f564bb933d5411e75f664e859d6be891e61 (commit)
from 7f8c4a43bdd1eb200245ead83ba4aee20c0e1776 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 7ff688a46feb12ff62afcc35a287048f3e49fb27
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Wed Apr 26 17:21:49 2023 -0400
15768: selections persist through sort/refresh, not filter Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index 68792e01..57753c05 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -13,8 +13,8 @@ import { countNodes, getTreeDirty } from 'models/tree';
import { IconType, PendingIcon } from 'components/icon/icon';
import { SvgIconProps } from '@material-ui/core/SvgIcon';
import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward';
-import { Checkbox } from '@material-ui/core';
import { createTree } from 'models/tree';
+import arraysAreCongruent from 'validators/arrays-are-congruent';
export type DataColumns<I, R> = Array<DataColumn<I, R>>;
@@ -97,12 +97,22 @@ export const DataTable = withStyles(styles)(
class Component<T> extends React.Component<DataTableProps<T>> {
state: DataTableState = {};
+ componentDidMount(): void {
+ this.initializeCheckedList(this.props.items);
+ }
+
componentDidUpdate(prevProps: Readonly<DataTableProps<T>>) {
- if (prevProps.items !== this.props.items) {
+ console.log(prevProps.items, this.props.items, this.state);
+ console.log(this.props.currentRoute);
+ if (!arraysAreCongruent(prevProps.items, this.props.items)) {
this.initializeCheckedList(this.props.items);
}
}
+ componentWillUnmount(): void {
+ console.log('UNMOUNT');
+ }
+
checkBoxColumn: DataColumn<any, any> = {
name: 'checkBoxColumn',
selected: true,
diff --git a/src/validators/arrays-are-congruent.tsx b/src/validators/arrays-are-congruent.tsx
new file mode 100644
index 00000000..d945600f
--- /dev/null
+++ b/src/validators/arrays-are-congruent.tsx
@@ -0,0 +1,17 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export default function arraysAreCongruent<T>(arr1: T[], arr2: T[]): boolean {
+ if (!arr1.length || !arr2.length) return false;
+ if (arr1.length !== arr2.length) return false;
+
+ const sortedArr1 = [...arr1].sort();
+ const sortedArr2 = [...arr2].sort();
+
+ for (let i = 0; i < sortedArr1.length; i++) {
+ if (sortedArr1[i] !== sortedArr2[i]) return false;
+ }
+
+ return true;
+}
commit d230941e87d4619683e4f3f7b44f19dab5017bd0
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Wed Apr 26 14:48:17 2023 -0400
15768: cleanup before sort/refresh fix Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx
index 373ff2e0..ea95648e 100644
--- a/src/components/data-explorer/data-explorer.tsx
+++ b/src/components/data-explorer/data-explorer.tsx
@@ -238,7 +238,6 @@ export const DataExplorer = withStyles(styles)(
defaultViewMessages={defaultViewMessages}
currentItemUuid={currentItemUuid}
currentRoute={paperKey}
- // checkedList={{}}
/>
</Grid>
<Grid item xs>
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index cde4ffb9..68792e01 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -62,7 +62,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
padding: theme.spacing.unit,
},
checkBoxCell: {
- // border: '1px dotted green',
padding: '0',
cursor: 'pointer',
},
@@ -90,23 +89,17 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
},
});
-type DataTableState = {
- // checkedList: Record<string, boolean>;
-};
+type DataTableState = Record<string, boolean>;
-type DataTableProps<T> = DataTableDataProps<T> & WithStyles<CssRules> & DataTableState;
+type DataTableProps<T> = DataTableDataProps<T> & WithStyles<CssRules>;
export const DataTable = withStyles(styles)(
class Component<T> extends React.Component<DataTableProps<T>> {
- state: DataTableState = {
- // checkedList: {},
- };
+ state: DataTableState = {};
componentDidUpdate(prevProps: Readonly<DataTableProps<T>>) {
if (prevProps.items !== this.props.items) {
- // console.log('BEFORE INIT', this.state);
this.initializeCheckedList(this.props.items);
- // console.log('AFTER INIT', this.state);
}
}
@@ -127,8 +120,8 @@ export const DataTable = withStyles(styles)(
),
};
- initializeCheckedList = async (uuids: any[]) => {
- let checkedList = this.state;
+ initializeCheckedList = (uuids: any[]): void => {
+ const checkedList = this.state;
uuids.forEach((uuid) => {
if (!checkedList.hasOwnProperty[uuid]) {
checkedList[uuid] = false;
@@ -136,13 +129,14 @@ export const DataTable = withStyles(styles)(
});
};
- handleCheck = (uuid: string) => {
+ handleCheck = (uuid: string): void => {
const newCheckedList = { ...this.state };
newCheckedList[uuid] = !this.state[uuid];
this.setState(newCheckedList);
+ console.log(newCheckedList);
};
- handleSelectAll = () => {
+ handleSelectAll = (): void => {
const newCheckedList = { ...this.state };
for (const key in newCheckedList) {
newCheckedList[key] = true;
@@ -150,7 +144,7 @@ export const DataTable = withStyles(styles)(
this.setState(newCheckedList);
};
- handleDeselectAll = () => {
+ handleDeselectAll = (): void => {
const newCheckedList = { ...this.state };
for (const key in newCheckedList) {
newCheckedList[key] = false;
@@ -158,7 +152,7 @@ export const DataTable = withStyles(styles)(
this.setState(newCheckedList);
};
- handleInvertSelect = () => {
+ handleInvertSelect = (): void => {
const newCheckedList = { ...this.state };
for (const key in newCheckedList) {
newCheckedList[key] = !this.state[key];
@@ -170,7 +164,6 @@ export const DataTable = withStyles(styles)(
const { items, classes, working, columns } = this.props;
if (columns[0].name === this.checkBoxColumn.name) columns.shift();
columns.unshift(this.checkBoxColumn);
- console.log('ONCHECK', this.state);
return (
<div className={classes.root}>
commit 4b6a2f564bb933d5411e75f664e859d6be891e61
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Wed Apr 26 12:23:07 2023 -0400
15768: fixed doubleclick bug Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index bd81b89a..cde4ffb9 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -104,9 +104,9 @@ export const DataTable = withStyles(styles)(
componentDidUpdate(prevProps: Readonly<DataTableProps<T>>) {
if (prevProps.items !== this.props.items) {
- console.log('BEFORE INIT', this.state);
+ // console.log('BEFORE INIT', this.state);
this.initializeCheckedList(this.props.items);
- console.log('AFTER INIT', this.state);
+ // console.log('AFTER INIT', this.state);
}
}
@@ -115,7 +115,16 @@ export const DataTable = withStyles(styles)(
selected: true,
configurable: false,
filters: createTree(),
- render: (uuid) => <input type='checkbox' name={uuid} color='primary' checked={this.state[uuid] ?? false} onChange={() => this.handleCheck(uuid)}></input>,
+ render: (uuid) => (
+ <input
+ type='checkbox'
+ name={uuid}
+ color='primary'
+ checked={this.state[uuid] ?? false}
+ onChange={() => this.handleCheck(uuid)}
+ onDoubleClick={(ev) => ev.stopPropagation()}
+ ></input>
+ ),
};
initializeCheckedList = async (uuids: any[]) => {
@@ -128,9 +137,8 @@ export const DataTable = withStyles(styles)(
};
handleCheck = (uuid: string) => {
- const checkedList = this.state;
- const newCheckedList = { ...checkedList };
- newCheckedList[uuid] = !checkedList[uuid];
+ const newCheckedList = { ...this.state };
+ newCheckedList[uuid] = !this.state[uuid];
this.setState(newCheckedList);
};
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list