import { groupMemberActionSet } from '~/views-components/context-menu/action-sets/group-member-action-set';
import { linkActionSet } from '~/views-components/context-menu/action-sets/link-action-set';
import { loadFileViewersConfig } from '~/store/file-viewers/file-viewers-actions';
-import { setRemoteHosts } from '~/views/login-panel/login-panel';
console.log(`Starting arvados [${getBuildInfo()}]`);
store.dispatch(initAuth(config));
store.dispatch(setBuildInfo());
store.dispatch(setCurrentTokenDialogApiHost(apiHost));
- store.dispatch(setUuidPrefix(config.uuidPrefix));
- store.dispatch(setRemoteHosts(config.remoteHosts));
store.dispatch(loadVocabulary);
store.dispatch(loadFileViewersConfig);
SAVE_API_TOKEN: ofType<string>(),
LOGIN: {},
LOGOUT: {},
+ CONFIG: ofType<{ uuidPrefix: string, remoteHosts: { [key: string]: string } }>(),
INIT: ofType<{ user: User, token: string }>(),
USER_DETAILS_REQUEST: {},
USER_DETAILS_SUCCESS: ofType<User>(),
SET_SSH_KEYS: ofType<SshKeyResource[]>(),
ADD_SSH_KEY: ofType<SshKeyResource>(),
REMOVE_SSH_KEY: ofType<string>(),
+ SET_HOME_CLUSTER: ofType<string>(),
SET_SESSIONS: ofType<Session[]>(),
ADD_SESSION: ofType<Session>(),
REMOVE_SESSION: ofType<string>(),
if (token) {
setAuthorizationHeader(services, token);
}
+ dispatch(authActions.CONFIG({ uuidPrefix: config.uuidPrefix, remoteHosts: config.remoteHosts }));
if (token && user) {
dispatch(authActions.INIT({ user, token }));
dispatch<any>(initSessions(services.authService, config, user));
apiToken?: string;
sshKeys: SshKeyResource[];
sessions: Session[];
+ localCluster: string;
+ homeCluster: string;
+ remoteHosts: { [key: string]: string };
}
const initialState: AuthState = {
user: undefined,
apiToken: undefined,
sshKeys: [],
- sessions: []
+ sessions: [],
+ localCluster: "",
+ homeCluster: "",
+ remoteHosts: {}
};
export const authReducer = (services: ServiceRepository) => (state = initialState, action: AuthAction) => {
return authActions.match(action, {
SAVE_API_TOKEN: (token: string) => {
- return {...state, apiToken: token};
+ return { ...state, apiToken: token };
+ },
+ CONFIG: ({ uuidPrefix, remoteHosts }) => {
+ return {
+ ...state, localCluster: uuidPrefix, remoteHosts, homeCluster: uuidPrefix
+ };
},
INIT: ({ user, token }) => {
- return { ...state, user, apiToken: token };
+ return { ...state, user, apiToken: token, homeCluster: user.uuid.substr(0, 5) };
},
LOGIN: () => {
return state;
},
LOGOUT: () => {
- return {...state, apiToken: undefined};
+ return { ...state, apiToken: undefined };
},
USER_DETAILS_SUCCESS: (user: User) => {
- return {...state, user};
+ return { ...state, user };
},
SET_SSH_KEYS: (sshKeys: SshKeyResource[]) => {
- return {...state, sshKeys};
+ return { ...state, sshKeys };
},
ADD_SSH_KEY: (sshKey: SshKeyResource) => {
return { ...state, sshKeys: state.sshKeys.concat(sshKey) };
},
REMOVE_SSH_KEY: (uuid: string) => {
- return { ...state, sshKeys: state.sshKeys.filter((sshKey) => sshKey.uuid !== uuid )};
+ return { ...state, sshKeys: state.sshKeys.filter((sshKey) => sshKey.uuid !== uuid) };
+ },
+ SET_HOME_CLUSTER: (homeCluster: string) => {
+ return { ...state, homeCluster };
},
SET_SESSIONS: (sessions: Session[]) => {
return { ...state, sessions };
...state,
sessions: state.sessions.filter(
session => session.clusterId !== clusterId
- )};
+ )
+ };
},
UPDATE_SESSION: (session: Session) => {
return {
...state,
sessions: state.sessions.map(
s => s.clusterId === session.clusterId ? session : s
- )};
+ )
+ };
},
default: () => state
});
import * as React from 'react';
import { connect, DispatchProp } from 'react-redux';
-import { Grid, Typography, Button } from '@material-ui/core';
+import { Grid, Typography, Button, Select, FormControl } from '@material-ui/core';
import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
-import { login } from '~/store/auth/auth-action';
+import { login, authActions } from '~/store/auth/auth-action';
import { ArvadosTheme } from '~/common/custom-theme';
import { RootState } from '~/store/store';
-import { getProperty } from '~/store/properties/properties';
-import { propertiesActions } from '~/store/properties/properties-actions';
import * as classNames from 'classnames';
type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
});
type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
- remoteHosts: any,
+ remoteHosts: { [key: string]: string },
homeCluster: string,
uuidPrefix: string
};
-export const REMOTE_HOSTS_NAME = 'remoteHosts';
-export const HOME_CLUSTER_NAME = 'homeCluster';
-export const setRemoteHosts = (remoteHosts: any) =>
- propertiesActions.SET_PROPERTY({ key: REMOTE_HOSTS_NAME, value: remoteHosts });
-
-export const setHomeCluster = (homeCluster: string) =>
- propertiesActions.SET_PROPERTY({ key: HOME_CLUSTER_NAME, value: homeCluster });
-
export const LoginPanel = withStyles(styles)(
connect((state: RootState) => ({
- remoteHosts: state.properties.remoteHosts,
- homeCluster: state.properties.homeCluster,
- uuidPrefix: state.properties.uuidPrefix
+ remoteHosts: state.auth.remoteHosts,
+ homeCluster: state.auth.homeCluster,
+ uuidPrefix: state.auth.localCluster
}))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
<Grid container direction="column" item xs alignItems="center" justify="center" className={classes.root}>
<Grid item className={classes.container}>
Arvados Workbench uses your name and email address only for identification, and does not retrieve any other personal information from Google.
</Typography>
- <Typography className={classes.content}>
- <form>
- <label>
- Choose your home cluster:
- <select value={homeCluster} onChange={(event) => dispatch(setHomeCluster(event.target.value))}>
- {Object.keys(remoteHosts).map((k) => <option key={k} value={k}>{k}</option>)}
- </select>
- </label>
- </form>
- </Typography>
+ {Object.keys(remoteHosts).length > 1 &&
+ <Typography component="div" align="right">
+ <label>Please select the cluster that hosts your user account:</label>
+ <Select native value={homeCluster} style={{ margin: "1em" }}
+ onChange={(event) => dispatch(authActions.SET_HOME_CLUSTER(event.target.value))}>
+ {Object.keys(remoteHosts).map((k) => <option key={k} value={k}>{k}</option>)}
+ </Select>
+ </Typography>}
+
<Typography component="div" align="right">
- <Button variant="contained" color="primary" className={classes.button} onClick={() => dispatch(login(uuidPrefix, remoteHosts[homeCluster]))}>
- Log in
- </Button>
+ <Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
+ onClick={() => dispatch(login(uuidPrefix, remoteHosts[homeCluster]))}>
+ Log in to {uuidPrefix}
+ {uuidPrefix !== homeCluster &&
+ <span> with user from {homeCluster}</span>}
+ </Button>
</Typography>
</Grid>
</Grid>
working: isSystemWorking(state.progressIndicator),
loading: isWorkbenchLoading(state),
buildInfo: state.appInfo.buildInfo,
- uuidPrefix: state.properties.uuidPrefix
+ uuidPrefix: state.auth.localCluster
};
};