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 %} +
+ {% if not user.is_authenticated %} +

+

+ You must be logged in to submit an add forge request. Please + log in +

+

+ {% else %} + +
+ {% csrf_token %} +
+
+ + + + Supported forge types in software archive. + +
+ +
+ + + + Remote URL of the forge. + +
+
+ +
+
+ + + + Name of the forge administrator. + +
+ +
+ + + + Email of the forge administrator. The given email address will not be used for any purpose outside the “add forge now” process. + +
+
+ +
+
+ + +
+
+ +
+
+ + + + Optionally, leave a comment to the moderator regarding your request. + +
+
+ +
+
+ +
+
+ +
+
+

+ +

+

+ +

+
+
+
+

+ 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 %} +
+{% endblock %} diff --git a/swh/web/templates/add_forge_now/create-request-help.html b/swh/web/templates/add_forge_now/create-request-help.html new file mode 100644 --- /dev/null +++ b/swh/web/templates/add_forge_now/create-request-help.html @@ -0,0 +1,89 @@ +{% 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 %} +
+

+ 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 +

+ +
+{% endblock %} diff --git a/swh/web/templates/add_forge_now/create-request-list.html b/swh/web/templates/add_forge_now/create-request-list.html new file mode 100644 --- /dev/null +++ b/swh/web/templates/add_forge_now/create-request-list.html @@ -0,0 +1,24 @@ +{% 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 %} +
+ + + + + + + + + +
Submission dateForge typeForge URLStatus
+
+
+{% endblock %} diff --git a/swh/web/templates/add_forge_now/create-request.html b/swh/web/templates/add_forge_now/create-request.html --- a/swh/web/templates/add_forge_now/create-request.html +++ b/swh/web/templates/add_forge_now/create-request.html @@ -43,208 +43,14 @@
-
- {% if not user.is_authenticated %} -

-

- You must be logged in to submit an add forge request. Please - log in -

-

- {% else %} - -
- {% csrf_token %} -
-
- - - - Supported forge types in software archive. - -
- -
- - - - Remote URL of the forge. - -
-
- -
-
- - - - Name of the forge administrator. - -
- -
- - - - Email of the forge administrator. The given email address will not be used for any purpose outside the “add forge now” process. - -
-
- -
-
- - -
-
- -
-
- - - - Optionally, leave a comment to the moderator regarding your request. - -
-
- -
-
- -
-
- -
-
-

- -

-

- -

-
-
-
-

- 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 dateForge typeForge URLStatus
-
-
-
-

- For submitting an "Add forge now" request", you have to provide the following details: -

-
    -
  • Forge type:Type of the forge you would like to add. - Supported forge types in software heritage currently are: -
      -
    • cgit, for cgit forges
    • -
    • gitea, for gitea forges
    • -
    • gitlab, for gitlab forges
    • -
    • heptapod, for heptapod forges
    • - ... -
    -
  • -
  • Forge url:The URL of the selected forge. This must be unique. -
  • -
  • Forge contact name:Contact name of the forge administrator -
  • -
  • Forge contact email:Contact email of the forge administrator. An email - will be sent to the given address to notify about the request. -
  • -
  • Consent checkbox: This checkbox's purpose is to know whether we can - explicitly mention the user's login within the email sent to the forge. If - not checked, the user's name won't be mentioned in the email at all. -
  • -
  • Comment: (Optionally) For the user to mention something more about - their request to the add-forge-now moderator. -
  • -
-

- Once submitted, your "add forge" request can be in one - of the following states -

-
    -
  • - Pending: - The request was submitted and is waiting for a moderator - to validate -
  • - -
  • - Waiting for feedback: - The request was processed by a moderator and the forge was contacted. -
  • - -
  • - Feedback to handle: - The forge has responded to the request and - there is feedback to handle for the request. -
  • -
  • - Accepted: - The request has been accepted. -
  • - -
  • - Scheduled: - The requested forge listing has been scheduled. -
  • - -
  • - First listing done: - The first listing of the requested forge has been completed -
  • - -
  • - First origin loaded: - The first repositories (or origins) from the requested forge have been loaded and archived. -
  • - -
  • Rejected:The request is invalid. It is rejected by a moderator with an explanation.
  • - -
  • Denied:The forge administrator(s) denied the request to list their forge.
  • - -
  • Suspended:The forge listing is not supported yet.
  • -
-
+ {% block tab_content %} + {% endblock %}
diff --git a/swh/web/templates/layout.html b/swh/web/templates/layout.html --- a/swh/web/templates/layout.html +++ b/swh/web/templates/layout.html @@ -211,7 +211,7 @@ {% if FEATURES.add_forge_now %}