[ARVADOS-WORKBENCH2] created: 2.1.0-34-g3af60f74
Git user
git at public.arvados.org
Thu Oct 22 23:24:53 UTC 2020
at 3af60f74e1bb43c779d660bda187d780b677188e (commit)
commit 3af60f74e1bb43c779d660bda187d780b677188e
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Thu Oct 22 20:22:56 2020 -0300
15685: Avoids the webdav service to report server error responses as success.
This makes the rename file dialog code to report errors correctly.
Probably will fix other file managing issues.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/common/webdav.ts b/src/common/webdav.ts
index 17032768..b51cff30 100644
--- a/src/common/webdav.ts
+++ b/src/common/webdav.ts
@@ -85,14 +85,16 @@ export class WebDAV {
r.upload.addEventListener('progress', config.onUploadProgress);
}
+ // This event gets triggered on *any* server response
r.addEventListener('load', () => {
- if (r.status === 404) {
+ if (r.status >= 400) {
return reject(r);
} else {
return resolve(r);
}
});
+ // This event gets triggered on network errors
r.addEventListener('error', () => {
return reject(r);
});
diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts
index 704e2999..19f5a7ee 100644
--- a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts
+++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts
@@ -146,7 +146,7 @@ export const renameFile = (newName: string) =>
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 }));
} catch (e) {
const errors: FormErrors<RenameFileDialogData, string> = {
- name: 'Could not rename the file'
+ name: `Could not rename the file: ${e.responseText}`
};
dispatch(stopSubmit(RENAME_FILE_DIALOG, errors));
}
diff --git a/src/views-components/rename-file-dialog/rename-file-dialog.tsx b/src/views-components/rename-file-dialog/rename-file-dialog.tsx
index 1a806511..d05c110b 100644
--- a/src/views-components/rename-file-dialog/rename-file-dialog.tsx
+++ b/src/views-components/rename-file-dialog/rename-file-dialog.tsx
@@ -37,5 +37,5 @@ const RenameDialogFormFields = (props: WithDialogProps<RenameFileDialogData>) =>
component={TextField}
autoFocus={true}
/>
- <WarningCollection text="Renaming a file will change content address." />
+ <WarningCollection text="Renaming a file will change the collection's content address." />
</>;
commit b5f5db0e8b85930e2240824cd2fd24e88ceb92c6
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Thu Oct 22 20:20:01 2020 -0300
15685: Adds integration tests for file renaming.
Exposes the bug of not displaying an error when trying to rename a file
to an illegal name (like empty string).
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js
index c14101d8..21b52686 100644
--- a/cypress/integration/collection-panel.spec.js
+++ b/cypress/integration/collection-panel.spec.js
@@ -21,12 +21,12 @@ describe('Collection panel tests', function() {
activeUser = this.activeUser;
}
);
- })
+ });
beforeEach(function() {
- cy.clearCookies()
- cy.clearLocalStorage()
- })
+ cy.clearCookies();
+ cy.clearLocalStorage();
+ });
it('shows collection by URL', function() {
cy.loginAs(activeUser);
@@ -117,4 +117,60 @@ describe('Collection panel tests', function() {
})
})
})
+
+ it('renames a file', 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() * Math.floor(999999))}`,
+ owner_uuid: activeUser.user.uuid,
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+ .as('testCollection').then(function() {
+ cy.loginAs(activeUser);
+ cy.visit(`/collections/${this.testCollection.uuid}`);
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('bar').rightclick();
+ cy.get('[data-cy=context-menu]')
+ .contains('Rename')
+ .click();
+ cy.get('[data-cy=form-dialog]')
+ .should('contain', 'Rename')
+ .within(() => {
+ cy.get('input').type('{backspace}{backspace}{backspace}foo');
+ });
+ cy.get('[data-cy=form-submit-btn]').click();
+ cy.get('[data-cy=collection-files-panel]')
+ .should('not.contain', 'bar')
+ .and('contain', 'foo');
+ });
+ });
+
+ it('tries to rename a file with an illegal name', 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() * Math.floor(999999))}`,
+ owner_uuid: activeUser.user.uuid,
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+ .as('testCollection').then(function() {
+ cy.loginAs(activeUser);
+ cy.visit(`/collections/${this.testCollection.uuid}`);
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('bar').rightclick();
+ cy.get('[data-cy=context-menu]')
+ .contains('Rename')
+ .click();
+ cy.get('[data-cy=form-dialog]')
+ .should('contain', 'Rename')
+ .within(() => {
+ cy.get('input').type('{backspace}{backspace}{backspace}');
+ });
+ cy.get('[data-cy=form-submit-btn]').click();
+ cy.get('[data-cy=form-dialog]')
+ .should('contain', 'Rename')
+ .within(() => {
+ cy.contains('Could not rename');
+ });
+ });
+ });
})
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list