X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/b7de31f185fccd2f9b276c1e89754d288e7facfe..f4012790be2404ce2f5b2594338fac43b1b9c59b:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index c74277e4..d801c5fa 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; + origin: string; } export const fetchConfig = () => { @@ -59,9 +62,10 @@ 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'` + config: {...response.data, vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json' }, + apiHost: config.API_HOST, }))); }; @@ -95,7 +99,7 @@ export const mockConfig = (config: Partial): Config => ({ packageVersion: '', parameters: {}, protocol: '', - remoteHosts: '', + remoteHosts: {}, remoteHostsViaDNS: false, resources: {}, revision: '', @@ -110,6 +114,7 @@ export const mockConfig = (config: Partial): Config => ({ websocketUrl: '', workbenchUrl: '', vocabularyUrl: '', + origin: '', ...config }); @@ -123,4 +128,5 @@ const getDefaultConfig = (): ConfigJSON => ({ VOCABULARY_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}`;