X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/4ea2ff188ec745966387ce8bbe14880bfeede863..0209f5e7f2ec688f545f5025bafee2f2ea90a71b:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index c74277e4..71b7774c 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,7 +51,9 @@ export interface Config { version: string; websocketUrl: string; workbenchUrl: string; + workbench2Url?: string; vocabularyUrl: string; + fileViewersConfigUrl: string; } export const fetchConfig = () => { @@ -59,9 +63,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 +105,7 @@ export const mockConfig = (config: Partial): Config => ({ packageVersion: '', parameters: {}, protocol: '', - remoteHosts: '', + remoteHosts: {}, remoteHostsViaDNS: false, resources: {}, revision: '', @@ -110,17 +120,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'; +export const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}?nocache=${(new Date()).getTime()}`;