15530: Set homeCluster to LoginCluster
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Tue, 24 Sep 2019 14:58:13 +0000 (10:58 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Tue, 24 Sep 2019 14:58:13 +0000 (10:58 -0400)
src/common/config.ts
src/store/auth/auth-action.ts
src/store/auth/auth-reducer.ts
src/views/login-panel/login-panel.tsx

index 496b0b78891b3657d7119abc0116b2ec1780ed91..3dc34ce510411c67c4e6afc623a7f193c95c8357 100644 (file)
@@ -45,6 +45,9 @@ export interface ClusterConfigJSON {
         VocabularyURL: string;
         FileViewersConfigURL: string;
     };
+    Login: {
+        LoginCluster: string;
+    };
 }
 
 export class Config {
@@ -60,6 +63,7 @@ export class Config {
     workbench2Url: string;
     vocabularyUrl: string;
     fileViewersConfigUrl: string;
+    loginCluster: string;
 }
 
 export const fetchConfig = () => {
@@ -111,6 +115,7 @@ remove the entire ${varName} entry from ${WORKBENCH_CONFIG_URL}`);
                 config.workbench2Url = clusterConfigJSON.Services.Workbench2.ExternalURL;
                 config.workbenchUrl = clusterConfigJSON.Services.Workbench1.ExternalURL;
                 config.keepWebServiceUrl = clusterConfigJSON.Services.WebDAV.ExternalURL;
+                config.loginCluster = clusterConfigJSON.Login.LoginCluster;
                 mapRemoteHosts(clusterConfigJSON, config);
 
                 return { config, apiHost: workbenchConfig.API_HOST };
@@ -135,7 +140,8 @@ export const mockConfig = (config: Partial<Config>): Config => ({
     workbenchUrl: "",
     workbench2Url: "",
     vocabularyUrl: "",
-    fileViewersConfigUrl: ""
+    fileViewersConfigUrl: "",
+    loginCluster: ""
 });
 
 const getDefaultConfig = (): WorkbenchConfig => {
@@ -157,4 +163,4 @@ const getDefaultConfig = (): WorkbenchConfig => {
 
 export const ARVADOS_API_PATH = "arvados/v1";
 export const CLUSTER_CONFIG_URL = "arvados/v1/config";
-export const getClusterConfigURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${CLUSTER_CONFIG_URL}?nocache=${(new Date()).getTime()}`;
\ No newline at end of file
+export const getClusterConfigURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${CLUSTER_CONFIG_URL}?nocache=${(new Date()).getTime()}`;
index b889adf571113494f32fee49843ebeabe527f5a9..4a4710deaf3c7598fe3ccc6abcbb4245bc4f017a 100644 (file)
@@ -72,7 +72,7 @@ const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState,
         setAuthorizationHeader(services, token);
     }
     dispatch(authActions.CONFIG({ config }));
-    dispatch(authActions.SET_HOME_CLUSTER(homeCluster || config.uuidPrefix));
+    dispatch(authActions.SET_HOME_CLUSTER(config.loginCluster || homeCluster || config.uuidPrefix));
     if (token && user) {
         dispatch(authActions.INIT({ user, token }));
         dispatch<any>(initSessions(services.authService, config, user));
@@ -94,7 +94,7 @@ const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState,
                 remoteConfig.uuidPrefix = response.data.ClusterID;
                 remoteConfig.workbench2Url = response.data.Services.Workbench2.ExternalURL;
                 mapRemoteHosts(response.data, remoteConfig);
-                dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: remoteConfig}));
+                dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: remoteConfig }));
             });
     });
 };
index cded9f0e71816636ce1876d51c83d3976abb589c..b4e73e1eb42d1b16c2241343f93b93cb28fbba0a 100644 (file)
@@ -16,6 +16,7 @@ export interface AuthState {
     sessions: Session[];
     localCluster: string;
     homeCluster: string;
+    loginCluster: string;
     remoteHosts: { [key: string]: string };
     remoteHostsConfig: { [key: string]: Config };
 }
@@ -27,6 +28,7 @@ const initialState: AuthState = {
     sessions: [],
     localCluster: "",
     homeCluster: "",
+    loginCluster: "",
     remoteHosts: {},
     remoteHostsConfig: {}
 };
@@ -37,14 +39,15 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat
             return { ...state, apiToken: token };
         },
         SAVE_USER: (user: UserResource) => {
-            return { ...state, user};
+            return { ...state, user };
         },
         CONFIG: ({ config }) => {
             return {
                 ...state,
                 localCluster: config.uuidPrefix,
                 remoteHosts: { ...config.remoteHosts, [config.uuidPrefix]: new URL(config.rootUrl).host },
-                homeCluster: config.uuidPrefix
+                homeCluster: config.loginCluster || config.uuidPrefix,
+                loginCluster: config.loginCluster
             };
         },
         REMOTE_CLUSTER_CONFIG: ({ config }) => {
index debede12faf4be7c9c0a5371e2fda6b95535791e..70a673bb8e25c351e01963a3f860b19a55aa8213 100644 (file)
@@ -52,15 +52,17 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
     remoteHosts: { [key: string]: string },
     homeCluster: string,
-    uuidPrefix: string
+    uuidPrefix: string,
+    loginCluster: string
 };
 
 export const LoginPanel = withStyles(styles)(
     connect((state: RootState) => ({
         remoteHosts: state.auth.remoteHosts,
         homeCluster: state.auth.homeCluster,
-        uuidPrefix: state.auth.localCluster
-    }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
+        uuidPrefix: state.auth.localCluster,
+        loginCluster: state.auth.loginCluster
+    }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, loginCluster }: LoginPanelProps) =>
         <Grid container justify="center" alignItems="center"
             className={classes.root}
             style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
@@ -82,7 +84,7 @@ export const LoginPanel = withStyles(styles)(
                     Arvados Workbench uses your name and email address only for identification, and does not retrieve any other personal information from Google.
                </Typography>
 
-                {Object.keys(remoteHosts).length > 1 &&
+                {Object.keys(remoteHosts).length > 1 && loginCluster === "" &&
                     <Typography component="div" align="right">
                         <label>Please select the cluster that hosts your user account:</label>
                         <Select native value={homeCluster} style={{ margin: "1em" }}