X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c324b64f3b26e79b4640b6f0cf55671f1a261bca..f9dde5c781766b8be71d43d0f031c201a0edcfbb:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index 1ab73294..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; @@ -49,6 +51,8 @@ export interface Config { version: string; websocketUrl: string; workbenchUrl: string; + vocabularyUrl: string; + fileViewersConfigUrl: string; } export const fetchConfig = () => { @@ -58,7 +62,16 @@ export const fetchConfig = () => { .catch(() => Promise.resolve(getDefaultConfig())) .then(config => Axios .get(getDiscoveryURL(config.API_HOST)) - .then(response => ({ config: response.data, 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, + }))); }; @@ -91,7 +104,7 @@ export const mockConfig = (config: Partial): Config => ({ packageVersion: '', parameters: {}, protocol: '', - remoteHosts: '', + remoteHosts: {}, remoteHostsViaDNS: false, resources: {}, revision: '', @@ -105,15 +118,22 @@ export const mockConfig = (config: Partial): Config => ({ version: '', 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}`;