From 1f8d8674c4e14cd6f0225da58bdd566bd142e5b8 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz <vlorentz@softwareheritage.org> Date: Tue, 8 Feb 2022 11:55:15 +0100 Subject: [PATCH] Allow vault cooking from the UI The vault is now about as stable as it can be in the short term, so I think it is time to finally make this available to everyone, without having to go throught the API manually. --- cypress/integration/vault.spec.js | 23 ++++++++--- .../includes/vault-create-tasks.html | 41 ++++++++----------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js index 9c98efff4..bea251397 100644 --- a/cypress/integration/vault.spec.js +++ b/cypress/integration/vault.spec.js @@ -129,8 +129,7 @@ describe('Vault Cooking User Interface Tests', function() { statusCode: 500 }).as('checkVaultCookingTask'); - cy.contains('button', 'Download') - .click(); + checkVaultCookingTask('as tarball'); // Check error alert is displayed cy.get('.alert-danger') @@ -157,6 +156,9 @@ describe('Vault Cooking User Interface Tests', function() { cy.contains('button', 'Download') .click(); + cy.contains('button', 'as tarball') + .click(); + // Create a vault cooking task through the GUI cy.get('.modal-dialog') .contains('button:visible', 'Ok') @@ -229,6 +231,9 @@ describe('Vault Cooking User Interface Tests', function() { cy.contains('button', 'Download') .click(); + cy.contains('button', 'as tarball') + .click(); + cy.window().then(win => { const swhIdsContext = win.swh.webapp.getSwhIdsContext(); const browseDirectoryUrl = swhIdsContext.directory.swhid_with_context_url; @@ -393,6 +398,9 @@ describe('Vault Cooking User Interface Tests', function() { cy.contains('button', 'Download') .click(); + cy.contains('button', 'as tarball') + .click(); + // Create a vault cooking task through the GUI cy.get('.modal-dialog') .contains('button:visible', 'Ok') @@ -421,10 +429,7 @@ describe('Vault Cooking User Interface Tests', function() { }).as('createVaultCookingTask'); // Open vault cook directory modal - cy.contains('button', 'Download') - .click(); - - cy.wait('@checkVaultCookingTask'); + checkVaultCookingTask('as tarball'); // Create a vault cooking task through the GUI and fill email input cy.get('#vault-cook-directory-modal input[type="email"]') @@ -518,6 +523,9 @@ describe('Vault Cooking User Interface Tests', function() { cy.contains('button', 'Download') .click(); + cy.contains('button', 'as tarball') + .click(); + // Start archive download through the GUI cy.get('.modal-dialog') .contains('button:visible', 'Ok') @@ -571,6 +579,9 @@ describe('Vault Cooking User Interface Tests', function() { cy.contains('button', 'Download') .click(); + cy.contains('button', 'as tarball') + .click(); + // Check that recooking the directory is offered to user cy.get('.modal-dialog') .contains('button:visible', 'Ok') diff --git a/swh/web/templates/includes/vault-create-tasks.html b/swh/web/templates/includes/vault-create-tasks.html index 97e1edf51..f6a32c526 100644 --- a/swh/web/templates/includes/vault-create-tasks.html +++ b/swh/web/templates/includes/vault-create-tasks.html @@ -8,33 +8,26 @@ See top-level LICENSE file for more information {% load swh_templatetags %} {% if vault_cooking %} - {% if user.is_authenticated and user.is_staff or "swh.vault.git_bare.ui" in user.get_all_permissions %} - <div class="btn-group"> - <button class="btn btn-default btn-sm dropdown-toggle swh-vault-download" type="button" data-toggle="dropdown"> - <i class="mdi mdi-download mdi-fw" aria-hidden="true"></i> - Download - </button> - <div class="dropdown-menu swh-vault-menu"> - {% if vault_cooking.directory_context %} - <button class="dropdown-item" type="button" tabindex="-1" onclick="swh.vault.vaultRequest('directory', '{{ vault_cooking.directory_swhid }}')"> - <i class="{{ swh_object_icons.directory }} mdi-fw" aria-hidden="true"></i> - as tarball - </button> - {% endif %} - {% if vault_cooking.revision_context %} - <button class="dropdown-item" type="button" tabindex="-1" onclick="swh.vault.vaultRequest('revision', '{{ vault_cooking.revision_swhid }}')"> - <i class="{{ swh_object_icons.revision }} mdi-fw" aria-hidden="true"></i> - as git - </button> - {% endif %} - </div> - </div> - {% else %} - <button class="btn btn-default btn-sm swh-vault-download" type="button" onclick="swh.vault.vaultRequest('directory', '{{ vault_cooking.directory_swhid }}')"> + <div class="btn-group"> + <button class="btn btn-default btn-sm dropdown-toggle swh-vault-download" type="button" data-toggle="dropdown"> <i class="mdi mdi-download mdi-fw" aria-hidden="true"></i> Download </button> - {% endif %} + <div class="dropdown-menu swh-vault-menu"> + {% if vault_cooking.directory_context %} + <button class="dropdown-item" type="button" tabindex="-1" onclick="swh.vault.vaultRequest('directory', '{{ vault_cooking.directory_swhid }}')"> + <i class="{{ swh_object_icons.directory }} mdi-fw" aria-hidden="true"></i> + as tarball + </button> + {% endif %} + {% if vault_cooking.revision_context %} + <button class="dropdown-item" type="button" tabindex="-1" onclick="swh.vault.vaultRequest('revision', '{{ vault_cooking.revision_swhid }}')"> + <i class="{{ swh_object_icons.revision }} mdi-fw" aria-hidden="true"></i> + as git + </button> + {% endif %} + </div> + </div> <!-- modals related to the creation of vault cooking tasks --> -- GitLab