diff --git a/cypress/integration/origin-browse.spec.js b/cypress/integration/origin-browse.spec.js new file mode 100644 --- /dev/null +++ b/cypress/integration/origin-browse.spec.js @@ -0,0 +1,87 @@ +/** + * Copyright (C) 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 + */ + +describe('Test origin browse', function() { + beforeEach(function() { + const url = `${this.Urls.browse_origin()}?origin_url=${this.origin[1].url}`; + cy.visit(url); + }); + + it('should have code tab active by default', function() { + cy.get('#swh-browse-code-nav-link') + .should('have.class', 'active'); + }); + + it('should load branches view when clicking on the Branches tab', function() { + cy.get('#swh-browse-snapshot-branches-nav-link') + .click(); + + cy.location('pathname') + .should('eq', this.Urls.browse_origin_branches()); + + cy.location('search') + .should('eq', `?origin_url=${this.origin[1].url}`); + + cy.get('#swh-browse-snapshot-branches-nav-link') + .should('have.class', 'active'); + }); + + it('should load releases view when clicking on the Releases tab', function() { + cy.get('#swh-browse-snapshot-releases-nav-link') + .click(); + + cy.location('pathname') + .should('eq', this.Urls.browse_origin_releases()); + + cy.location('search') + .should('eq', `?origin_url=${this.origin[1].url}`); + + cy.get('#swh-browse-snapshot-releases-nav-link') + .should('have.class', 'active'); + }); + + it('should load visits view when clicking on the Visits tab', function() { + cy.get('#swh-browse-origin-visits-nav-link') + .click(); + + cy.location('pathname') + .should('eq', this.Urls.browse_origin_visits()); + + cy.location('search') + .should('eq', `?origin_url=${this.origin[1].url}`); + + cy.get('#swh-browse-origin-visits-nav-link') + .should('have.class', 'active'); + }); + + it('should load code view when clicking on the Code tab', function() { + cy.get('#swh-browse-origin-visits-nav-link') + .click(); + + cy.get('#swh-browse-code-nav-link') + .click(); + + cy.location('pathname') + .should('eq', this.Urls.browse_origin_directory()); + + cy.location('search') + .should('eq', `?origin_url=${this.origin[1].url}`); + + cy.get('#swh-browse-code-nav-link') + .should('have.class', 'active'); + + }); + + it('should have Releases tab link disabled when there is no releases', function() { + const url = `${this.Urls.browse_origin()}?origin_url=${this.origin[0].url}`; + cy.visit(url); + + cy.get('#swh-browse-snapshot-releases-nav-link') + .should('have.class', 'disabled'); + }); + +}); diff --git a/swh/web/assets/src/bundles/browse/browse-utils.js b/swh/web/assets/src/bundles/browse/browse-utils.js --- a/swh/web/assets/src/bundles/browse/browse-utils.js +++ b/swh/web/assets/src/bundles/browse/browse-utils.js @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2019 The Software Heritage developers + * Copyright (C) 2018-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 @@ -70,3 +70,17 @@ }); }); + +export function initBrowseNavbar() { + if (window.location.pathname === Urls.browse_origin_visits()) { + $('#swh-browse-origin-visits-nav-link').addClass('active'); + } else if (window.location.pathname === Urls.browse_origin_branches() || + window.location.pathname === Urls.browse_snapshot_branches()) { + $('#swh-browse-snapshot-branches-nav-link').addClass('active'); + } else if (window.location.pathname === Urls.browse_origin_releases() || + window.location.pathname === Urls.browse_snapshot_releases()) { + $('#swh-browse-snapshot-releases-nav-link').addClass('active'); + } else { + $('#swh-browse-code-nav-link').addClass('active'); + } +} diff --git a/swh/web/assets/src/bundles/webapp/webapp.css b/swh/web/assets/src/bundles/webapp/webapp.css --- a/swh/web/assets/src/bundles/webapp/webapp.css +++ b/swh/web/assets/src/bundles/webapp/webapp.css @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2019 The Software Heritage developers + * Copyright (C) 2018-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 @@ -385,10 +385,6 @@ height: auto; } - .swh-navbar-content h4 { - font-size: 1rem; - } - .swh-donate-link { display: none; } diff --git a/swh/web/common/utils.py b/swh/web/common/utils.py --- a/swh/web/common/utils.py +++ b/swh/web/common/utils.py @@ -38,6 +38,7 @@ "branches": "mdi mdi-source-branch", "content": "mdi mdi-file-document", "directory": "mdi mdi-folder", + "origin": "mdi mdi-source-repository", "person": "mdi mdi-account", "revisions history": "mdi mdi-history", "release": "mdi mdi-tag", diff --git a/swh/web/templates/browse/browse.html b/swh/web/templates/browse/browse.html --- a/swh/web/templates/browse/browse.html +++ b/swh/web/templates/browse/browse.html @@ -13,36 +13,9 @@ {% block navbar-content %} -{% if snapshot_context %} -

- - - {% if snapshot_context.origin_info %} - Browse archived {{ swh_object_name.lower }} for origin - - {{ snapshot_context.origin_info.url }} - - {% if snapshot_context.origin_info.url|slice:"0:4" == "http" %} - - - - {% endif %} - {% else %} - Browse archived {{ swh_object_name.lower }} for snapshot - - {{ snapshot_context.snapshot_swhid }} - - {% endif %} -

-{% else %} -

- - Browse archived {{ swh_object_name.lower }} - - {{ swh_object_id }} - -

-{% endif %} +

+ Browse the archive +

{% endblock %} diff --git a/swh/web/templates/browse/origin-visits.html b/swh/web/templates/browse/origin-visits.html --- a/swh/web/templates/browse/origin-visits.html +++ b/swh/web/templates/browse/origin-visits.html @@ -1,7 +1,7 @@ {% extends "./browse.html" %} {% comment %} -Copyright (C) 2017-2018 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 @@ -18,61 +18,64 @@ {% block swh-browse-content %} -

Overview

- - - -

History

- -
-
- - -
-
- - -
-
- - -
-
- -
Calendar
- -
- -
List
- -
- -
Timeline
- -
+
+ +

Overview

+ + + +

History

+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
Calendar
+ +
+ +
List
+ +
+ +
Timeline
+ +
+
\ No newline at end of file diff --git a/swh/web/templates/includes/top-navigation.html b/swh/web/templates/includes/top-navigation.html --- a/swh/web/templates/includes/top-navigation.html +++ b/swh/web/templates/includes/top-navigation.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,7 +7,7 @@ {% load swh_templatetags %} -
+
{% if snapshot_context %} {% if snapshot_context.branch or snapshot_context.release %}