diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js
--- a/cypress/integration/vault.spec.js
+++ b/cypress/integration/vault.spec.js
@@ -103,14 +103,71 @@
cy.server();
});
- it('should create a directory cooking task and report its status', function() {
+ it('should report an error when vault service is experiencing issues', function() {
+ // Browse a directory
+ cy.visit(this.directoryUrl);
+
+ // Stub responses when requesting the vault API to simulate
+ // an internal server error
+ cy.route({
+ method: 'GET',
+ url: this.vaultDirectoryUrl,
+ response: {'exception': 'APIError'},
+ status: 500
+ }).as('checkVaultCookingTask');
+
+ cy.contains('button', 'Download')
+ .click();
+
+ // Check error alert is displayed
+ cy.get('.alert-danger')
+ .should('be.visible')
+ .should('contain', 'Archive cooking service is currently experiencing issues.');
+ });
+
+ it('should report an error when a cooking task creation failed', function() {
// Browse a directory
cy.visit(this.directoryUrl);
// Stub responses when requesting the vault API to simulate
- // a task has been created
+ // a task can not be created
+ cy.route({
+ method: 'GET',
+ url: this.vaultDirectoryUrl,
+ response: {'exception': 'NotFoundExc'}
+ }).as('checkVaultCookingTask');
+ cy.route({
+ method: 'POST',
+ url: this.vaultDirectoryUrl,
+ response: {'exception': 'ValueError'},
+ status: 500
+ }).as('createVaultCookingTask');
+
+ cy.contains('button', 'Download')
+ .click();
+
+ // Create a vault cooking task through the GUI
+ cy.get('.modal-dialog')
+ .contains('button:visible', 'Ok')
+ .click();
+
+ cy.wait('@createVaultCookingTask');
+
+ // Check error alert is displayed
+ cy.get('.alert-danger')
+ .should('be.visible')
+ .should('contain', 'Archive cooking request submission failed.');
+ });
+
+ it('should create a directory cooking task and report the success', function() {
+
+ // Browse a directory
+ cy.visit(this.directoryUrl);
+
+ // Stub responses when requesting the vault API to simulate
+ // a task has been created
cy.route({
method: 'GET',
url: this.vaultDirectoryUrl,
@@ -143,8 +200,13 @@
cy.wait('@createVaultCookingTask');
- // Check that a redirection to the vault UI has been performed
- cy.url().should('eq', Cypress.config().baseUrl + this.Urls.browse_vault());
+ // Check success alert is displayed
+ cy.get('.alert-success')
+ .should('be.visible')
+ .should('contain', 'Archive cooking request successfully submitted.');
+
+ // Go to Downloads page
+ cy.visit(this.Urls.browse_vault());
cy.wait('@checkVaultCookingTask').then(() => {
testStatus(this.directory, progressbarColors['new'], 'new', 'new');
@@ -240,8 +302,13 @@
cy.wait('@createVaultCookingTask');
- // Check that a redirection to the vault UI has been performed
- cy.url().should('eq', Cypress.config().baseUrl + this.Urls.browse_vault());
+ // Check success alert is displayed
+ cy.get('.alert-success')
+ .should('be.visible')
+ .should('contain', 'Archive cooking request successfully submitted.');
+
+ // Go to Downloads page
+ cy.visit(this.Urls.browse_vault());
cy.wait('@checkVaultCookingTask').then(() => {
testStatus(this.revision, progressbarColors['new'], 'new', 'new');
diff --git a/swh/web/assets/src/bundles/vault/vault-create-tasks.js b/swh/web/assets/src/bundles/vault/vault-create-tasks.js
--- a/swh/web/assets/src/bundles/vault/vault-create-tasks.js
+++ b/swh/web/assets/src/bundles/vault/vault-create-tasks.js
@@ -5,7 +5,14 @@
* See top-level LICENSE file for more information
*/
-import {handleFetchError, csrfPost} from 'utils/functions';
+import {handleFetchError, csrfPost, htmlAlert} from 'utils/functions';
+
+const alertStyle = {
+ 'position': 'fixed',
+ 'left': '1rem',
+ 'bottom': '1rem',
+ 'z-index': '100000'
+};
export function vaultRequest(objectType, objectId) {
let vaultUrl;
@@ -28,6 +35,14 @@
// it will be asked to cook it again if it is not
} else if (data.status === 'done') {
$(`#vault-fetch-${objectType}-modal`).modal('show');
+ } else {
+ const cookingServiceDownAlert =
+ $(htmlAlert('danger',
+ 'Archive cooking service is currently experiencing issues.
' +
+ 'Please try again later.',
+ true));
+ cookingServiceDownAlert.css(alertStyle);
+ $('body').append(cookingServiceDownAlert);
}
});
}
@@ -59,6 +74,7 @@
if (cookingTask.email) {
cookingUrl += '?email=' + cookingTask.email;
}
+
csrfPost(cookingUrl)
.then(handleFetchError)
.then(() => {
@@ -66,14 +82,25 @@
localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultCookingTasks));
$('#vault-cook-directory-modal').modal('hide');
$('#vault-cook-revision-modal').modal('hide');
- window.location = Urls.browse_vault();
+ const cookingTaskCreatedAlert =
+ $(htmlAlert('success',
+ 'Archive cooking request successfully submitted.
' +
+ `Go to the Downloads page ` +
+ 'to get the download link once it is ready.',
+ true));
+ cookingTaskCreatedAlert.css(alertStyle);
+ $('body').append(cookingTaskCreatedAlert);
})
.catch(() => {
$('#vault-cook-directory-modal').modal('hide');
$('#vault-cook-revision-modal').modal('hide');
+ const cookingTaskFailedAlert =
+ $(htmlAlert('danger',
+ 'Archive cooking request submission failed.',
+ true));
+ cookingTaskFailedAlert.css(alertStyle);
+ $('body').append(cookingTaskFailedAlert);
});
- } else {
- window.location = Urls.browse_vault();
}
}
diff --git a/swh/web/assets/src/utils/functions.js b/swh/web/assets/src/utils/functions.js
--- a/swh/web/assets/src/utils/functions.js
+++ b/swh/web/assets/src/utils/functions.js
@@ -8,6 +8,7 @@
// utility functions
export function handleFetchError(response) {
+ console.log(response);
if (!response.ok) {
throw response;
}
diff --git a/swh/web/templates/includes/vault-create-tasks.html b/swh/web/templates/includes/vault-create-tasks.html
--- a/swh/web/templates/includes/vault-create-tasks.html
+++ b/swh/web/templates/includes/vault-create-tasks.html
@@ -51,10 +51,6 @@
You have requested the cooking of the directory with identifier {{ vault_cooking.directory_id }}
into a standard tar.gz archive
.
- Once downloaded, the directory can be extracted with the following command: -
-$ tar xvzf {{ vault_cooking.directory_id }}.tar.gz
Are you sure you want to continue ?
@@ -87,10 +83,6 @@ You have requested the download of the directory with identifier {{ vault_cooking.directory_id }} as a standardtar.gz archive
.
- - Once downloaded, the directory can be extracted with the following command: -
-$ tar xvzf {{ vault_cooking.directory_id }}.tar.gz
Are you sure you want to continue ?
@@ -117,13 +109,6 @@ You have requested the cooking of the history heading to revision with identifier {{ vault_cooking.revision_id }} into agit fast-import archive
.
- - Once downloaded, the git repository can be imported with the following commands: -
-
- $ git init
- $ zcat {{ vault_cooking.revision_id }}.gitfast.gz | git fast-import
-
Are you sure you want to continue ?
@@ -156,13 +141,6 @@ You have requested the download of the history heading to revision with identifier {{ vault_cooking.revision_id }} as agit fast-import archive
.
- - Once downloaded, the git repository can be imported with the following commands: -
-
- $ git init
- $ zcat {{ vault_cooking.revision_id }}.gitfast.gz | git fast-import
-
Are you sure you want to continue ?