[ARVADOS-WORKBENCH2] updated: 1.4.1-304-gc791a7eb

Git user git at public.arvados.org
Tue Mar 31 19:00:43 UTC 2020


Summary of changes:
 src/index.tsx                                  |  2 --
 src/store/auth/auth-action-session.ts          | 13 +++++++++++++
 src/store/auth/auth-action.ts                  | 14 +++++++++++---
 src/views-components/login-form/login-form.tsx |  5 +++--
 src/views/login-panel/login-panel.tsx          | 25 ++++++++++++++-----------
 5 files changed, 41 insertions(+), 18 deletions(-)

       via  c791a7ebad9264d5ef3be948ad038ef83b7da64d (commit)
       via  0feed69e897950f4044605064acc779224c7d5ef (commit)
      from  a308a27833843d90405b927ac491fea7c853b91c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c791a7ebad9264d5ef3be948ad038ef83b7da64d
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Mar 31 15:59:40 2020 -0300

    16212: Support LoginCluster feature.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx
index 57e7a0dc..ce8adb8f 100644
--- a/src/views/login-panel/login-panel.tsx
+++ b/src/views/login-panel/login-panel.tsx
@@ -74,8 +74,8 @@ export const LoginPanel = withStyles(styles)(
         localCluster: state.auth.localCluster,
         loginCluster: state.auth.loginCluster,
         welcomePage: state.auth.config.clusterConfig.Workbench.WelcomePageHTML,
-        pamLogin: state.auth.remoteHostsConfig[state.auth.homeCluster] &&
-            state.auth.remoteHostsConfig[state.auth.homeCluster].clusterConfig.Login.PAM || false,
+        pamLogin: state.auth.remoteHostsConfig[state.auth.loginCluster || state.auth.homeCluster] &&
+            state.auth.remoteHostsConfig[state.auth.loginCluster || state.auth.homeCluster].clusterConfig.Login.PAM || false,
     }))(({ classes, dispatch, remoteHosts, homeCluster, localCluster, loginCluster, welcomePage, pamLogin }: LoginPanelProps) => {
         const loginBtnLabel = `Log in${(localCluster !== homeCluster && loginCluster !== homeCluster) ? " to "+localCluster+" with user from "+homeCluster : ''}`;
 
@@ -100,7 +100,7 @@ export const LoginPanel = withStyles(styles)(
                 ? <Typography component="div">
                     <LoginForm dispatch={dispatch}
                         loginLabel={loginBtnLabel}
-                        handleSubmit={doPAMLogin(`https://${remoteHosts[homeCluster]}`)}/>
+                        handleSubmit={doPAMLogin(`https://${remoteHosts[loginCluster || homeCluster]}`)}/>
                 </Typography>
                 : <Typography component="div" align="right">
                     <Button variant="contained" color="primary" style={{ margin: "1em" }}

commit 0feed69e897950f4044605064acc779224c7d5ef
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Mar 31 15:35:29 2020 -0300

    16212: Loads remote clusters configs at app boot.
    
    When using a federation without LoginCluster, the user is given the option
    to log in using any cluster as the 'home cluster'. If any of those remote
    clusters has Login.PAM enabled, the login form is displayed.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/index.tsx b/src/index.tsx
index bf810fb7..d428b1c3 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -166,5 +166,3 @@ const initListener = (history: History, store: RootStore, services: ServiceRepos
         }
     };
 };
-
-// force build comment #1
diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts
index a6387828..52a1e23a 100644
--- a/src/store/auth/auth-action-session.ts
+++ b/src/store/auth/auth-action-session.ts
@@ -200,6 +200,19 @@ export const validateSessions = () =>
         }
     };
 
+export const addRemoteConfig = (remoteHost: string) =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        const config = await getRemoteHostConfig(remoteHost);
+        if (!config) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: `Could not get config for ${remoteHost}`,
+                kind: SnackbarKind.ERROR
+            }));
+            return;
+        }
+        dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config }));
+    };
+
 export const addSession = (remoteHost: string, token?: string, sendToLogin?: boolean) =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
         const sessions = getState().auth.sessions;
diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts
index 1d8a01c6..5cff19ee 100644
--- a/src/store/auth/auth-action.ts
+++ b/src/store/auth/auth-action.ts
@@ -15,6 +15,7 @@ import { createServices, setAuthorizationHeader } from "~/services/services";
 import { cancelLinking } from '~/store/link-account-panel/link-account-panel-actions';
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
 import { WORKBENCH_LOADING_SCREEN } from '~/store/workbench/workbench-actions';
+import { addRemoteConfig } from './auth-action-session';
 
 export const authActions = unionize({
     LOGIN: {},
@@ -38,23 +39,30 @@ export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () =>
     // Cancel any link account ops in progress unless the user has
     // just logged in or there has been a successful link operation
     const data = services.linkAccountService.getLinkOpStatus();
-    if (!matchTokenRoute(location.pathname) && (!matchFedTokenRoute(location.pathname)) && data === undefined) {
+    if (!matchTokenRoute(location.pathname) &&
+        (!matchFedTokenRoute(location.pathname)) && data === undefined) {
         dispatch<any>(cancelLinking()).then(() => {
             dispatch<any>(init(config));
         });
-    }
-    else {
+    } else {
         dispatch<any>(init(config));
     }
 };
 
 const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    const remoteHosts = () => getState().auth.remoteHosts;
     const token = services.authService.getApiToken();
     let homeCluster = services.authService.getHomeCluster();
     if (homeCluster && !config.remoteHosts[homeCluster]) {
         homeCluster = undefined;
     }
     dispatch(authActions.SET_CONFIG({ config }));
+    Object.keys(remoteHosts()).forEach((remoteUuid: string) => {
+        const remoteHost = remoteHosts()[remoteUuid];
+        if (remoteUuid !== config.uuidPrefix) {
+            dispatch<any>(addRemoteConfig(remoteHost));
+        }
+    });
     dispatch(authActions.SET_HOME_CLUSTER(config.loginCluster || homeCluster || config.uuidPrefix));
 
     if (token && token !== "undefined") {
diff --git a/src/views-components/login-form/login-form.tsx b/src/views-components/login-form/login-form.tsx
index 2d4451c6..8ec856f9 100644
--- a/src/views-components/login-form/login-form.tsx
+++ b/src/views-components/login-form/login-form.tsx
@@ -46,10 +46,11 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
 
 type LoginFormProps = DispatchProp<any> & WithStyles<CssRules> & {
     handleSubmit: (username: string, password: string) => AxiosPromise;
+    loginLabel?: string,
 };
 
 export const LoginForm = withStyles(styles)(
-    ({ handleSubmit, dispatch, classes }: LoginFormProps) => {
+    ({ handleSubmit, loginLabel, dispatch, classes }: LoginFormProps) => {
         const userInput = useRef<HTMLInputElement>(null);
         const [username, setUsername] = useState('');
         const [password, setPassword] = useState('');
@@ -137,7 +138,7 @@ export const LoginForm = withStyles(styles)(
                         <Button variant="contained" size="large" color="primary"
                             className={classes.loginBtn} onClick={() => handleLogin()}
                             disabled={isSubmitting || isButtonDisabled}>
-                            Log in
+                            {loginLabel || 'Log in'}
                         </Button>
                     </CardActions>
                     { isSubmitting && <CircularProgress color='secondary' className={classes.progress} />}
diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx
index 203a2f19..57e7a0dc 100644
--- a/src/views/login-panel/login-panel.tsx
+++ b/src/views/login-panel/login-panel.tsx
@@ -61,7 +61,7 @@ const doPAMLogin = (url: string) => (username: string, password: string) => {
 type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
     remoteHosts: { [key: string]: string },
     homeCluster: string,
-    uuidPrefix: string,
+    localCluster: string,
     loginCluster: string,
     welcomePage: string,
     pamLogin: boolean,
@@ -71,12 +71,15 @@ export const LoginPanel = withStyles(styles)(
     connect((state: RootState) => ({
         remoteHosts: state.auth.remoteHosts,
         homeCluster: state.auth.homeCluster,
-        uuidPrefix: state.auth.localCluster,
+        localCluster: state.auth.localCluster,
         loginCluster: state.auth.loginCluster,
         welcomePage: state.auth.config.clusterConfig.Workbench.WelcomePageHTML,
-        pamLogin: state.auth.config.clusterConfig.Login.PAM,
-    }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, loginCluster, welcomePage, pamLogin }: LoginPanelProps) =>
-        <Grid container justify="center" alignItems="center"
+        pamLogin: state.auth.remoteHostsConfig[state.auth.homeCluster] &&
+            state.auth.remoteHostsConfig[state.auth.homeCluster].clusterConfig.Login.PAM || false,
+    }))(({ classes, dispatch, remoteHosts, homeCluster, localCluster, loginCluster, welcomePage, pamLogin }: LoginPanelProps) => {
+        const loginBtnLabel = `Log in${(localCluster !== homeCluster && loginCluster !== homeCluster) ? " to "+localCluster+" with user from "+homeCluster : ''}`;
+
+        return (<Grid container justify="center" alignItems="center"
             className={classes.root}
             style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
             <Grid item className={classes.container}>
@@ -95,17 +98,17 @@ export const LoginPanel = withStyles(styles)(
 
                 {pamLogin
                 ? <Typography component="div">
-                    <LoginForm dispatch={dispatch} handleSubmit={
-                        doPAMLogin(`https://${remoteHosts[homeCluster]}`)}/>
+                    <LoginForm dispatch={dispatch}
+                        loginLabel={loginBtnLabel}
+                        handleSubmit={doPAMLogin(`https://${remoteHosts[homeCluster]}`)}/>
                 </Typography>
                 : <Typography component="div" align="right">
                     <Button variant="contained" color="primary" style={{ margin: "1em" }}
                         className={classes.button}
-                        onClick={() => dispatch(login(uuidPrefix, homeCluster, loginCluster, remoteHosts))}>
-                        Log in {uuidPrefix !== homeCluster && loginCluster !== homeCluster &&
-                            <span> to {uuidPrefix} with user from {homeCluster}</span>}
+                        onClick={() => dispatch(login(localCluster, homeCluster, loginCluster, remoteHosts))}>
+                        {loginBtnLabel}
                     </Button>
                 </Typography>}
             </Grid>
-        </Grid >
+        </Grid >);}
     ));

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list