diff --git a/dbrepo-ui/api/identifier.service.js b/dbrepo-ui/api/identifier.service.js index a7b739d8046b231d9ca07ca26ffd01adbfc9cdeb..51181e9c590de56c1d69856e6d61585848579281 100644 --- a/dbrepo-ui/api/identifier.service.js +++ b/dbrepo-ui/api/identifier.service.js @@ -53,6 +53,36 @@ class IdentifierService { }) }) } + + export (pid) { + return new Promise((resolve, reject) => { + api.get(`/api/pid/${pid}`, { headers: { Accept: 'text/xml' } }) + .then((response) => { + const identifier = response.data + console.debug('response identifier', identifier) + resolve(identifier) + }) + .catch((error) => { + const { code, message } = error + console.error('Failed to export identifier', error) + Vue.$toast.error(`[${code}] Failed to export identifier: ${message}`) + reject(error) + }) + }) + } + + delete (pid) { + return new Promise((resolve, reject) => { + api.delete(`/api/pid/${pid}`, { headers: { Accept: 'application/json' } }) + .then(() => resolve()) + .catch((error) => { + const { code, message } = error + console.error('Failed to delete identifier', error) + Vue.$toast.error(`[${code}] Failed to delete identifier: ${message}`) + reject(error) + }) + }) + } } export default new IdentifierService() diff --git a/dbrepo-ui/layouts/default.vue b/dbrepo-ui/layouts/default.vue index b455e8305160e98311b3e70ebb5e4aebaba098db..4745a933d7c218f5c6ced2589c51d727a5639d39 100644 --- a/dbrepo-ui/layouts/default.vue +++ b/dbrepo-ui/layouts/default.vue @@ -120,16 +120,12 @@ </template> <script> -import { isDeveloper } from '@/utils' import AuthenticationService from '@/api/authentication.service' import DatabaseService from '@/api/database.service' import TableService from '@/api/table.service' import IdentifierService from '@/api/identifier.service' export default { - name: 'DefaultLayout', - components: { - }, data () { return { drawer: false, @@ -146,8 +142,7 @@ export default { }, computed: { availableLocales () { - // return this.$i18n.locales.filter(i => i.code !== this.$i18n.locale) - return [] + return this.$i18n.locales.filter(i => i.code !== this.$i18n.locale) }, token () { return this.$store.state.token @@ -167,9 +162,6 @@ export default { database () { return this.$store.state.database }, - isDeveloper () { - return isDeveloper(this.user) - }, version () { return this.$config.version }, diff --git a/dbrepo-ui/test/e2e/database.js b/dbrepo-ui/test/e2e/database.js index 15a86e980b777905aa866d6162fd4976371905a2..22db30cb4cfdec7b4ef4a54c950a5db4a4f67b3d 100644 --- a/dbrepo-ui/test/e2e/database.js +++ b/dbrepo-ui/test/e2e/database.js @@ -6,7 +6,7 @@ test.before(before) test.after(after) test('databases_seeDatabases_succeeds', pageMacro, async (t, page) => { - await page.go('/container') + await page.go('/database') /* test */ const success = await page.waitForSelector('main >> header >> text=Databases') t.true(!!success, 'Failed to find \'Databases\' in page') @@ -15,7 +15,7 @@ test('databases_seeDatabases_succeeds', pageMacro, async (t, page) => { test('databases_createDatabase_succeeds', pageMacro, async (t, page) => { const state = { token: null, user: null, database: null, table: null, access: null } - await page.go('/container') + await page.go('/database') mutations.SET_TOKEN(state, 'ABC') mutations.SET_USER(state, { username: 'ava' }) await page.screenshot({ path: './screenshots/databases_createDatabase_succeeds.png' }) diff --git a/dbrepo-ui/utils/index.js b/dbrepo-ui/utils/index.js index fbf2e9b6b223f4fa9d7b089f6ca8879312dcfc6a..cc1ee56b61df97eb94ddaea8f6f577f7634fee6f 100644 --- a/dbrepo-ui/utils/index.js +++ b/dbrepo-ui/utils/index.js @@ -28,27 +28,6 @@ function isNonNegativeInteger (str) { return str >>> 0 === parseFloat(str) } -function isDeveloper (user) { - if (!user || !user.roles || user.roles.length === 0) { - return false - } - return user.roles.filter(a => a === 'ROLE_DEVELOPER').length === 1 -} - -function isResearcher (user) { - if (!user || !user.roles || user.roles.length === 0) { - return false - } - return user.roles.filter(a => a === 'ROLE_RESEARCHER').length === 1 -} - -function isDataSteward (user) { - if (!user || !user.roles || user.roles.length === 0) { - return false - } - return user.roles.filter(a => a === 'ROLE_DATA_STEWARD').length === 1 -} - function formatDateUTC (str) { if (str === null) { return null @@ -113,8 +92,5 @@ module.exports = { isNonNegativeInteger, formatYearUTC, formatMonthUTC, - formatDayUTC, - isDeveloper, - isResearcher, - isDataSteward + formatDayUTC }