diff --git a/assets/src/bundles/admin/deposit.js b/assets/src/bundles/admin/deposit.js --- a/assets/src/bundles/admin/deposit.js +++ b/assets/src/bundles/admin/deposit.js @@ -7,19 +7,29 @@ import {getHumanReadableDate} from 'utils/functions'; -function genSwhLink(data, type) { +function genSwhLink(data, type, linkText = '') { if (type === 'display' && data && data.startsWith('swh')) { const browseUrl = Urls.browse_swhid(data); const formattedSWHID = data.replace(/;/g, ';
'); - return `${formattedSWHID}`; + if (!linkText) { + linkText = formattedSWHID; + } + return `${linkText}`; } return data; } -function genLink(data, type) { +function genLink(data, type, openInNewTab = false, linkText = '') { if (type === 'display' && data) { const sData = encodeURI(data); - return `${sData}`; + if (!linkText) { + linkText = sData; + } + let attrs = ''; + if (openInNewTab) { + attrs = 'target="_blank" rel="noopener noreferrer"'; + } + return `${linkText}`; } return data; } @@ -70,7 +80,19 @@ data: 'uri', name: 'uri', render: (data, type, row) => { - return genLink(data, type); + const sanitizedURL = $.fn.dataTable.render.text().display(data); + let swhLink = ''; + let originLink = ''; + if (row.swhid_context && data) { + swhLink = genSwhLink(row.swhid_context, type, sanitizedURL); + } else if (data) { + swhLink = sanitizedURL; + } + if (data) { + originLink = genLink(sanitizedURL, type, true, + ''); + } + return swhLink + ' ' + originLink; } }, { @@ -88,7 +110,7 @@ render: (data, type, row) => { if (type === 'display') { if (row.raw_metadata) { - return ``; + return ``; } } return data; diff --git a/cypress/integration/deposit-admin.spec.js b/cypress/integration/deposit-admin.spec.js --- a/cypress/integration/deposit-admin.spec.js +++ b/cypress/integration/deposit-admin.spec.js @@ -11,6 +11,8 @@ let depositModerationUrl; let depositListUrl; +const $ = Cypress.$; + describe('Test moderation deposit Login/logout', function() { before(function() { depositModerationUrl = this.Urls.admin_deposit(); @@ -135,6 +137,7 @@ // only 2 entries cy.get('@rows').each((row, idx, collection) => { + const cells = row[0].cells; const deposit = deposits[idx]; const responseDeposit = testDeposits[idx]; assert.isNotNull(deposit); @@ -156,6 +159,15 @@ cy.contains(expectedOrigin).should('be.visible'); } + if (deposit.uri && deposit.swhid_context) { + let html = `${deposit.uri}`; + html += ` `; + html += ''; + expect($(cells[2]).html()).to.contain(html); + } else if (!deposit.uri) { + expect($(cells[2]).text().trim()).to.equal(''); + } + cy.contains(deposit.status).should('be.visible'); // those are hidden by default, so now visible if (deposit.status_detail !== null) { @@ -171,6 +183,7 @@ if (deposit.raw_metadata !== null) { cy.get('button.metadata', {withinSubject: row}) .should('exist') + .should('have.text', 'display') .click({force: true}); cy.get('#swh-web-modal-html code.xml').should('be.visible');