Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123075
D5939.id21348.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Subscribers
None
D5939.id21348.diff
View Options
diff --git a/assets/src/bundles/browse/browse-utils.js b/assets/src/bundles/browse/browse-utils.js
--- a/assets/src/bundles/browse/browse-utils.js
+++ b/assets/src/bundles/browse/browse-utils.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2018-2020 The Software Heritage developers
+ * Copyright (C) 2018-2021 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
@@ -65,8 +65,8 @@
$('#swh-branch-search-form').submit(function(e) {
var searchParams = new URLSearchParams(window.location.search);
- const searchString = $('#swh-branch-search-string').val().trim();
- searchParams.set('branch_name_include', searchString);
+ searchParams.set('name_include',
+ $('#swh-branch-search-string').val().trim());
window.location.search = searchParams.toString();
e.preventDefault();
});
diff --git a/cypress/integration/origin-browse.spec.js b/cypress/integration/origin-browse.spec.js
--- a/cypress/integration/origin-browse.spec.js
+++ b/cypress/integration/origin-browse.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2020 The Software Heritage developers
+ * Copyright (C) 2020-2021 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
@@ -100,19 +100,19 @@
cy.get('#swh-branch-serach-button').click();
cy.location('search')
- .should('include', 'branch_name_include=mas');
+ .should('include', 'name_include=mas');
cy.get('table').contains('td', 'master').should('be.visible');
cy.get('#swh-branch-search-string').should('have.value', 'mas');
});
- it('should empty search show all branches', function() {
+ it('should show all the branches for empty search', function() {
cy.get('#swh-branch-search-string').clear();
cy.get('#swh-branch-serach-button').click();
cy.location('search')
- .should('include', 'branch_name_include=');
+ .should('include', 'name_include=');
cy.get('table').contains('td', 'master').should('be.visible');
@@ -125,3 +125,44 @@
cy.get('table').contains('td', 'No branch names containing random have been found!').should('be.visible');
});
});
+
+describe('Test browse releases', function() {
+ beforeEach(function() {
+ const url = `${this.Urls.browse_origin_releases()}?origin_url=${this.origin[1].url}`;
+ cy.visit(url);
+ });
+
+ it('should have the v2 release in the list', function() {
+ cy.get('table').contains('td', 'v2.0').should('be.visible');
+ });
+
+ it('should search inside the releases', function() {
+ cy.get('#swh-branch-search-string').type('v2.4');
+ cy.get('#swh-branch-serach-button').click();
+
+ cy.location('search')
+ .should('include', 'name_include=v2.4');
+
+ cy.get('table').contains('td', 'v2.4').should('be.visible');
+
+ cy.get('#swh-branch-search-string').should('have.value', 'v2.4');
+ });
+
+ it('should show all the releases for empty search', function() {
+ cy.get('#swh-branch-search-string').clear();
+ cy.get('#swh-branch-serach-button').click();
+
+ cy.location('search')
+ .should('include', 'name_include=');
+
+ cy.get('table').contains('td', 'v2.0').should('be.visible');
+
+ cy.get('#swh-branch-search-string').should('have.value', '');
+ });
+
+ it('should show no release exists message on failed search', function() {
+ cy.get('#swh-branch-search-string').type('random{enter}');
+
+ cy.get('table').contains('td', 'No release names containing random have been found!').should('be.visible');
+ });
+});
diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py
--- a/swh/web/browse/snapshot_context.py
+++ b/swh/web/browse/snapshot_context.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2020 The Software Heritage developers
+# Copyright (C) 2018-2021 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
@@ -1326,7 +1326,11 @@
def browse_snapshot_releases(
- request, snapshot_id=None, origin_url=None, timestamp=None
+ request,
+ snapshot_id=None,
+ origin_url=None,
+ timestamp=None,
+ release_name_include=None,
):
"""
Django view implementation for browsing a list of releases in a snapshot
@@ -1354,8 +1358,11 @@
rel_from,
PER_PAGE + 1,
target_types=["release", "alias"],
+ branch_name_include_substring=release_name_include,
)
- _, displayed_releases, _ = process_snapshot_branches(snapshot)
+ displayed_releases = []
+ if snapshot:
+ _, displayed_releases, _ = process_snapshot_branches(snapshot)
for release in displayed_releases:
query_params_tgt = {"snapshot": snapshot_id}
@@ -1426,7 +1433,7 @@
browse_view_name, url_args=url_args, query_params=query_params
)
- if snapshot["next_branch"] is not None:
+ if snapshot and snapshot["next_branch"] is not None:
query_params_next = dict(query_params)
next_rel = displayed_releases[-1]["branch_name"]
del displayed_releases[-1]
@@ -1458,5 +1465,6 @@
"snapshot_context": snapshot_context,
"vault_cooking": None,
"show_actions": False,
+ "search_string": release_name_include or "",
},
)
diff --git a/swh/web/browse/views/origin.py b/swh/web/browse/views/origin.py
--- a/swh/web/browse/views/origin.py
+++ b/swh/web/browse/views/origin.py
@@ -161,7 +161,7 @@
origin_url=request.GET.get("origin_url"),
snapshot_id=request.GET.get("snapshot"),
timestamp=request.GET.get("timestamp"),
- branch_name_include=request.GET.get("branch_name_include"),
+ branch_name_include=request.GET.get("name_include"),
)
@@ -202,6 +202,7 @@
origin_url=request.GET.get("origin_url"),
snapshot_id=request.GET.get("snapshot"),
timestamp=request.GET.get("timestamp"),
+ release_name_include=request.GET.get("name_include"),
)
diff --git a/swh/web/templates/browse/branches.html b/swh/web/templates/browse/branches.html
--- a/swh/web/templates/browse/branches.html
+++ b/swh/web/templates/browse/branches.html
@@ -13,15 +13,7 @@
{% block swh-browse-content %}
<div class="table-responsive mt-3 mb-3">
<div class="form-group row float-right">
- <form class="form-horizontal d-none d-md-flex input-group" id="swh-branch-search-form">
- <input class="form-control" placeholder="Search in branch names"
- id="swh-branch-search-string" value="{{search_string}}" type="text" />
- <div class="input-group-append">
- <button class="btn btn-primary" type="submit" id="swh-branch-serach-button">
- <i class="swh-search-icon mdi mdi-24px mdi-magnify" aria-hidden="true"></i>
- </button>
- </div>
- </form>
+ {% include "includes/branch-search.html" %}
</div>
<table class="table swh-table swh-table-striped">
<thead>
diff --git a/swh/web/templates/browse/releases.html b/swh/web/templates/browse/releases.html
--- a/swh/web/templates/browse/releases.html
+++ b/swh/web/templates/browse/releases.html
@@ -1,7 +1,7 @@
{% extends "./browse.html" %}
{% comment %}
-Copyright (C) 2017-2019 The Software Heritage developers
+Copyright (C) 2017-2021 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,8 +10,10 @@
{% load swh_templatetags %}
{% block swh-browse-content %}
-{% if displayed_releases|length > 0 %}
<div class="table-responsive mt-3 mb-3">
+ <div class="form-group row float-right">
+ {% include "includes/branch-search.html" %}
+ </div>
<table class="table swh-table swh-table-striped">
<thead>
<tr>
@@ -22,53 +24,62 @@
</tr>
</thead>
<tbody>
- {% for release in displayed_releases %}
- <tr class="swh-release-entry swh-tr-hover-highlight">
- <td class="swh-release-name">
- <a href="{{ release.release_url }}">
- {% if release.alias %}
- <i class="{{ swh_object_icons.alias }} mdi-fw" aria-hidden="true"></i>
- {% else %}
- <i class="{{ swh_object_icons.release }} mdi-fw" aria-hidden="true"></i>
- {% endif %}
- {{ release.name }}
- </a>
- </td>
- <td class="swh-release-target">
- <a href="{{ release.target_url }}">
- <i class="{{ swh_object_icons|key_value:release.target_type }} mdi-fw" aria-hidden="true" title="{{ release.tooltip }}"></i>{{ release.target|slice:":7" }}
- </a>
- </td>
- <td class="swh-log-entry-message swh-release-message swh-table-cell-text-overflow" title="{{ release.message }}">
- {{ release.message }}
- </td>
- <td class="swh-release-date">
- {{ release.date }}
+ {% if displayed_releases|length > 0 %}
+ {% for release in displayed_releases %}
+ <tr class="swh-release-entry swh-tr-hover-highlight">
+ <td class="swh-release-name">
+ <a href="{{ release.release_url }}">
+ {% if release.alias %}
+ <i class="{{ swh_object_icons.alias }} mdi-fw" aria-hidden="true"></i>
+ {% else %}
+ <i class="{{ swh_object_icons.release }} mdi-fw" aria-hidden="true"></i>
+ {% endif %}
+ {{ release.name }}
+ </a>
+ </td>
+ <td class="swh-release-target">
+ <a href="{{ release.target_url }}">
+ <i class="{{ swh_object_icons|key_value:release.target_type }} mdi-fw" aria-hidden="true" title="{{ release.tooltip }}"></i>{{ release.target|slice:":7" }}
+ </a>
+ </td>
+ <td class="swh-log-entry-message swh-release-message swh-table-cell-text-overflow" title="{{ release.message }}">
+ {{ release.message }}
+ </td>
+ <td class="swh-release-date">
+ {{ release.date }}
+ </td>
+ </tr>
+ {% endfor %}
+ {% else %}
+ <tr>
+ <td>
+ {% if search_string %}
+ No release names containing {{search_string}} have been found!
+ {% else %}
+ The list of releases is empty!
+ {% endif %}
</td>
</tr>
- {% endfor %}
+ {% endif %}
</tbody>
</table>
</div>
-{% else %}
- <i>The list of releases is empty !</i>
-{% endif %}
{% endblock %}
{% block swh-browse-after-content %}
-{% if prev_releases_url or next_releases_url %}
- <ul class="pagination justify-content-center">
- {% if prev_releases_url %}
- <li class="page-item"><a class="page-link" href="{{ prev_releases_url }}">Previous</a></li>
- {% else %}
- <li class="page-item disabled"><a class="page-link">Previous</a></li>
- {% endif %}
+ {% if prev_releases_url or next_releases_url %}
+ <ul class="pagination justify-content-center">
+ {% if prev_releases_url %}
+ <li class="page-item"><a class="page-link" href="{{ prev_releases_url }}">Previous</a></li>
+ {% else %}
+ <li class="page-item disabled"><a class="page-link">Previous</a></li>
+ {% endif %}
- {% if next_releases_url %}
- <li class="page-item"><a class="page-link" href="{{ next_releases_url }}">Next</a></li>
- {% else %}
- <li class="page-item disabled"><a class="page-link">Next</a></li>
- {% endif %}
- </ul>
-{% endif %}
+ {% if next_releases_url %}
+ <li class="page-item"><a class="page-link" href="{{ next_releases_url }}">Next</a></li>
+ {% else %}
+ <li class="page-item disabled"><a class="page-link">Next</a></li>
+ {% endif %}
+ </ul>
+ {% endif %}
{% endblock %}
diff --git a/swh/web/templates/includes/branch-search.html b/swh/web/templates/includes/branch-search.html
new file mode 100644
--- /dev/null
+++ b/swh/web/templates/includes/branch-search.html
@@ -0,0 +1,16 @@
+{% comment %}
+Copyright (C) 2021 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
+{% endcomment %}
+
+<form class="form-horizontal d-none d-md-flex input-group" id="swh-branch-search-form">
+ <input class="form-control" placeholder="Search in names"
+ id="swh-branch-search-string" value="{{search_string}}" type="text" />
+ <div class="input-group-append">
+ <button class="btn btn-primary" type="submit" id="swh-branch-serach-button">
+ <i class="swh-search-icon mdi mdi-24px mdi-magnify" aria-hidden="true"></i>
+ </button>
+ </div>
+</form>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 17, 7:47 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3224412
Attached To
D5939: Search inside the origin releases with name
Event Timeline
Log In to Comment