14813: wb2 uses cluster config
[arvados-workbench2.git] / src / store / auth / auth-action.ts
index 1d1ad18cbd8c985218fc7aa433b04056d76d031d..6356eaa8bdc9e5b8771feacb7ea2c26241842002 100644 (file)
@@ -10,7 +10,7 @@ import { ServiceRepository } from "~/services/services";
 import { SshKeyResource } from '~/models/ssh-key';
 import { User, UserResource } from "~/models/user";
 import { Session } from "~/models/session";
-import { getDiscoveryURL, Config } from '~/common/config';
+import { getClusterConfigURL, Config, ClusterConfigJSON, mapRemoteHosts } from '~/common/config';
 import { initSessions } from "~/store/auth/auth-action-session";
 import { cancelLinking } from '~/store/link-account-panel/link-account-panel-actions';
 import { matchTokenRoute, matchFedTokenRoute } from '~/routes/routes';
@@ -88,8 +88,13 @@ const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState,
         });
     }
     Object.keys(config.remoteHosts).map((k) => {
-        Axios.get<Config>(getDiscoveryURL(config.remoteHosts[k]))
-            .then(response => dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: response.data })));
+        Axios.get<ClusterConfigJSON>(getClusterConfigURL(config.remoteHosts[k]))
+            .then(response => {
+                const remoteConfig = new Config();
+                remoteConfig.workbench2Url = response.data.Services.Workbench2.ExternalURL;
+                mapRemoteHosts(response.data, remoteConfig);
+                dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: remoteConfig}));
+            });
     });
 };