Merge branch '17229-integrate-webshell' into main. Closes #17229
[arvados-workbench2.git] / src / common / config.ts
index 55e99e010451646c236d18c9c487b26aca72a1ef..56f7c4884b19542ee057b937b5ff420809477a9e 100644 (file)
@@ -89,6 +89,14 @@ export interface ClusterConfigJSON {
                 Value: string,
                 Protected?: boolean,
             }
+        },
+        TrustAllContent: boolean
+    };
+    Volumes: {
+        [key: string]: {
+            StorageClasses: {
+                [key: string]: boolean;
+            }
         }
     };
 }
@@ -130,6 +138,19 @@ export const buildConfig = (clusterConfig: ClusterConfigJSON): Config => {
     return config;
 };
 
+export const getStorageClasses = (config: Config): string[] => {
+    const classes: Set<string> = new Set(['default']);
+    const volumes = config.clusterConfig.Volumes;
+    Object.keys(volumes).forEach(v => {
+        Object.keys(volumes[v].StorageClasses || {}).forEach(sc => {
+            if (volumes[v].StorageClasses[sc]) {
+                classes.add(sc);
+            }
+        });
+    });
+    return Array.from(classes);
+};
+
 const getApiRevision = async (apiUrl: string) => {
     try {
         const dd = (await Axios.get<any>(`${apiUrl}/${DISCOVERY_DOC_PATH}`)).data;
@@ -142,7 +163,7 @@ const getApiRevision = async (apiUrl: string) => {
 
 const removeTrailingSlashes = (config: ClusterConfigJSON): ClusterConfigJSON => {
     const svcs: any = {};
-    Object.keys(config.Services).map((s) => {
+    Object.keys(config.Services).forEach((s) => {
         svcs[s] = config.Services[s];
         if (svcs[s].hasOwnProperty('ExternalURL')) {
             svcs[s].ExternalURL = svcs[s].ExternalURL.replace(/\/+$/, '');
@@ -251,7 +272,9 @@ export const mockClusterConfigJSON = (config: Partial<ClusterConfigJSON>): Clust
     },
     Collections: {
         ForwardSlashNameSubstitution: "",
+        TrustAllContent: false,
     },
+    Volumes: {},
     ...config
 });