From 748c1377880459b66b6d84f483cc81e10f61dbf8 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 2 Nov 2021 15:22:02 -0300 Subject: [PATCH] 17944: Request the vocabulary exclusively from the new controller's endpoint. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- README.md | 7 - public/vocabulary-example.json | 213 ------------------ src/common/config.ts | 15 +- .../vocabulary-service/vocabulary-service.ts | 8 +- 4 files changed, 9 insertions(+), 234 deletions(-) delete mode 100644 public/vocabulary-example.json diff --git a/README.md b/README.md index 8bb50dbe..4ec4bd1c 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,6 @@ Currently this configuration schema is supported: ``` { "API_HOST": "string", - "VOCABULARY_URL": "string", "FILE_VIEWERS_CONFIG_URL": "string", } ``` @@ -93,12 +92,6 @@ The Arvados base URL. The `REACT_APP_ARVADOS_API_HOST` environment variable can be used to set the default URL if the run time configuration is unreachable. -### VOCABULARY_URL -Local path, or any URL that allows cross-origin requests. See -[Vocabulary JSON file example](public/vocabulary-example.json). - -To use the URL defined in the Arvados cluster configuration, remove the entire `VOCABULARY_URL` entry from the runtime configuration. Found in `/config.json` by default. - ## FILE_VIEWERS_CONFIG_URL Local path, or any URL that allows cross-origin requests. See: diff --git a/public/vocabulary-example.json b/public/vocabulary-example.json deleted file mode 100644 index 59d4de7a..00000000 --- a/public/vocabulary-example.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "strict_tags": false, - "tags": { - "IDTAGFRUITS": { - "strict": false, - "labels": [ - {"label": "Fruit"} - ], - "values": { - "IDVALFRUITS1": { - "labels": [ - {"label": "Pineapple"} - ] - }, - "IDVALFRUITS2": { - "labels": [ - {"label": "Tomato"} - ] - }, - "IDVALFRUITS3": { - "labels": [ - {"label": "Orange"} - ] - }, - "IDVALFRUITS4": { - "labels": [ - {"label": "Banana"} - ] - }, - "IDVALFRUITS5": { - "labels": [ - {"label": "Advocado"} - ] - }, - "IDVALFRUITS6": { - "labels": [ - {"label": "Lemon"} - ] - }, - "IDVALFRUITS7": { - "labels": [ - {"label": "Apple"} - ] - }, - "IDVALFRUITS8": { - "labels": [ - {"label": "Peach"} - ] - }, - "IDVALFRUITS9": { - "labels": [ - {"label": "Strawberry"} - ] - } - } - }, - "IDTAGANIMALS": { - "strict": false, - "labels": [ - {"label": "Animal" }, - {"label": "Creature"} - ], - "values": { - "IDVALANIMALS1": { - "labels": [ - {"label": "Human"}, - {"label": "Homo sapiens"} - ] - }, - "IDVALANIMALS2": { - "labels": [ - {"label": "Dog"}, - {"label": "Canis lupus familiaris"} - ] - }, - "IDVALANIMALS3": { - "labels": [ - {"label": "Elephant"}, - {"label": "Loxodonta"} - ] - }, - "IDVALANIMALS4": { - "labels": [ - {"label": "Eagle"}, - {"label": "Haliaeetus leucocephalus"} - ] - } - } - }, - "IDTAGCOLORS": { - "strict": false, - "labels": [ - {"label": "Color"} - ], - "values": { - "IDVALCOLORS1": { - "labels": [ - {"label": "Yellow"} - ] - }, - "IDVALCOLORS2": { - "labels": [ - {"label": "Red"} - ] - }, - "IDVALCOLORS3": { - "labels": [ - {"label": "Magenta"} - ] - }, - "IDVALCOLORS4": { - "labels": [ - {"label": "Green"} - ] - } - } - }, - "IDTAGCOMMENT": { - "labels": [ - {"label": "Comment"}, - {"label": "Text"} - ] - }, - "IDTAGCATEGORIES": { - "strict": true, - "labels": [ - {"label": "Category"} - ], - "values": { - "IDTAGCAT1": { - "labels": [ - {"label": "Experimental"} - ] - }, - "IDTAGCAT2": { - "labels": [ - {"label": "Development"} - ] - }, - "IDTAGCAT3": { - "labels": [ - {"label": "Production"} - ] - } - } - }, - "IDTAGIMPORTANCES": { - "strict": true, - "labels": [ - {"label": "Importance"}, - {"label": "Priority"} - ], - "values": { - "IDVALIMPORTANCES1": { - "labels": [ - {"label": "Critical"}, - {"label": "Urgent"}, - {"label": "High"} - ] - }, - "IDVALIMPORTANCES2": { - "labels": [ - {"label": "Normal"}, - {"label": "Moderate"} - ] - }, - "IDVALIMPORTANCES3": { - "labels": [ - {"label": "Low"} - ] - } - } - }, - "IDTAGSIZES": { - "strict": true, - "labels": [ - {"label": "Size"} - ], - "values": { - "IDVALSIZES1": { - "labels": [ - {"label": "XS"}, - {"label": "x-small"} - ] - }, - "IDVALSIZES2": { - "labels": [ - {"label": "S"}, - {"label": "small"} - ] - }, - "IDVALSIZES3": { - "labels": [ - {"label": "M"}, - {"label": "medium"} - ] - }, - "IDVALSIZES4": { - "labels": [ - {"label": "L"}, - {"label": "large"} - ] - }, - "IDVALSIZES5": { - "labels": [ - {"label": "XL"}, - {"label": "x-large"} - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/common/config.ts b/src/common/config.ts index 56f7c488..2518c95e 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -51,7 +51,6 @@ export interface ClusterConfigJSON { }; Workbench: { ArvadosDocsite: string; - VocabularyURL: string; FileViewersConfigURL: string; WelcomePageHTML: string; InactivePageHTML: string; @@ -204,15 +203,10 @@ remove the entire ${varName} entry from ${WORKBENCH_CONFIG_URL}`); } config.fileViewersConfigUrl = fileViewerConfigUrl; - let vocabularyUrl; if (workbenchConfig.VOCABULARY_URL !== undefined) { - warnLocalConfig("VOCABULARY_URL"); - vocabularyUrl = workbenchConfig.VOCABULARY_URL; + console.warn(`A value for VOCABULARY_URL was found in ${WORKBENCH_CONFIG_URL}. It will be ignored as the cluster already provides its own endpoint, you can safely remove it.`) } - else { - vocabularyUrl = config.clusterConfig.Workbench.VocabularyURL || "/vocabulary-example.json"; - } - config.vocabularyUrl = vocabularyUrl; + config.vocabularyUrl = getVocabularyURL(workbenchConfig.API_HOST); return { config, apiHost: workbenchConfig.API_HOST }; }); @@ -240,7 +234,6 @@ export const mockClusterConfigJSON = (config: Partial): Clust }, Workbench: { ArvadosDocsite: "", - VocabularyURL: "", FileViewersConfigURL: "", WelcomePageHTML: "", InactivePageHTML: "", @@ -315,5 +308,7 @@ const getDefaultConfig = (): WorkbenchConfig => { export const ARVADOS_API_PATH = "arvados/v1"; export const CLUSTER_CONFIG_PATH = "arvados/v1/config"; +export const VOCABULARY_PATH = "arvados/v1/vocabulary"; export const DISCOVERY_DOC_PATH = "discovery/v1/apis/arvados/v1/rest"; -export const getClusterConfigURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${CLUSTER_CONFIG_PATH}?nocache=${(new Date()).getTime()}`; +export const getClusterConfigURL = (apiHost: string) => `https://${apiHost}/${CLUSTER_CONFIG_PATH}?nocache=${(new Date()).getTime()}`; +export const getVocabularyURL = (apiHost: string) => `https://${apiHost}/${VOCABULARY_PATH}?nocache=${(new Date()).getTime()}`; diff --git a/src/services/vocabulary-service/vocabulary-service.ts b/src/services/vocabulary-service/vocabulary-service.ts index ff2de159..38163f77 100644 --- a/src/services/vocabulary-service/vocabulary-service.ts +++ b/src/services/vocabulary-service/vocabulary-service.ts @@ -10,9 +10,9 @@ export class VocabularyService { private url: string ) { } - getVocabulary() { - return Axios - .get(this.url) - .then(response => response.data); + async getVocabulary() { + const response = await Axios + .get(this.url); + return response.data; } } -- 2.30.2