diff --git a/src/components/RegistryInfo.vue b/src/components/RegistryInfo.vue index 43019e92..fbe75221 100644 --- a/src/components/RegistryInfo.vue +++ b/src/components/RegistryInfo.vue @@ -12,7 +12,7 @@ :class="{ 'fontWeight-heavy': $store.state.settings.settings.mappingBrowserShowRegistry[registry.uri] !== false }"> - {{ $jskos.prefLabel(registry, { language: locale }) }} + {{ registryName }} import RegistryNotation from "./RegistryNotation.vue" +import { getRegistryName } from "@/utils" // Import mixins import auth from "../mixins/auth.js" @@ -104,6 +105,11 @@ export default { default: false, }, }, + computed: { + registryName() { + return getRegistryName({ registry: this.registry, locale: this.locale }) + }, + }, } diff --git a/src/components/RegistryName.vue b/src/components/RegistryName.vue index ba4c42b2..40b21fd4 100644 --- a/src/components/RegistryName.vue +++ b/src/components/RegistryName.vue @@ -6,6 +6,7 @@ diff --git a/src/utils/index.js b/src/utils/index.js new file mode 100644 index 00000000..a14757c1 --- /dev/null +++ b/src/utils/index.js @@ -0,0 +1,28 @@ +import _ from "lodash" +import jskos from "jskos-tools" + +export function getRegistryName({ registry, locale }) { + if (!registry) { + return "" + } + let label = jskos.prefLabel(registry, { language: locale, fallbackToUri: false }) + if (label) { + return label + } + // Try _config (i.e. result of /status endpoint) + label = _.get(registry, "_config.title") + if (label) { + const baseUrl = _.get(registry, "_config.baseUrl") + return baseUrl ? `${label} (${baseUrl})` : label + } + // Try URI + if (registry.uri) { + return registry.uri + } + // Try API URL + label = _.get(registry, "_api.api") + if (label) { + return label + } + return "" +}