diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js index b40ff58f8ce70ca55d079900001589c4e2904280..f227f5fea780e6db1f4863fd298a724c600e4a1b 100644 --- a/cypress/integration/vault.spec.js +++ b/cypress/integration/vault.spec.js @@ -1,5 +1,5 @@ /** - * Copyright (C) 2019 The Software Heritage developers + * Copyright (C) 2019-2020 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information @@ -13,11 +13,18 @@ const progressbarColors = { 'done': 'rgb(92, 184, 92)' }; -function checkVaultCookingTask(objectType) { - cy.contains('button', 'Actions') - .click(); +function adminLogin() { + cy.visit('/admin/') + .get('input[name="username"]') + .type('admin') + .get('input[name="password"]') + .type('admin') + .get('form') + .submit(); +} - cy.contains('.dropdown-item', 'Download') +function checkVaultCookingTask(objectType) { + cy.contains('button', 'Download') .click(); cy.contains('.dropdown-item', objectType) @@ -124,7 +131,8 @@ describe('Vault Cooking User Interface Tests', function() { response: this.genVaultDirCookingResponse('new') }).as('createVaultCookingTask'); - checkVaultCookingTask('as tarball'); + cy.contains('button', 'Download') + .click(); cy.route({ method: 'GET', @@ -189,6 +197,7 @@ describe('Vault Cooking User Interface Tests', function() { }); it('should create a revision cooking task and report its status', function() { + adminLogin(); // Browse a revision cy.visit(this.revisionUrl); @@ -358,7 +367,8 @@ describe('Vault Cooking User Interface Tests', function() { }).as('fetchCookedArchive'); // Create a vault cooking task through the GUI - checkVaultCookingTask('as tarball'); + cy.contains('button', 'Download') + .click(); // Start archive download through the GUI cy.get('.modal-dialog') @@ -370,7 +380,7 @@ describe('Vault Cooking User Interface Tests', function() { }); it('should offer to immediately download a revision gitfast archive if already cooked', function() { - + adminLogin(); // Browse a directory cy.visit(this.revisionUrl); @@ -416,7 +426,8 @@ describe('Vault Cooking User Interface Tests', function() { response: this.genVaultDirCookingResponse('failed') }).as('checkVaultCookingTask'); - checkVaultCookingTask('as tarball'); + cy.contains('button', 'Download') + .click(); // Check that recooking the directory is offered to user cy.get('.modal-dialog') diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py index 9a5203f1d4031910e7d713bdc11113f672219e5f..c5094a0d86f090813dae480b93b8a0a39631d7f5 100644 --- a/swh/web/browse/snapshot_context.py +++ b/swh/web/browse/snapshot_context.py @@ -851,7 +851,7 @@ def browse_snapshot_directory( "readme_html": readme_html, "snapshot_context": snapshot_context, "vault_cooking": vault_cooking, - "show_actions_menu": True, + "show_actions": True, "swhids_info": swhids_info, }, ) @@ -1037,7 +1037,7 @@ def browse_snapshot_content( "top_right_link": top_right_link, "snapshot_context": snapshot_context, "vault_cooking": None, - "show_actions_menu": True, + "show_actions": True, "swhids_info": swhids_info, "error_code": content_data.get("error_code"), "error_message": content_data.get("error_message"), @@ -1187,7 +1187,7 @@ def browse_snapshot_log(request, snapshot_id=None, origin_url=None, timestamp=No "top_right_link": None, "snapshot_context": snapshot_context, "vault_cooking": None, - "show_actions_menu": True, + "show_actions": True, "swhids_info": swhids_info, }, ) @@ -1436,6 +1436,6 @@ def browse_snapshot_releases( "next_releases_url": next_releases_url, "snapshot_context": snapshot_context, "vault_cooking": None, - "show_actions_menu": False, + "show_actions": False, }, ) diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py index a8d065b3128e59474e94999cbe19f392789c69b5..cee04ccaf365a99d1164fea8c2fa5d0954873828 100644 --- a/swh/web/browse/views/content.py +++ b/swh/web/browse/views/content.py @@ -401,7 +401,7 @@ def content_display(request, query_string): }, "snapshot_context": snapshot_context, "vault_cooking": None, - "show_actions_menu": True, + "show_actions": True, "swhids_info": swhids_info, "error_code": content_data["error_code"], "error_message": content_data["error_message"], diff --git a/swh/web/browse/views/directory.py b/swh/web/browse/views/directory.py index f45771318731abab77767dc72bffb8d66ae0bdfe..e974303e6cb117cab2ab8c1823cdb400290537af 100644 --- a/swh/web/browse/views/directory.py +++ b/swh/web/browse/views/directory.py @@ -215,7 +215,7 @@ def _directory_browse(request, sha1_git, path=None): "readme_html": readme_html, "snapshot_context": snapshot_context, "vault_cooking": vault_cooking, - "show_actions_menu": True, + "show_actions": True, "swhids_info": swhids_info, }, ) diff --git a/swh/web/browse/views/origin.py b/swh/web/browse/views/origin.py index 38dd97c91aae85e16811a5a4b8841dc61e50827d..4ca0d2c43e18a3e8a20efa2174b73c7d7da94565 100644 --- a/swh/web/browse/views/origin.py +++ b/swh/web/browse/views/origin.py @@ -270,7 +270,7 @@ def _origin_visits_browse(request, origin_url): "origin_info": origin_info, "snapshot_context": snapshot_context, "vault_cooking": None, - "show_actions_menu": False, + "show_actions": False, }, ) diff --git a/swh/web/browse/views/release.py b/swh/web/browse/views/release.py index 736b5f99590f145107b736b12f562360a9dd7fbe..cb4ace406580b301d3cdcd78f564a966c1da587b 100644 --- a/swh/web/browse/views/release.py +++ b/swh/web/browse/views/release.py @@ -232,7 +232,7 @@ def release_browse(request, sha1_git): "swh_object_metadata": release_metadata, "release": release, "snapshot_context": snapshot_context, - "show_actions_menu": True, + "show_actions": True, "breadcrumbs": None, "vault_cooking": vault_cooking, "top_right_link": None, diff --git a/swh/web/browse/views/revision.py b/swh/web/browse/views/revision.py index ae4714f43a00f632a6046287ff028d56d4e8b7b6..bebd7f5d61ae5c531d643c18aa57e77033d67fe9 100644 --- a/swh/web/browse/views/revision.py +++ b/swh/web/browse/views/revision.py @@ -299,7 +299,7 @@ def revision_log_browse(request, sha1_git): "top_right_link": None, "snapshot_context": snapshot_context, "vault_cooking": None, - "show_actions_menu": True, + "show_actions": True, "swhids_info": None, }, ) @@ -597,7 +597,7 @@ def revision_browse(request, sha1_git): "top_right_link": top_right_link, "vault_cooking": vault_cooking, "diff_revision_url": diff_revision_url, - "show_actions_menu": True, + "show_actions": True, "swhids_info": swhids_info, "error_code": error_code, "error_message": error_message, diff --git a/swh/web/templates/includes/show-metadata.html b/swh/web/templates/includes/show-metadata.html index 2dcfc29e657035bf81e19afde115863651959e3e..ff05f1375ed3ce5ff0dca29927e9728e91768ef7 100644 --- a/swh/web/templates/includes/show-metadata.html +++ b/swh/web/templates/includes/show-metadata.html @@ -1,5 +1,5 @@ {% comment %} -Copyright (C) 2017-2019 The Software Heritage developers +Copyright (C) 2017-2020 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information @@ -7,9 +7,10 @@ See top-level LICENSE file for more information {% load swh_templatetags %} -<div class="dropdown-submenu"> - <a id="metadata-toggler" class="dropdown-item dropdown-left swh-popover-toggler" tabindex="-1" href="#" data-toggle="popover" data-popover-content="#metadata-popover"><i class="mdi mdi-table mdi-fw" aria-hidden="true"></i>Show metadata</a> -</div> +<button id="metadata-toggler" class="btn btn-default btn-sm swh-popover-toggler" data-toggle="popover" data-popover-content="#metadata-popover"> + <i class="mdi mdi-table mdi-fw" aria-hidden="true"></i> + Show metadata +</button> <div id="metadata-popover" style="display:none;"> <div class="popover-heading">{{ swh_object_name }} metadata</div> diff --git a/swh/web/templates/includes/take-new-snapshot.html b/swh/web/templates/includes/take-new-snapshot.html index e05e7ba9779cd77f6dc5cb90f438cc1a3295dbeb..00ae8d15828e34af58cae31785ff701aaccb7e57 100644 --- a/swh/web/templates/includes/take-new-snapshot.html +++ b/swh/web/templates/includes/take-new-snapshot.html @@ -1,5 +1,5 @@ {% comment %} -Copyright (C) 2019 The Software Heritage developers +Copyright (C) 2019-2020 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information @@ -10,12 +10,10 @@ See top-level LICENSE file for more information {% if snapshot_context and snapshot_context.visit_info and snapshot_context.visit_info.type|visit_type_savable %} - <!-- entry in the Actions menu --> - <div class="dropdown-submenu"> - <button class="dropdown-item" type="button" tabindex="-1" data-toggle="modal" data-target="#swh-take-new-snapshot-modal"> - <i class="mdi mdi-camera mdi-fw" aria-hidden="true"></i>Take a new snapshot - </button> - </div> + <button class="btn btn-default btn-sm" type="button" tabindex="-1" data-toggle="modal" data-target="#swh-take-new-snapshot-modal"> + <i class="mdi mdi-camera mdi-fw" aria-hidden="true"></i> + New snapshot + </button> <div class="modal fade" id="swh-take-new-snapshot-modal" tabindex="-1" role="dialog" aria-labelledby="swh-take-new-snapshot-modal-label" aria-hidden="true"> <div class="modal-dialog"> diff --git a/swh/web/templates/includes/top-navigation.html b/swh/web/templates/includes/top-navigation.html index d961e9272900cc3caa88580af561fbf0f5037943..501c6516cf0bf9110d248f118c8a1fa9bddba717 100644 --- a/swh/web/templates/includes/top-navigation.html +++ b/swh/web/templates/includes/top-navigation.html @@ -106,18 +106,14 @@ See top-level LICENSE file for more information {% endfor %} </select> {% endif %} - {% if show_actions_menu %} - <button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown"> - <i class="mdi mdi-menu mdi-fw" aria-hidden="true"></i>Actions - <span class="caret"></span> - </button> - <ul class="dropdown-menu dropdown-menu-right swh-browse-actions-menu"> - {% if not snapshot_context or not snapshot_context.is_empty %} - {% include "includes/vault-create-tasks.html" %} - {% endif %} + {% if show_actions %} + {% if not snapshot_context or not snapshot_context.is_empty %} + {% include "includes/vault-create-tasks.html" %} + {% endif %} + {% include "includes/take-new-snapshot.html" %} + {% if user.is_staff %} {% include "includes/show-metadata.html" %} - {% include "includes/take-new-snapshot.html" %} - </ul> + {% endif %} {% endif %} </div> </div> diff --git a/swh/web/templates/includes/vault-create-tasks.html b/swh/web/templates/includes/vault-create-tasks.html index ddc0529e454343d2429e43a08b12ce54bffe41e1..7d8e5a51c76c15aa7e6c0a8e8a361b1eed09800a 100644 --- a/swh/web/templates/includes/vault-create-tasks.html +++ b/swh/web/templates/includes/vault-create-tasks.html @@ -1,5 +1,5 @@ {% comment %} -Copyright (C) 2017-2019 The Software Heritage developers +Copyright (C) 2017-2020 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information @@ -8,25 +8,32 @@ See top-level LICENSE file for more information {% load swh_templatetags %} {% if vault_cooking %} - - <!-- entry in the Actions menu --> - <div class="dropdown-submenu swh-vault-menu"> - <a class="dropdown-item dropdown-left" tabindex="-1" href="#"> - <i class="mdi mdi-download mdi-fw" aria-hidden="true"></i>Download - </a> - <div class="dropdown-menu"> + {% if user.is_staff %} + <button class="btn btn-default btn-sm dropdown-toggle" 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_id }}')"> - <i class="{{ swh_object_icons.directory }} mdi-fw" aria-hidden="true"></i>as tarball + <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_id }}')"> - <i class="{{ swh_object_icons.revision }} mdi-fw" aria-hidden="true"></i>as git + <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" type="button" onclick="swh.vault.vaultRequest('directory', '{{ vault_cooking.directory_id }}')"> + <i class="mdi mdi-download mdi-fw" aria-hidden="true"></i> + Download + </button> + {% endif %} + <!-- modals related to the creation of vault cooking tasks --> <!-- they will be reparented in the script below in order to be able to display them -->