X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/85c93508dc959ca5491998283565a8e125a56a86..4b961d16b8f8ef8afbd13697a79fe4684acd0416:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index c74277e4..3961d5aa 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -35,7 +35,9 @@ export interface Config { packageVersion: string; parameters: {}; protocol: string; - remoteHosts: string; + remoteHosts: { + [key: string]: string + }; remoteHostsViaDNS: boolean; resources: {}; revision: string; @@ -50,6 +52,7 @@ export interface Config { websocketUrl: string; workbenchUrl: string; vocabularyUrl: string; + fileViewersConfigUrl: string; } export const fetchConfig = () => { @@ -59,9 +62,15 @@ export const fetchConfig = () => { .catch(() => Promise.resolve(getDefaultConfig())) .then(config => Axios .get(getDiscoveryURL(config.API_HOST)) - .then(response => ({ - config: {...response.data, vocabularyUrl: config.VOCABULARY_URL }, - apiHost: config.API_HOST, + .then(response => ({ + // TODO: After tests delete `|| '/vocabulary-example.json'` + // TODO: After tests delete `|| '/file-viewers-example.json'` + config: { + ...response.data, + vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json', + fileViewersConfigUrl: config.FILE_VIEWERS_CONFIG_URL || '/file-viewers-example.json' + }, + apiHost: config.API_HOST, }))); }; @@ -95,7 +104,7 @@ export const mockConfig = (config: Partial): Config => ({ packageVersion: '', parameters: {}, protocol: '', - remoteHosts: '', + remoteHosts: {}, remoteHostsViaDNS: false, resources: {}, revision: '', @@ -110,17 +119,21 @@ export const mockConfig = (config: Partial): Config => ({ websocketUrl: '', workbenchUrl: '', vocabularyUrl: '', + fileViewersConfigUrl: '', ...config }); interface ConfigJSON { API_HOST: string; VOCABULARY_URL: string; + FILE_VIEWERS_CONFIG_URL: string; } const getDefaultConfig = (): ConfigJSON => ({ API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "", VOCABULARY_URL: "", + FILE_VIEWERS_CONFIG_URL: "", }); -const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/discovery/v1/apis/arvados/v1/rest`; +export const DISCOVERY_URL = 'discovery/v1/apis/arvados/v1/rest'; +const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}`;