[ARVADOS-WORKBENCH2] updated: 2.3.1-4-g0b84326c
Git user
git at public.arvados.org
Mon Dec 6 17:23:53 UTC 2021
Summary of changes:
.licenseignore | 1 +
cypress/fixtures/files/5mb.bin | Bin 0 -> 5242880 bytes
cypress/integration/collection.spec.js | 79 +++++++++++++++++++++
cypress/integration/project.spec.js | 15 ++++
cypress/support/commands.js | 40 ++++++++++-
src/common/webdav.ts | 9 +++
src/components/chips/chips.tsx | 2 +-
.../collection-panel-files.tsx | 7 +-
src/components/file-upload/file-upload.tsx | 12 ++++
src/components/form-dialog/form-dialog.tsx | 14 +++-
.../collection-service/collection-service.test.ts | 56 ++++++++++++++-
.../collection-service/collection-service.ts | 16 ++++-
src/services/common-service/common-service.ts | 16 +++--
src/store/advanced-tab/advanced-tab.tsx | 3 +-
.../collections/collection-partial-copy-actions.ts | 2 +-
src/store/collections/collection-upload-actions.ts | 4 +-
.../collections/collection-version-actions.ts | 14 +++-
src/store/file-uploader/file-uploader-actions.ts | 1 +
src/store/file-uploader/file-uploader-reducer.ts | 15 ++++
.../dialog-collection-files-upload.tsx | 18 ++++-
.../file-uploader/file-uploader.tsx | 4 +-
.../main-content-bar/main-content-bar.tsx | 4 +-
.../run-process-panel/inputs/float-array-input.tsx | 2 +-
.../run-process-panel/inputs/int-array-input.tsx | 2 +-
.../inputs/string-array-input.tsx | 2 +-
25 files changed, 309 insertions(+), 29 deletions(-)
create mode 100644 cypress/fixtures/files/5mb.bin
via 0b84326ca02a4ce6b9d8bd5b9d92e633eb629682 (commit)
via bfeea246674f46989aee854d8e32b117143b6e6e (commit)
via 72e38dc2f3ff6f587e23d8512e93a041e7a71ce1 (commit)
via dffa004174b744e4fb42fb1d63d282f41ecebbc9 (commit)
from 9610e9d15c6c00b0684753d1f3ec90d550e700cf (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 0b84326ca02a4ce6b9d8bd5b9d92e633eb629682
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Wed Dec 1 17:25:35 2021 -0300
Merge branch '18257-chips-error-fix' into main. Closes #18257.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/components/chips/chips.tsx b/src/components/chips/chips.tsx
index eb68ed7a..c4724d1b 100644
--- a/src/components/chips/chips.tsx
+++ b/src/components/chips/chips.tsx
@@ -38,7 +38,7 @@ export const Chips = withStyles(styles)(
render() {
const { values, filler } = this.props;
return <Grid container spacing={8} className={this.props.classes.root}>
- {values.map(this.renderChip)}
+ {values && values.map(this.renderChip)}
{filler && <Grid item xs>{filler}</Grid>}
</Grid>;
}
diff --git a/src/views/run-process-panel/inputs/float-array-input.tsx b/src/views/run-process-panel/inputs/float-array-input.tsx
index 780cbc90..3f0a5334 100644
--- a/src/views/run-process-panel/inputs/float-array-input.tsx
+++ b/src/views/run-process-panel/inputs/float-array-input.tsx
@@ -30,7 +30,7 @@ const validationSelector = createSelector(
);
const required = (value: string[]) =>
- value.length > 0
+ value && value.length > 0
? undefined
: ERROR_MESSAGE;
diff --git a/src/views/run-process-panel/inputs/int-array-input.tsx b/src/views/run-process-panel/inputs/int-array-input.tsx
index 03cb07ea..8077f28a 100644
--- a/src/views/run-process-panel/inputs/int-array-input.tsx
+++ b/src/views/run-process-panel/inputs/int-array-input.tsx
@@ -30,7 +30,7 @@ const validationSelector = createSelector(
);
const required = (value: string[]) =>
- value.length > 0
+ value && value.length > 0
? undefined
: ERROR_MESSAGE;
diff --git a/src/views/run-process-panel/inputs/string-array-input.tsx b/src/views/run-process-panel/inputs/string-array-input.tsx
index cabbf749..8955009a 100644
--- a/src/views/run-process-panel/inputs/string-array-input.tsx
+++ b/src/views/run-process-panel/inputs/string-array-input.tsx
@@ -31,7 +31,7 @@ const validationSelector = createSelector(
);
const required = (value: string[] = []) =>
- value.length > 0
+ value && value.length > 0
? undefined
: ERROR_MESSAGE;
commit bfeea246674f46989aee854d8e32b117143b6e6e
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Wed Dec 1 17:36:55 2021 -0300
Merge branch '18484-collection-manifest-fix' into main. Closes #18484.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/services/collection-service/collection-service.test.ts b/src/services/collection-service/collection-service.test.ts
index 061a45ec..aa64d9db 100644
--- a/src/services/collection-service/collection-service.test.ts
+++ b/src/services/collection-service/collection-service.test.ts
@@ -26,6 +26,60 @@ describe('collection-service', () => {
collectionService.update = jest.fn();
});
+ describe('get', () => {
+ it('should make a list request with uuid filtering', async () => {
+ serverApi.get = jest.fn(() => Promise.resolve(
+ { data: { items: [{}] } }
+ ));
+ const uuid = 'zzzzz-4zz18-0123456789abcde'
+ await collectionService.get(uuid);
+ expect(serverApi.get).toHaveBeenCalledWith(
+ '/collections', {
+ params: {
+ filters: `[["uuid","=","zzzzz-4zz18-0123456789abcde"]]`,
+ include_old_versions: true,
+ },
+ }
+ );
+ });
+
+ it('should be able to request specific fields', async () => {
+ serverApi.get = jest.fn(() => Promise.resolve(
+ { data: { items: [{}] } }
+ ));
+ const uuid = 'zzzzz-4zz18-0123456789abcde'
+ await collectionService.get(uuid, undefined, ['manifestText']);
+ expect(serverApi.get).toHaveBeenCalledWith(
+ '/collections', {
+ params: {
+ filters: `[["uuid","=","zzzzz-4zz18-0123456789abcde"]]`,
+ include_old_versions: true,
+ select: `["manifest_text"]`
+ },
+ }
+ );
+ });
+ });
+
+ describe('update', () => {
+ it('should call put selecting updated fields + others', async () => {
+ serverApi.put = jest.fn(() => Promise.resolve({ data: {} }));
+ const data: Partial<CollectionResource> = {
+ name: 'foo',
+ };
+ const expected = {
+ collection: {
+ ...data,
+ preserve_version: true,
+ },
+ select: ['uuid', 'name', 'version', 'modified_at'],
+ }
+ collectionService = new CollectionService(serverApi, webdavClient, authService, actions);
+ await collectionService.update('uuid', data);
+ expect(serverApi.put).toHaveBeenCalledWith('/collections/uuid', expected);
+ });
+ });
+
describe('deleteFiles', () => {
it('should remove no files', async () => {
// given
@@ -67,4 +121,4 @@ describe('collection-service', () => {
expect(webdavClient.delete).toHaveBeenCalledWith("c=zzzzz-tpzed-5o5tg0l9a57gxxx/root/1");
});
});
-});
\ No newline at end of file
+});
diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 52fbf1a5..2410c0a2 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -11,6 +11,8 @@ import { extractFilesData } from "./collection-service-files-response";
import { TrashableResourceService } from "services/common-service/trashable-resource-service";
import { ApiActions } from "services/api/api-actions";
import { customEncodeURI } from "common/url";
+import { FilterBuilder } from "services/api/filter-builder";
+import { ListArguments } from "services/common-service/common-service";
export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
@@ -28,6 +30,18 @@ export class CollectionService extends TrashableResourceService<CollectionResour
]);
}
+ async get(uuid: string, showErrors?: boolean, select?: string[]) {
+ super.validateUuid(uuid);
+ // We use a filtered list request to avoid getting the manifest text
+ const filters = new FilterBuilder().addEqual('uuid', uuid).getFilters();
+ const listArgs: ListArguments = {filters, includeOldVersions: true};
+ if (select) {
+ listArgs.select = select;
+ }
+ const lst = await super.list(listArgs, showErrors);
+ return lst.items[0];
+ }
+
create(data?: Partial<CollectionResource>) {
return super.create({ ...data, preserveVersion: true });
}
diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts
index 82777342..f66fad74 100644
--- a/src/services/common-service/common-service.ts
+++ b/src/services/common-service/common-service.ts
@@ -68,7 +68,7 @@ export class CommonService<T> {
}
}
- private validateUuid(uuid: string) {
+ protected validateUuid(uuid: string) {
if (uuid === "") {
throw new Error('UUID cannot be empty string');
}
@@ -124,18 +124,21 @@ export class CommonService<T> {
);
}
- list(args: ListArguments = {}): Promise<ListResults<T>> {
- const { filters, order, ...other } = args;
+ list(args: ListArguments = {}, showErrors?: boolean): Promise<ListResults<T>> {
+ const { filters, select, ...other } = args;
const params = {
...CommonService.mapKeys(snakeCase)(other),
filters: filters ? `[${filters}]` : undefined,
- order: order ? order : undefined
+ select: select
+ ? `[${select.map(snakeCase).map(s => `"${s}"`).join(', ')}]`
+ : undefined
};
if (QueryString.stringify(params).length <= 1500) {
return CommonService.defaultResponse(
this.serverApi.get(`/${this.resourceType}`, { params }),
- this.actions
+ this.actions,
+ showErrors
);
} else {
// Using the POST special case to avoid URI length 414 errors.
@@ -152,7 +155,8 @@ export class CommonService<T> {
_method: 'GET'
}
}),
- this.actions
+ this.actions,
+ showErrors
);
}
}
diff --git a/src/store/advanced-tab/advanced-tab.tsx b/src/store/advanced-tab/advanced-tab.tsx
index 0f8bf3cb..25d90195 100644
--- a/src/store/advanced-tab/advanced-tab.tsx
+++ b/src/store/advanced-tab/advanced-tab.tsx
@@ -411,7 +411,7 @@ const containerRequestApiResponse = (apiResponse: ContainerRequestResource) => {
const collectionApiResponse = (apiResponse: CollectionResource) => {
const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, name, description, properties, portableDataHash, replicationDesired,
- replicationConfirmedAt, replicationConfirmed, manifestText, deleteAt, trashAt, isTrashed, storageClassesDesired,
+ replicationConfirmedAt, replicationConfirmed, deleteAt, trashAt, isTrashed, storageClassesDesired,
storageClassesConfirmed, storageClassesConfirmedAt, currentVersionUuid, version, preserveVersion, fileCount, fileSizeTotal } = apiResponse;
const response = `
"uuid": "${uuid}",
@@ -424,7 +424,6 @@ const collectionApiResponse = (apiResponse: CollectionResource) => {
"replication_desired": ${stringify(replicationDesired)},
"replication_confirmed_at": ${stringify(replicationConfirmedAt)},
"replication_confirmed": ${stringify(replicationConfirmed)},
-"manifest_text": ${stringify(manifestText)},
"name": ${stringify(name)},
"description": ${stringify(description)},
"properties": ${stringifyObject(properties)},
diff --git a/src/store/collections/collection-partial-copy-actions.ts b/src/store/collections/collection-partial-copy-actions.ts
index 49900f2c..d898c500 100644
--- a/src/store/collections/collection-partial-copy-actions.ts
+++ b/src/store/collections/collection-partial-copy-actions.ts
@@ -114,7 +114,7 @@ export const copyCollectionPartialToSelectedCollection = ({ collectionUuid }: Co
const currentCollection = state.collectionPanel.item;
if (currentCollection && !currentCollection.manifestText) {
- const fetchedCurrentCollection = await services.collectionService.get(currentCollection.uuid);
+ const fetchedCurrentCollection = await services.collectionService.get(currentCollection.uuid, undefined, ['manifestText']);
currentCollection.manifestText = fetchedCurrentCollection.manifestText;
currentCollection.unsignedManifestText = fetchedCurrentCollection.unsignedManifestText;
}
diff --git a/src/store/collections/collection-version-actions.ts b/src/store/collections/collection-version-actions.ts
index c0a58432..7d2511ed 100644
--- a/src/store/collections/collection-version-actions.ts
+++ b/src/store/collections/collection-version-actions.ts
@@ -9,6 +9,8 @@ import { snackbarActions, SnackbarKind } from "../snackbar/snackbar-actions";
import { resourcesActions } from "../resources/resources-actions";
import { navigateTo } from "../navigation/navigation-action";
import { dialogActions } from "../dialog/dialog-actions";
+import { getResource } from "store/resources/resources";
+import { CollectionResource } from "models/collection";
export const COLLECTION_RESTORE_VERSION_DIALOG = 'collectionRestoreVersionDialog';
@@ -28,9 +30,15 @@ export const openRestoreCollectionVersionDialog = (uuid: string) =>
export const restoreVersion = (resourceUuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
try {
- // Request que entire record because stored old versions usually
- // don't include the manifest_text field.
- const oldVersion = await services.collectionService.get(resourceUuid);
+ // Request the manifest text because stored old versions usually
+ // don't include them.
+ let oldVersion = getResource<CollectionResource>(resourceUuid)(getState().resources);
+ if (!oldVersion) {
+ oldVersion = await services.collectionService.get(resourceUuid);
+ }
+ const oldVersionManifest = await services.collectionService.get(resourceUuid, undefined, ['manifestText']);
+ oldVersion.manifestText = oldVersionManifest.manifestText;
+
const { uuid, version, ...rest} = oldVersion;
const headVersion = await services.collectionService.update(
oldVersion.currentVersionUuid,
commit 72e38dc2f3ff6f587e23d8512e93a041e7a71ce1
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Tue Nov 30 08:46:51 2021 +0100
Merge branch '18482-Info-Button-for-projects-is-broken' into main
closes #18482
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/cypress/integration/project.spec.js b/cypress/integration/project.spec.js
index af2d93e3..1c175952 100644
--- a/cypress/integration/project.spec.js
+++ b/cypress/integration/project.spec.js
@@ -179,4 +179,19 @@ describe('Project tests', function() {
cy.get('[data-cy=not-found-page]').should('not.exist');
});
});
+
+ it('shows details panel when clicking on the info icon', () => {
+ cy.createGroup(activeUser.token, {
+ name: `Test root project ${Math.floor(Math.random() * 999999)}`,
+ group_class: 'project',
+ }).as('testRootProject').then(function(testRootProject) {
+ cy.loginAs(activeUser);
+
+ cy.get('[data-cy=side-panel-tree]').contains(testRootProject.name).click();
+
+ cy.get('[data-cy=additional-info-icon]').click();
+
+ cy.contains(testRootProject.uuid).should('exist');
+ });
+ });
});
\ No newline at end of file
diff --git a/src/views-components/main-content-bar/main-content-bar.tsx b/src/views-components/main-content-bar/main-content-bar.tsx
index 10ae1790..480150cb 100644
--- a/src/views-components/main-content-bar/main-content-bar.tsx
+++ b/src/views-components/main-content-bar/main-content-bar.tsx
@@ -60,7 +60,7 @@ export const MainContentBar =
buttonVisible: isButtonVisible(state),
projectUuid: state.detailsPanel.resourceUuid,
}), (dispatch) => ({
- onDetailsPanelToggle: toggleDetailsPanel,
+ onDetailsPanelToggle: () => dispatch<any>(toggleDetailsPanel()),
onRefreshButtonClick: (id) => {
dispatch<any>(loadSidePanelTreeProjects(id));
dispatch<any>(reloadProjectMatchingUuid([id]));
@@ -80,7 +80,7 @@ export const MainContentBar =
</Grid>
<Grid item>
{props.buttonVisible && <Tooltip title="Additional Info">
- <IconButton color="inherit" className={props.classes.infoTooltip} onClick={props.onDetailsPanelToggle}>
+ <IconButton data-cy="additional-info-icon" color="inherit" className={props.classes.infoTooltip} onClick={props.onDetailsPanelToggle}>
<DetailsIcon />
</IconButton>
</Tooltip>}
commit dffa004174b744e4fb42fb1d63d282f41ecebbc9
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Fri Nov 26 09:05:56 2021 +0100
Merge branch '18169-cancel-button-not-working' into main
closes #18169
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/.licenseignore b/.licenseignore
index 853135fc..9b943a1f 100644
--- a/.licenseignore
+++ b/.licenseignore
@@ -14,3 +14,4 @@ public/*
.npmrc
src/lib/cwl-svg/*
tools/arvados_config.yml
+cypress/fixtures/files/5mb.bin
diff --git a/cypress/fixtures/files/5mb.bin b/cypress/fixtures/files/5mb.bin
new file mode 100644
index 00000000..d52f252e
Binary files /dev/null and b/cypress/fixtures/files/5mb.bin differ
diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js
index 3e06d7e5..eb06a06c 100644
--- a/cypress/integration/collection.spec.js
+++ b/cypress/integration/collection.spec.js
@@ -793,4 +793,83 @@ describe('Collection panel tests', function () {
.contains(adminUser.user.uuid);
});
});
+
+ describe('file upload', () => {
+ beforeEach(() => {
+ 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('testCollection1');
+ });
+
+ it('allows to cancel running upload', () => {
+ cy.getAll('@testCollection1')
+ .then(function([testCollection1]) {
+ cy.loginAs(activeUser);
+
+ cy.goToPath(`/collections/${testCollection1.uuid}`);
+
+ cy.get('[data-cy=upload-button]').click();
+
+ cy.fixture('files/5mb.bin', 'base64').then(content => {
+ cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
+ cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
+
+ cy.get('[data-cy=form-submit-btn]').click();
+
+ cy.get('button').contains('Cancel').click();
+
+ cy.get('[data-cy=form-submit-btn]').should('not.exist');
+ });
+ });
+ });
+
+ it('allows to cancel single file from the running upload', () => {
+ cy.getAll('@testCollection1')
+ .then(function([testCollection1]) {
+ cy.loginAs(activeUser);
+
+ cy.goToPath(`/collections/${testCollection1.uuid}`);
+
+ cy.get('[data-cy=upload-button]').click();
+
+ cy.fixture('files/5mb.bin', 'base64').then(content => {
+ cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
+ cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
+
+ cy.get('[data-cy=form-submit-btn]').click();
+
+ cy.get('button[aria-label=Remove]').eq(1).click();
+
+ cy.get('[data-cy=form-submit-btn]').should('not.exist');
+
+ cy.get('[data-cy=collection-files-panel]').contains('5mb_a.bin').should('exist');
+ });
+ });
+ });
+
+ it('allows to cancel all files from the running upload', () => {
+ cy.getAll('@testCollection1')
+ .then(function([testCollection1]) {
+ cy.loginAs(activeUser);
+
+ cy.goToPath(`/collections/${testCollection1.uuid}`);
+
+ cy.get('[data-cy=upload-button]').click();
+
+ cy.fixture('files/5mb.bin', 'base64').then(content => {
+ cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
+ cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
+
+ cy.get('[data-cy=form-submit-btn]').click();
+
+ cy.get('button[aria-label=Remove]').click({ multiple: true });
+
+ cy.get('[data-cy=form-submit-btn]').should('not.exist');
+ });
+ });
+ });
+ });
})
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 069ed96d..07290e55 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -280,4 +280,42 @@ Cypress.Commands.add('createProject', ({
cy.addToFavorites(user.token, user.user.uuid, project.uuid);
}
});
-});
\ No newline at end of file
+});
+
+Cypress.Commands.add(
+ 'upload',
+ {
+ prevSubject: 'element',
+ },
+ (subject, file, fileName) => {
+ cy.window().then(window => {
+ const blob = b64toBlob(file, '', 512);
+ const testFile = new window.File([blob], fileName);
+
+ cy.wrap(subject).trigger('drop', {
+ dataTransfer: { files: [testFile] },
+ });
+ })
+ }
+)
+
+function b64toBlob(b64Data, contentType = '', sliceSize = 512) {
+ const byteCharacters = atob(b64Data)
+ const byteArrays = []
+
+ for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
+ const slice = byteCharacters.slice(offset, offset + sliceSize);
+
+ const byteNumbers = new Array(slice.length);
+ for (let i = 0; i < slice.length; i++) {
+ byteNumbers[i] = slice.charCodeAt(i);
+ }
+
+ const byteArray = new Uint8Array(byteNumbers);
+
+ byteArrays.push(byteArray);
+ }
+
+ const blob = new Blob(byteArrays, { type: contentType });
+ return blob
+}
\ No newline at end of file
diff --git a/src/common/webdav.ts b/src/common/webdav.ts
index 758a5e18..93ec21cb 100644
--- a/src/common/webdav.ts
+++ b/src/common/webdav.ts
@@ -84,6 +84,15 @@ export class WebDAV {
.keys(headers)
.forEach(key => r.setRequestHeader(key, headers[key]));
+ if (!(window as any).cancelTokens) {
+ Object.assign(window, { cancelTokens: {} });
+ }
+
+ (window as any).cancelTokens[config.url] = () => {
+ resolve(r);
+ r.abort();
+ }
+
if (config.onUploadProgress) {
r.upload.addEventListener('progress', config.onUploadProgress);
}
diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index 97cbc8ce..a7001a61 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -517,7 +517,12 @@ export const CollectionPanelFiles = withStyles(styles)(connect((state: RootState
<Button
className={classes.uploadButton}
data-cy='upload-button'
- onClick={onUploadDataClick}
+ onClick={() => {
+ if (!collectionAutofetchEnabled) {
+ setCollectionAutofetchEnabled(true);
+ }
+ onUploadDataClick();
+ }}
variant='contained'
color='primary'
size='small'>
diff --git a/src/components/file-upload/file-upload.tsx b/src/components/file-upload/file-upload.tsx
index 617529cd..54d5b5db 100644
--- a/src/components/file-upload/file-upload.tsx
+++ b/src/components/file-upload/file-upload.tsx
@@ -123,6 +123,17 @@ export const FileUpload = withStyles(styles)(
if (!disabled) {
onDelete(file);
}
+
+ let interval = setInterval(() => {
+ const key = Object.keys((window as any).cancelTokens).find(key => key.indexOf(file.file.name) > -1);
+
+ if (key) {
+ clearInterval(interval);
+ (window as any).cancelTokens[key]();
+ delete (window as any).cancelTokens[key];
+ }
+ }, 100);
+
}
render() {
const { classes, onDrop, disabled, files } = this.props;
@@ -140,6 +151,7 @@ export const FileUpload = withStyles(styles)(
inputs[0].focus();
}
}}
+ data-cy="drag-and-drop"
disabled={disabled}
inputProps={{
onFocus: () => {
diff --git a/src/components/form-dialog/form-dialog.tsx b/src/components/form-dialog/form-dialog.tsx
index 19145cea..0fc799de 100644
--- a/src/components/form-dialog/form-dialog.tsx
+++ b/src/components/form-dialog/form-dialog.tsx
@@ -42,7 +42,9 @@ interface DialogProjectDataProps {
dialogTitle: string;
formFields: React.ComponentType<InjectedFormProps<any> & WithDialogProps<any>>;
submitLabel?: string;
+ cancelCallback?: Function;
enableWhenPristine?: boolean;
+ doNotDisableCancel?: boolean;
}
type DialogProjectProps = DialogProjectDataProps & WithDialogProps<{}> & InjectedFormProps<any> & WithStyles<CssRules>;
@@ -65,10 +67,18 @@ export const FormDialog = withStyles(styles)((props: DialogProjectProps) =>
<DialogActions className={props.classes.dialogActions}>
<Button
data-cy='form-cancel-btn'
- onClick={props.closeDialog}
+ onClick={() => {
+ props.closeDialog();
+
+ if (props.cancelCallback) {
+ props.cancelCallback();
+ props.reset();
+ props.initialize({});
+ }
+ }}
className={props.classes.button}
color="primary"
- disabled={props.submitting}>
+ disabled={props.doNotDisableCancel ? false : props.submitting}>
{props.cancelLabel || 'Cancel'}
</Button>
<Button
diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 92437806..52fbf1a5 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -107,7 +107,7 @@ export class CollectionService extends TrashableResourceService<CollectionResour
},
onUploadProgress: (e: ProgressEvent) => {
onProgress(fileId, e.loaded, e.total, Date.now());
- }
+ },
};
return this.webdavClient.upload(fileURL, [file], requestConfig);
}
diff --git a/src/store/collections/collection-upload-actions.ts b/src/store/collections/collection-upload-actions.ts
index 8f85ea18..0ca681b9 100644
--- a/src/store/collections/collection-upload-actions.ts
+++ b/src/store/collections/collection-upload-actions.ts
@@ -14,12 +14,14 @@ import { progressIndicatorActions } from "store/progress-indicator/progress-indi
import { collectionPanelFilesAction } from 'store/collection-panel/collection-panel-files/collection-panel-files-actions';
import { createTree } from 'models/tree';
import { loadCollectionPanel } from '../collection-panel/collection-panel-action';
+import * as WorkbenchActions from 'store/workbench/workbench-actions';
export const uploadCollectionFiles = (collectionUuid: string) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
dispatch(fileUploaderActions.START_UPLOAD());
const files = getState().fileUploader.map(file => file.file);
await services.collectionService.uploadFiles(collectionUuid, files, handleUploadProgress(dispatch));
+ dispatch(WorkbenchActions.loadCollection(collectionUuid));
dispatch(fileUploaderActions.CLEAR_UPLOAD());
};
diff --git a/src/store/file-uploader/file-uploader-actions.ts b/src/store/file-uploader/file-uploader-actions.ts
index 8436c485..a397bbd8 100644
--- a/src/store/file-uploader/file-uploader-actions.ts
+++ b/src/store/file-uploader/file-uploader-actions.ts
@@ -24,6 +24,7 @@ export const fileUploaderActions = unionize({
SET_UPLOAD_PROGRESS: ofType<{ fileId: number, loaded: number, total: number, currentTime: number }>(),
START_UPLOAD: ofType(),
DELETE_UPLOAD_FILE: ofType<UploadFile>(),
+ CANCEL_FILES_UPLOAD: ofType(),
});
export type FileUploaderAction = UnionOf<typeof fileUploaderActions>;
diff --git a/src/store/file-uploader/file-uploader-reducer.ts b/src/store/file-uploader/file-uploader-reducer.ts
index c1f9c681..4218fbee 100644
--- a/src/store/file-uploader/file-uploader-reducer.ts
+++ b/src/store/file-uploader/file-uploader-reducer.ts
@@ -43,6 +43,21 @@ export const fileUploaderReducer = (state: UploaderState = initialState, action:
return updatedState;
},
+ CANCEL_FILES_UPLOAD: () => {
+ state.forEach((file) => {
+ let interval = setInterval(() => {
+ const key = Object.keys((window as any).cancelTokens).find(key => key.indexOf(file.file.name) > -1);
+
+ if (key) {
+ clearInterval(interval);
+ (window as any).cancelTokens[key]();
+ delete (window as any).cancelTokens[key];
+ }
+ }, 100);
+ });
+
+ return [];
+ },
START_UPLOAD: () => {
const startTime = Date.now();
return state.map(f => ({ ...f, startTime, prevTime: startTime }));
diff --git a/src/views-components/dialog-upload/dialog-collection-files-upload.tsx b/src/views-components/dialog-upload/dialog-collection-files-upload.tsx
index 2f662bfa..f65bdabf 100644
--- a/src/views-components/dialog-upload/dialog-collection-files-upload.tsx
+++ b/src/views-components/dialog-upload/dialog-collection-files-upload.tsx
@@ -10,16 +10,30 @@ import { FormDialog } from 'components/form-dialog/form-dialog';
import { require } from 'validators/require';
import { FileUploaderField } from 'views-components/file-uploader/file-uploader';
import { WarningCollection } from 'components/warning-collection/warning-collection';
+import { fileUploaderActions } from 'store/file-uploader/file-uploader-actions';
+import { progressIndicatorActions } from 'store/progress-indicator/progress-indicator-actions';
type DialogCollectionFilesUploadProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
-export const DialogCollectionFilesUpload = (props: DialogCollectionFilesUploadProps) =>
- <FormDialog
+export const DialogCollectionFilesUpload = (props: DialogCollectionFilesUploadProps) => {
+
+ return <FormDialog
dialogTitle='Upload data'
formFields={UploadCollectionFilesFields}
submitLabel='Upload data'
+ doNotDisableCancel
+ cancelCallback={() => {
+ const { submitting, dispatch } = (props as any);
+
+ if (submitting) {
+ dispatch(progressIndicatorActions.STOP_WORKING('uploadCollectionFilesDialog'));
+ dispatch(fileUploaderActions.CANCEL_FILES_UPLOAD());
+ dispatch(fileUploaderActions.CLEAR_UPLOAD());
+ }
+ }}
{...props}
/>;
+}
const UploadCollectionFilesFields = () => <>
<Field
diff --git a/src/views-components/file-uploader/file-uploader.tsx b/src/views-components/file-uploader/file-uploader.tsx
index 82e400f7..cde286c4 100644
--- a/src/views-components/file-uploader/file-uploader.tsx
+++ b/src/views-components/file-uploader/file-uploader.tsx
@@ -30,7 +30,7 @@ const mapDispatchToProps = (dispatch: Dispatch, { onDrop }: FileUploaderProps):
onDrop(files);
}
},
- onDelete: file => dispatch(fileUploaderActions.DELETE_UPLOAD_FILE(file)),
+ onDelete: file => dispatch(fileUploaderActions.DELETE_UPLOAD_FILE(file))
});
export const FileUploader = connect(mapStateToProps, mapDispatchToProps)(FileUpload);
@@ -38,5 +38,5 @@ export const FileUploader = connect(mapStateToProps, mapDispatchToProps)(FileUpl
export const FileUploaderField = (props: WrappedFieldProps & { label?: string }) =>
<div>
<Typography variant='caption'>{props.label}</Typography>
- <FileUploader disabled={props.meta.submitting} onDrop={props.input.onChange} />
+ <FileUploader disabled={false} onDrop={props.input.onChange} />
</div>;
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list