Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/admin/deposit.js
/** | /** | ||||
* Copyright (C) 2018-2019 The Software Heritage developers | * Copyright (C) 2018-2020 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
function genSwhLink(data, type) { | function genSwhLink(data, type) { | ||||
if (type === 'display') { | if (type === 'display') { | ||||
if (data && data.startsWith('swh')) { | if (data && data.startsWith('swh')) { | ||||
Show All 24 Lines | depositsTable = $('#swh-admin-deposit-list') | ||||
data: 'swh_id_context', | data: 'swh_id_context', | ||||
name: 'swh_id_context', | name: 'swh_id_context', | ||||
render: (data, type, row) => { | render: (data, type, row) => { | ||||
if (data && type === 'display') { | if (data && type === 'display') { | ||||
let originPattern = ';origin='; | let originPattern = ';origin='; | ||||
let originPatternIdx = data.indexOf(originPattern); | let originPatternIdx = data.indexOf(originPattern); | ||||
if (originPatternIdx !== -1) { | if (originPatternIdx !== -1) { | ||||
let originUrl = data.slice(originPatternIdx + originPattern.length); | let originUrl = data.slice(originPatternIdx + originPattern.length); | ||||
let nextSepPattern = ';'; | |||||
let nextSepPatternIdx = originUrl.indexOf(nextSepPattern); | |||||
if (nextSepPatternIdx !== -1) { /* Remove extra context */ | |||||
originUrl = originUrl.slice(0, nextSepPatternIdx); | |||||
} | |||||
return `<a href="${originUrl}">${originUrl}</a>`; | return `<a href="${originUrl}">${originUrl}</a>`; | ||||
} | } | ||||
rdicosmo: This is kind of fragile, as it assumes that the visit qualifiers will appear immediately after… | |||||
Done Inline Actionsfragile, indeed. I will adapt accordingly. What'd be even greater is to test this and actually add the relevant tests. ardumont: fragile, indeed.
I like this approach better. Thanks.
I will adapt accordingly.
What'd be… | |||||
} | } | ||||
return data; | return data; | ||||
} | } | ||||
}, | }, | ||||
{ | { | ||||
data: 'reception_date', | data: 'reception_date', | ||||
name: 'reception_date', | name: 'reception_date', | ||||
render: (data, type, row) => { | render: (data, type, row) => { | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |
This is kind of fragile, as it assumes that the visit qualifiers will appear immediately after the origin qualifier.
It would be better to do something like: