[ARVADOS-WORKBENCH2] updated: 2.2.1-75-g3ef50531
Git user
git at public.arvados.org
Thu Sep 9 18:45:02 UTC 2021
Summary of changes:
cypress/integration/collection.spec.js | 68 +++++++++-
src/common/service-provider.ts | 2 +-
.../collection-panel-files.tsx | 145 +++++++++++++--------
.../collection-panel/collection-panel-action.ts | 1 -
4 files changed, 162 insertions(+), 54 deletions(-)
via 3ef505311c624abd61dd899283e061974abe8efb (commit)
via f571a8bf53280b2512ab1d83c33cd1e1bb50884c (commit)
via 87184cd1febea084a96e87d2b94028b6751d4418 (commit)
from 9836f40712e19996efa35a6d3ecd3c6921031b0c (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 3ef505311c624abd61dd899283e061974abe8efb
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Thu Sep 9 20:44:28 2021 +0200
17585: Added tests
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js
index c169de2f..bf2375d0 100644
--- a/cypress/integration/collection.spec.js
+++ b/cypress/integration/collection.spec.js
@@ -178,6 +178,7 @@ describe('Collection panel tests', function () {
}
// Check that the file listing show both read & write operations
cy.get('[data-cy=collection-files-panel]').within(() => {
+ cy.wait(1000);
cy.root().should('contain', fileName);
if (isWritable) {
cy.get('[data-cy=upload-button]')
@@ -279,7 +280,7 @@ describe('Collection panel tests', function () {
});
});
- it('renames a file to a different directory', function () {
+ it.skip('renames a file to a different directory', function () {
// Creates the collection using the admin token so we can set up
// a bogus manifest text without block signatures.
cy.createCollection(adminUser.token, {
@@ -336,6 +337,71 @@ describe('Collection panel tests', function () {
});
});
+ it('renames a file to a different directory', function () {
+ // Creates the collection using the admin token so we can set up
+ // a bogus manifest text without block signatures.
+ cy.createCollection(adminUser.token, {
+ name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+ owner_uuid: activeUser.user.uuid,
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+ })
+ .as('testCollection').then(function () {
+ cy.loginAs(activeUser);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
+
+ ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('bar').rightclick({force: true});
+ cy.get('[data-cy=context-menu]')
+ .contains('Rename')
+ .click();
+ cy.get('[data-cy=form-dialog]')
+ .should('contain', 'Rename')
+ .within(() => {
+ cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
+ });
+ cy.get('[data-cy=form-submit-btn]').click();
+ cy.get('[data-cy=collection-files-panel]')
+ .should('not.contain', 'bar')
+ .and('contain', subdir);
+ cy.wait(1000);
+ cy.get('[data-cy=collection-files-panel]').contains(subdir).click();
+ // Rename 'subdir/foo' to 'foo'
+ cy.wait(1000);
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('foo').rightclick();
+ cy.get('[data-cy=context-menu]')
+ .contains('Rename')
+ .click();
+ cy.get('[data-cy=form-dialog]')
+ .should('contain', 'Rename')
+ .within(() => {
+ cy.get('input')
+ .should('have.value', `${subdir}/foo`)
+ .type(`{selectall}{backspace}bar`);
+ });
+ cy.get('[data-cy=form-submit-btn]').click();
+
+ cy.wait(1000);
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('Home')
+ .click();
+
+ cy.wait(2000);
+ cy.get('[data-cy=collection-files-panel]')
+ .should('contain', subdir) // empty dir kept
+ .and('contain', 'bar');
+
+ cy.get('[data-cy=collection-files-panel]')
+ .contains(subdir).rightclick();
+ cy.get('[data-cy=context-menu]')
+ .contains('Remove')
+ .click();
+ cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+ });
+ });
+ });
+
it('tries to rename a file with illegal names', function () {
// Creates the collection using the admin token so we can set up
// a bogus manifest text without block signatures.
diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index 12dd554c..70c72107 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -7,9 +7,9 @@ import classNames from 'classnames';
import { connect } from 'react-redux';
import { FixedSizeList } from "react-window";
import AutoSizer from "react-virtualized-auto-sizer";
-import { CustomizeTableIcon } from 'components/icon/icon';
+import { CustomizeTableIcon, DownloadIcon } from 'components/icon/icon';
import { SearchInput } from 'components/search-input/search-input';
-import { ListItemIcon, StyleRulesCallback, Theme, WithStyles, withStyles, Tooltip, IconButton, Checkbox, CircularProgress } from '@material-ui/core';
+import { ListItemIcon, StyleRulesCallback, Theme, WithStyles, withStyles, Tooltip, IconButton, Checkbox, CircularProgress, Button } from '@material-ui/core';
import { FileTreeData } from '../file-tree/file-tree-data';
import { TreeItem, TreeItemStatus } from '../tree/tree';
import { RootState } from 'store/store';
@@ -40,7 +40,7 @@ export interface CollectionPanelFilesProps {
collectionPanel: any;
}
-type CssRules = "loader" | "wrapper" | "dataWrapper" | "row" | "rowEmpty" | "leftPanel" | "rightPanel" | "pathPanel" | "pathPanelItem" | "rowName" | "listItemIcon" | "rowActive" | "pathPanelMenu" | "rowSelection" | "leftPanelHidden" | "leftPanelVisible" | "searchWrapper" | "searchWrapperHidden";
+type CssRules = "pathPanelPathWrapper" | "uploadButton" | "uploadIcon" | "loader" | "wrapper" | "dataWrapper" | "row" | "rowEmpty" | "leftPanel" | "rightPanel" | "pathPanel" | "pathPanelItem" | "rowName" | "listItemIcon" | "rowActive" | "pathPanelMenu" | "rowSelection" | "leftPanelHidden" | "leftPanelVisible" | "searchWrapper" | "searchWrapperHidden";
const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
wrapper: {
@@ -85,7 +85,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
justifyContent: 'center'
},
searchWrapper: {
- width: '100%',
+ display: 'inline-block',
marginBottom: '1rem'
},
searchWrapperHidden: {
@@ -112,6 +112,9 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
backgroundColor: '#fff',
boxShadow: '0px 1px 3px 0px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 2px 1px -1px rgb(0 0 0 / 12%)',
},
+ pathPanelPathWrapper: {
+ display: 'inline-block',
+ },
leftPanel: {
flex: 0,
padding: '1rem',
@@ -151,6 +154,12 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
},
pathPanelItem: {
cursor: 'pointer',
+ },
+ uploadIcon: {
+ transform: 'rotate(180deg)'
+ },
+ uploadButton: {
+ float: 'right',
}
});
@@ -161,7 +170,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
collectionPanel: state.collectionPanel,
collectionPanelFiles: state.collectionPanelFiles,
}))((props: CollectionPanelFilesProps & WithStyles<CssRules> & { auth: AuthState }) => {
- const { classes, onItemMenuOpen, isWritable, dispatch, collectionPanelFiles, collectionPanel } = props;
+ const { classes, onItemMenuOpen, onUploadDataClick, isWritable, dispatch, collectionPanelFiles, collectionPanel } = props;
const { apiToken, config } = props.auth;
const webdavClient = new WebDAV();
@@ -197,16 +206,32 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
}
}, [props.currentItemUuid]);
- const fetchData = (rightKey, ignoreCache = false) => {
- const dataExists = !!pathData[rightKey];
- const runningRequest = pathPromise[rightKey];
+ const fetchData = (keys, ignoreCache = false) => {
+ const keyArray = Array.isArray(keys) ? keys : [keys];
- if ((!dataExists || ignoreCache) && !runningRequest) {
- setIsLoading(true);
+ Promise.all(keyArray
+ .map((key) => {
+ const dataExists = !!pathData[key];
+ const runningRequest = pathPromise[key];
- webdavClient.propfind(`c=${rightKey}`, webDAVRequestConfig)
- .then((request) => {
- if (request.responseXML != null) {
+ if ((!dataExists || ignoreCache) && (!runningRequest || ignoreCache)) {
+ if (!isLoading) {
+ setIsLoading(true);
+ }
+
+ pathPromise[key] = true;
+
+ return webdavClient.propfind(`c=${key}`, webDAVRequestConfig);
+ }
+
+ return Promise.resolve(null);
+ })
+ .filter((promise) => !!promise)
+ )
+ .then((requests) => {
+ const newState = requests.map((request, index) => {
+ if (request && request.responseXML != null) {
+ const key = keyArray[index];
const result: any = extractFilesData(request.responseXML);
const sortedResult = sortBy(result, (n) => n.name).sort((n1, n2) => {
if (n1.type === 'directory' && n2.type !== 'directory') {
@@ -217,19 +242,20 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
}
return 0;
});
- const newPathData = { ...pathData, [rightKey]: sortedResult };
- setPathData(newPathData);
+
+ return { [key]: sortedResult };
}
- })
- .finally(() => {
- setIsLoading(false);
- delete pathPromise[rightKey];
- });
-
- pathPromise[rightKey] = true;
- } else {
- setTimeout(() => setIsLoading(false), 0);
- }
+ return {};
+ }).reduce((prev, next) => {
+ return { ...next, ...prev };
+ }, {});
+
+ setPathData({ ...pathData, ...newState });
+ })
+ .finally(() => {
+ setIsLoading(false);
+ keyArray.forEach(key => delete pathPromise[key]);
+ });
};
React.useEffect(() => {
@@ -244,7 +270,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
const hash = (collectionPanel.item || {}).portableDataHash;
if (hash && rightClickUsed) {
- fetchData(rightKey, true);
+ fetchData([leftKey, rightKey], true);
}
}, [(collectionPanel.item || {}).portableDataHash]); // eslint-disable-line react-hooks/exhaustive-deps
@@ -258,11 +284,6 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
const handleRightClick = React.useCallback(
(event) => {
event.preventDefault();
-
- if (!rightClickUsed) {
- setRightClickUsed(true);
- }
-
let elem = event.target;
while (elem && elem.dataset && !elem.dataset.item) {
@@ -278,6 +299,10 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
if (id) {
onItemMenuOpen(event, item, isWritable);
+
+ if (!rightClickUsed) {
+ setRightClickUsed(true);
+ }
}
},
[onItemMenuOpen, isWritable, rightData] // eslint-disable-line react-hooks/exhaustive-deps
@@ -380,17 +405,19 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
return (
<div data-cy="collection-files-panel" onClick={handleClick} ref={parentRef}>
<div className={classes.pathPanel}>
- {
- path
- .map((p: string, index: number) => <span
- key={`${index}-${p}`}
- data-item="true"
- className={classes.pathPanelItem}
- data-breadcrumb-path={p}
- >
- {index === 0 ? 'Home' : p} /
- </span>)
- }
+ <div className={classes.pathPanelPathWrapper}>
+ {
+ path
+ .map((p: string, index: number) => <span
+ key={`${index}-${p}`}
+ data-item="true"
+ className={classes.pathPanelItem}
+ data-breadcrumb-path={p}
+ >
+ {index === 0 ? 'Home' : p} /
+ </span>)
+ }
+ </div>
<Tooltip className={classes.pathPanelMenu} title="More options" disableFocusListener>
<IconButton
data-cy='collection-files-panel-options-btn'
@@ -441,6 +468,19 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
<div className={classes.searchWrapper}>
<SearchInput label="Search" value={rightSearch} onSearch={setRightSearch} />
</div>
+ {
+ isWritable &&
+ <Button
+ className={classes.uploadButton}
+ data-cy='upload-button'
+ onClick={onUploadDataClick}
+ variant='contained'
+ color='primary'
+ size='small'>
+ <DownloadIcon className={classes.uploadIcon} />
+ Upload data
+ </Button>
+ }
<div className={classes.dataWrapper}>
{
rightData && !isLoading ?
@@ -473,7 +513,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
{getItemIcon(type, null)} <div className={classes.rowName}>
{name}
</div>
- <span className={classes.rowName} style={{marginLeft: 'auto', marginRight: '1rem'}}>
+ <span className={classes.rowName} style={{ marginLeft: 'auto', marginRight: '1rem' }}>
{formatFileSize(size)}
</span>
</div>
commit f571a8bf53280b2512ab1d83c33cd1e1bb50884c
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Tue Sep 7 21:36:51 2021 +0200
17585: Added data-cy attribute
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index e5b88f2f..12dd554c 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -235,6 +235,8 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
React.useEffect(() => {
if (rightKey) {
fetchData(rightKey);
+ setLeftSearch('');
+ setRightSearch('');
}
}, [rightKey]); // eslint-disable-line react-hooks/exhaustive-deps
@@ -376,7 +378,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
);
return (
- <div onClick={handleClick} ref={parentRef}>
+ <div data-cy="collection-files-panel" onClick={handleClick} ref={parentRef}>
<div className={classes.pathPanel}>
{
path
commit 87184cd1febea084a96e87d2b94028b6751d4418
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Sat Sep 4 23:12:46 2021 +0200
17585: Fixed eslint warnings
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>01~
diff --git a/src/common/service-provider.ts b/src/common/service-provider.ts
index 1362de9a..080916c5 100644
--- a/src/common/service-provider.ts
+++ b/src/common/service-provider.ts
@@ -26,7 +26,7 @@ class ServicesProvider {
public getServices() {
if (!this.services) {
- throw "Please check if services have been set in the index.ts before the app is initiated";
+ throw "Please check if services have been set in the index.ts before the app is initiated"; // eslint-disable-line no-throw-literal
}
return this.services;
}
diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index f5aa1244..e5b88f2f 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -236,7 +236,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
if (rightKey) {
fetchData(rightKey);
}
- }, [rightKey]);
+ }, [rightKey]); // eslint-disable-line react-hooks/exhaustive-deps
React.useEffect(() => {
const hash = (collectionPanel.item || {}).portableDataHash;
@@ -244,13 +244,14 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
if (hash && rightClickUsed) {
fetchData(rightKey, true);
}
- }, [(collectionPanel.item || {}).portableDataHash]);
+ }, [(collectionPanel.item || {}).portableDataHash]); // eslint-disable-line react-hooks/exhaustive-deps
React.useEffect(() => {
if (rightData) {
- setCollectionFiles(rightData, false)(dispatch);
+ const filtered = rightData.filter(({ name }) => name.indexOf(rightSearch) > -1);
+ setCollectionFiles(filtered, false)(dispatch);
}
- }, [rightData, dispatch]);
+ }, [rightData, dispatch, rightSearch]);
const handleRightClick = React.useCallback(
(event) => {
@@ -277,7 +278,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
onItemMenuOpen(event, item, isWritable);
}
},
- [onItemMenuOpen, isWritable, rightData]
+ [onItemMenuOpen, isWritable, rightData] // eslint-disable-line react-hooks/exhaustive-deps
);
React.useEffect(() => {
@@ -335,7 +336,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
props.onSelectionToggle(event, item);
}
},
- [path, setPath, collectionPanelFiles]
+ [path, setPath, collectionPanelFiles] // eslint-disable-line react-hooks/exhaustive-deps
);
const getItemIcon = React.useCallback(
@@ -371,7 +372,7 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
(ev, isWritable) => {
props.onOptionsMenuOpen(ev, isWritable);
},
- [props.onOptionsMenuOpen]
+ [props.onOptionsMenuOpen] // eslint-disable-line react-hooks/exhaustive-deps
);
return (
diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts
index 7401c64a..ca9542c5 100644
--- a/src/store/collection-panel/collection-panel-action.ts
+++ b/src/store/collection-panel/collection-panel-action.ts
@@ -4,7 +4,6 @@
import { Dispatch } from "redux";
import {
- loadCollectionFiles,
COLLECTION_PANEL_LOAD_FILES_THRESHOLD
} from "./collection-panel-files/collection-panel-files-actions";
import { CollectionResource } from 'models/collection';
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list