diff --git a/assets/src/bundles/add_forge/create-request.js b/assets/src/bundles/add_forge/create-request.js --- a/assets/src/bundles/add_forge/create-request.js +++ b/assets/src/bundles/add_forge/create-request.js @@ -5,7 +5,7 @@ * See top-level LICENSE file for more information */ -import {handleFetchError, removeUrlFragment, csrfPost, +import {handleFetchError, csrfPost, getHumanReadableDate} from 'utils/functions'; import userRequestsFilterCheckboxFn from 'utils/requests-filter-checkbox.ejs'; import {swhSpinnerSrc} from 'utils/constants'; @@ -63,37 +63,10 @@ } }); - $('#swh-add-forge-requests-list-tab').on('shown.bs.tab', () => { - requestBrowseTable.draw(); - window.location.hash = '#browse-requests'; - }); - - $('#swh-add-forge-requests-help-tab').on('shown.bs.tab', () => { - window.location.hash = '#help'; - }); - - $('#swh-add-forge-tab').on('shown.bs.tab', () => { - removeUrlFragment(); - }); - - $(window).on('hashchange', () => { - onPageHashChage(); - }); - onPageHashChage(); // Explicit call to handle a hash during the page load populateRequestBrowseList(); // Load existing requests }); } -function onPageHashChage() { - if (window.location.hash === '#browse-requests') { - $('.nav-tabs a[href="#swh-add-forge-requests-list"]').tab('show'); - } else if (window.location.hash === '#help') { - $('.nav-tabs a[href="#swh-add-forge-requests-help"]').tab('show'); - } else { - $('.nav-tabs a[href="#swh-add-forge-submit-request"]').tab('show'); - } -} - export function populateRequestBrowseList() { requestBrowseTable = $('#add-forge-request-browse') .on('error.dt', (e, settings, techNote, message) => { diff --git a/cypress/integration/add-forge-now-request-create.spec.js b/cypress/integration/add-forge-now-request-create.spec.js --- a/cypress/integration/add-forge-now-request-create.spec.js +++ b/cypress/integration/add-forge-now-request-create.spec.js @@ -18,7 +18,7 @@ describe('Browse requests list tests', function() { beforeEach(function() { - this.addForgeNowUrl = this.Urls.forge_add(); + this.addForgeNowUrl = this.Urls.forge_add_create(); this.listAddForgeRequestsUrl = this.Urls.add_forge_request_list_datatables(); }); @@ -71,6 +71,10 @@ cy.get('#swh-add-forge-requests-list-tab').click(); cy.get('#swh-add-forge-user-filter').should('exist').should('be.checked'); + // Uncheck and re-check again, to synchronize table state with the checkbox + // FIXME: this should not be needed + cy.get('#swh-add-forge-user-filter').click().click(); + // check unfiltered user requests cy.get('tbody tr').then(rows => { expect(rows.length).to.eq(2); @@ -88,7 +92,7 @@ describe('Test add-forge-request creation', function() { beforeEach(function() { - this.addForgeNowUrl = this.Urls.forge_add(); + this.addForgeNowUrl = this.Urls.forge_add_create(); }); it('should show all the tabs for every user', function() { @@ -127,7 +131,7 @@ cy.get('#loginLink') .should('have.attr', 'href') - .and('include', `${this.Urls.login()}?next=${this.Urls.forge_add()}`); + .and('include', `${this.Urls.login()}?next=${this.Urls.forge_add_create()}`); }); it('should change tabs on click', function() { @@ -140,7 +144,8 @@ .should('have.class', 'active'); cy.get('#swh-add-forge-requests-help-tab') .should('not.have.class', 'active'); - cy.hash().should('eq', '#browse-requests'); + cy.url() + .should('include', `${this.Urls.forge_add_list()}`); cy.get('#swh-add-forge-requests-help-tab').click(); cy.get('#swh-add-forge-tab') @@ -149,7 +154,8 @@ .should('not.have.class', 'active'); cy.get('#swh-add-forge-requests-help-tab') .should('have.class', 'active'); - cy.hash().should('eq', '#help'); + cy.url() + .should('include', `${this.Urls.forge_add_help()}`); cy.get('#swh-add-forge-tab').click(); cy.get('#swh-add-forge-tab') @@ -158,7 +164,8 @@ .should('not.have.class', 'active'); cy.get('#swh-add-forge-requests-help-tab') .should('not.have.class', 'active'); - cy.hash().should('eq', ''); + cy.url() + .should('include', `${this.Urls.forge_add_create()}`); }); it('should show create form elements to authenticated user', function() { @@ -193,7 +200,7 @@ .should('be.visible'); cy.get('#loginLink') - .should('not.be.visible'); + .should('not.exist'); }); it('should update browse list on successful submission', function() { diff --git a/swh/web/add_forge_now/views.py b/swh/web/add_forge_now/views.py --- a/swh/web/add_forge_now/views.py +++ b/swh/web/add_forge_now/views.py @@ -87,21 +87,41 @@ ] -def create_request(request): +def create_request_create(request): """View to create a new 'add_forge_now' request. """ return render( - request, "add_forge_now/create-request.html", {"forge_types": FORGE_TYPES}, + request, + "add_forge_now/create-request-create.html", + {"forge_types": FORGE_TYPES}, ) +def create_request_list(request): + """View to list existing 'add_forge_now' requests. + + """ + + return render(request, "add_forge_now/create-request-list.html",) + + +def create_request_help(request): + """View to explain 'add_forge_now'. + + """ + + return render(request, "add_forge_now/create-request-help.html",) + + urlpatterns = [ url( r"^add-forge/request/list/datatables/$", add_forge_request_list_datatables, name="add-forge-request-list-datatables", ), - url(r"^add-forge/request/create/$", create_request, name="forge-add"), + url(r"^add-forge/request/create/$", create_request_create, name="forge-add-create"), + url(r"^add-forge/request/list/$", create_request_list, name="forge-add-list"), + url(r"^add-forge/request/help/$", create_request_help, name="forge-add-help"), ] diff --git a/swh/web/templates/add_forge_now/create-request-create.html b/swh/web/templates/add_forge_now/create-request-create.html new file mode 100644 --- /dev/null +++ b/swh/web/templates/add_forge_now/create-request-create.html @@ -0,0 +1,116 @@ +{% extends "./create-request.html" %} + +{% comment %} +Copyright (C) 2022 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 %} + +{% block tab_content %} +
+ You must be logged in to submit an add forge request. Please + log in +
+ + {% else %} + + ++ Once an add-forge-request is submitted, its status can be viewed in + the + submitted requests list. This process involves a moderator approval and + might take a few days to handle (it primarily depends on the response + time from the forge). +
+ {% endif %} ++ For submitting an "Add forge now" request", you have to provide the following details: +
++ Once submitted, your "add forge" request can be in one + of the following states +
+Submission date | +Forge type | +Forge URL | +Status | +
---|
- You must be logged in to submit an add forge request. Please - log in -
- - {% else %} - - -- Once an add-forge-request is submitted, its status can be viewed in - the - submitted requests list. This process involves a moderator approval and - might take a few days to handle (it primarily depends on the response - time from the forge). -
- {% endif %} -Submission date | -Forge type | -Forge URL | -Status | -
---|
- For submitting an "Add forge now" request", you have to provide the following details: -
-- Once submitted, your "add forge" request can be in one - of the following states -
-Add forge now