diff --git a/cypress/integration/origin-save.spec.js b/cypress/integration/origin-save.spec.js --- a/cypress/integration/origin-save.spec.js +++ b/cypress/integration/origin-save.spec.js @@ -231,4 +231,21 @@ .should('not.be.visible'); }); + it('should fill save request form when clicking on "Save again" button', function() { + cy.fixture('origin-save').as('originSaveJSON'); + cy.route('GET', '/save/requests/list/**', '@originSaveJSON'); + + cy.get('#swh-origin-save-requests-list-tab').click(); + cy.get('.swh-save-origin-again') + .eq(0) + .click(); + + cy.get('tbody tr').eq(0).then(row => { + const cells = row[0].cells; + cy.get('#swh-input-visit-type') + .should('have.value', $(cells[1]).text()); + cy.get('#swh-input-origin-url') + .should('have.value', $(cells[2]).text().slice(0, -1)); + }); + }); }); diff --git a/swh/web/assets/src/bundles/save/index.js b/swh/web/assets/src/bundles/save/index.js --- a/swh/web/assets/src/bundles/save/index.js +++ b/swh/web/assets/src/bundles/save/index.js @@ -120,6 +120,19 @@ return ''; } } + }, + { + render: (data, type, row) => { + if (row.save_request_status === 'accepted') { + const saveAgainButton = + ''; + return saveAgainButton; + } + } } ], scrollY: '50vh', @@ -431,3 +444,14 @@ $(event.target).popover('update'); }); } + +export function fillSaveRequestFormAndScroll(visitType, originUrl) { + $('#swh-input-visit-type option').each(function() { + let val = $(this).val(); + if (val === visitType) { + $(this).prop('selected', true); + } + }); + $('#swh-input-origin-url').val(originUrl); + window.scrollTo(0, 0); +} diff --git a/swh/web/templates/misc/origin-save.html b/swh/web/templates/misc/origin-save.html --- a/swh/web/templates/misc/origin-save.html +++ b/swh/web/templates/misc/origin-save.html @@ -32,11 +32,11 @@
- + -
The visit type must be specified
+
The origin type must be specified
@@ -67,7 +67,7 @@

A "Save code now" request takes the following parameters:

    -
  • Visit type: the type of version control system the software origin is using. +
  • Origin type: the type of version control system the software origin is using. Currently, the supported types are:
    • git, for origins using Git
    • @@ -110,6 +110,7 @@ Request Status Info +