diff --git a/cypress/fixtures/origin-save.json b/cypress/fixtures/origin-save.json
new file mode 100644
--- /dev/null
+++ b/cypress/fixtures/origin-save.json
@@ -0,0 +1,86 @@
+{
+ "recordsTotal": 6839,
+ "draw": 2,
+ "recordsFiltered": 6839,
+ "data": [{
+ "id": 6869,
+ "visit_type": "git",
+ "origin_url": "https://gitlab.inria.fr/solverstack/maphys/maphys/",
+ "save_request_date": "2020-03-25T15:57:21.725886+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "succeed",
+ "visit_date": "2020-03-25T16:23:15.309379+00:00"
+ }, {
+ "id": 6868,
+ "visit_type": "git",
+ "origin_url": "https://github.com/orthecreedence/cl-async.git",
+ "save_request_date": "2020-01-17T09:39:55.930715+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "succeed",
+ "visit_date": "2020-01-17T09:47:20.992279+00:00"
+ }, {
+ "id": 6867,
+ "visit_type": "git",
+ "origin_url": "https://forge.frm2.tum.de/cgit/cgit.cgi/frm2/mira/takin-data.git/",
+ "save_request_date": "2020-01-17T07:16:54.421290+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "failed",
+ "visit_date": "2020-01-17T07:46:35.223112+00:00"
+ }, {
+ "id": 6866,
+ "visit_type": "git",
+ "origin_url": "https://forge.frm2.tum.de/cgit/cgit.cgi/frm2/mira/mcstas.git/",
+ "save_request_date": "2020-01-17T07:16:43.411145+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "failed",
+ "visit_date": "2020-01-17T07:46:32.710716+00:00"
+ }, {
+ "id": 6865,
+ "visit_type": "git",
+ "origin_url": "https://forge.frm2.tum.de/cgit/cgit.cgi/frm2/mira/miezetools.git/",
+ "save_request_date": "2020-01-17T07:16:31.085132+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "failed",
+ "visit_date": "2020-01-17T07:46:32.634520+00:00"
+ }, {
+ "id": 6864,
+ "visit_type": "git",
+ "origin_url": "https://forge.frm2.tum.de/cgit/cgit.cgi/frm2/mira/tlibs.git/",
+ "save_request_date": "2020-01-17T07:16:21.708408+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "failed",
+ "visit_date": "2020-01-17T07:46:32.542717+00:00"
+ }, {
+ "id": 6863,
+ "visit_type": "git",
+ "origin_url": "https://forge.frm2.tum.de/cgit/cgit.cgi/frm2/mira/tastools.git/",
+ "save_request_date": "2020-01-17T07:15:58.076850+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "failed",
+ "visit_date": "2020-01-17T07:46:32.226750+00:00"
+ }, {
+ "id": 6862,
+ "visit_type": "git",
+ "origin_url": "https://github.com/openfun/flower-docker",
+ "save_request_date": "2020-01-16T15:26:05.406086+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "succeed",
+ "visit_date": "2020-01-16T15:47:50.200655+00:00"
+ }, {
+ "id": 6861,
+ "visit_type": "git",
+ "origin_url": "https://gitlab.inria.fr/dsi_public/depots_officiels_inria_gitlab",
+ "save_request_date": "2020-01-16T11:27:26.916797+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "succeed",
+ "visit_date": "2020-01-16T11:44:01.715665+00:00"
+ }, {
+ "id": 6860,
+ "visit_type": "git",
+ "origin_url": "https://github.com/SocialGouv/cdtn-run",
+ "save_request_date": "2020-01-16T11:23:24.933159+00:00",
+ "save_request_status": "accepted",
+ "save_task_status": "succeed",
+ "visit_date": "2020-01-16T11:39:50.882730+00:00"
+ }]
+}
\ No newline at end of file
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
@@ -7,6 +7,7 @@
let url;
let origin;
+const $ = Cypress.$;
const saveCodeMsg = {
'success': 'The "save code now" request has been accepted and will be processed as soon as possible.',
@@ -157,4 +158,35 @@
});
});
+ it('should display origin save info in the requests table', function() {
+ cy.fixture('origin-save').then(originSaveJSON => {
+ cy.route('GET', '/save/requests/list/**', originSaveJSON);
+ cy.get('#swh-origin-save-requests-list-tab').click();
+ cy.get('tbody tr').then(rows => {
+ let i = 0;
+ for (let row of rows) {
+ const cells = row.cells;
+ const requestDateStr = new Date(originSaveJSON.data[i].save_request_date).toLocaleString();
+ const saveStatus = originSaveJSON.data[i].save_task_status;
+ assert.equal($(cells[0]).text(), requestDateStr);
+ assert.equal($(cells[1]).text(), originSaveJSON.data[i].visit_type);
+ let html = '';
+ if (saveStatus === 'succeed') {
+ let browseOriginUrl = `${this.Urls.browse_origin()}?origin_url=${originSaveJSON.data[i].origin_url}`;
+ browseOriginUrl += `×tamp=${originSaveJSON.data[i].visit_date}`;
+ html += `${originSaveJSON.data[i].origin_url}`;
+ } else {
+ html += originSaveJSON.data[i].origin_url;
+ }
+ html += ` `;
+ html += '';
+ assert.equal($(cells[2]).html(), html);
+ assert.equal($(cells[3]).text(), originSaveJSON.data[i].save_request_status);
+ assert.equal($(cells[4]).text(), saveStatus);
+ ++i;
+ }
+ });
+ });
+ });
+
});
diff --git a/swh/web/assets/src/bundles/admin/origin-save.js b/swh/web/assets/src/bundles/admin/origin-save.js
--- a/swh/web/assets/src/bundles/admin/origin-save.js
+++ b/swh/web/assets/src/bundles/admin/origin-save.js
@@ -81,8 +81,17 @@
name: 'origin_url',
render: (data, type, row) => {
if (type === 'display') {
+ let html = '';
const sanitizedURL = $.fn.dataTable.render.text().display(data);
- return `${sanitizedURL}`;
+ if (row.save_task_status === 'succeed') {
+ let browseOriginUrl = `${Urls.browse_origin()}?origin_url=${sanitizedURL}`;
+ browseOriginUrl += `×tamp=${row.visit_date}`;
+ html += `${sanitizedURL}`;
+ } else {
+ html += sanitizedURL;
+ }
+ html += ` `;
+ return html;
}
return data;
}
@@ -133,15 +142,7 @@
columnsData.push({
data: 'save_task_status',
- name: 'save_task_status',
- render: (data, type, row) => {
- if (data === 'succeed' && row.visit_date) {
- let browseOriginUrl = `${Urls.browse_origin()}?origin_url=${row.origin_url}`;
- browseOriginUrl += `×tamp=${row.visit_date}`;
- return `${data}`;
- }
- return data;
- }
+ name: 'save_task_status'
});
columnsData.push({
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
@@ -86,8 +86,17 @@
name: 'origin_url',
render: (data, type, row) => {
if (type === 'display') {
+ let html = '';
const sanitizedURL = $.fn.dataTable.render.text().display(data);
- return `${sanitizedURL}`;
+ if (row.save_task_status === 'succeed') {
+ let browseOriginUrl = `${Urls.browse_origin()}?origin_url=${sanitizedURL}`;
+ browseOriginUrl += `×tamp=${row.visit_date}`;
+ html += `${sanitizedURL}`;
+ } else {
+ html += sanitizedURL;
+ }
+ html += ` `;
+ return html;
}
return data;
}
@@ -98,15 +107,7 @@
},
{
data: 'save_task_status',
- name: 'loading_task_status',
- render: (data, type, row) => {
- if (data === 'succeed' && row.visit_date) {
- let browseOriginUrl = `${Urls.browse_origin()}?origin_url=${row.origin_url}`;
- browseOriginUrl += `×tamp=${row.visit_date}`;
- return `${data}`;
- }
- return data;
- }
+ name: 'loading_task_status'
}
],
scrollY: '50vh',