Page MenuHomeSoftware Heritage

D3364.id.diff
No OneTemporary

D3364.id.diff

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 =
+ '<button class="btn btn-default btn-sm swh-save-origin-again" type="button" ' +
+ `onclick="swh.save.fillSaveRequestFormAndScroll(` +
+ `'${row.visit_type}', '${row.origin_url}');">` +
+ '<i class="mdi mdi-camera mdi-fw" aria-hidden="true"></i>' +
+ 'Save again</button>';
+ 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 @@
<div class="form-row">
<div class="col-md-1"></div>
<div class="form-group col-md-2">
- <label for="swh-input-visit-type">Visit type</label>
+ <label for="swh-input-visit-type">Origin type</label>
<select id="swh-input-visit-type" class="form-control" required>
{% comment %} <option selected value="">Choose...</option> {% endcomment %}
</select>
- <div class="invalid-feedback">The visit type must be specified</div>
+ <div class="invalid-feedback">The origin type must be specified</div>
</div>
<div class="form-group col-md-6">
<label for="swh-input-origin-url">Origin url</label>
@@ -67,7 +67,7 @@
<div id="swh-origin-save-requests-create" class="tab-pane active">
<p style="margin-top: 1rem;">A "Save code now" request takes the following parameters:</p>
<ul>
- <li><b>Visit type:</b> the type of version control system the software origin is using.
+ <li><b>Origin type:</b> the type of version control system the software origin is using.
Currently, the supported types are:
<ul>
<li><code>git</code>, for origins using <a href="https://git-scm.com/">Git</a></li>
@@ -110,6 +110,7 @@
<th data-priority="5">Request</th>
<th data-priority="2">Status</th>
<th data-priority="6">Info</th>
+ <th data-priority="7"></th>
</tr>
</thead>
</table>

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 2, 11:57 AM (4 d, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216437

Event Timeline