X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/6bdb4758d981aa05c19700761d3ace0db7af324a..b1250d13a43d4351c6cbca7990c996b3219693d0:/src/store/auth/auth-reducer.ts diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts index da3c223f..946407fe 100644 --- a/src/store/auth/auth-reducer.ts +++ b/src/store/auth/auth-reducer.ts @@ -7,7 +7,7 @@ import { User } from "~/models/user"; import { ServiceRepository } from "~/services/services"; import { SshKeyResource } from '~/models/ssh-key'; import { Session } from "~/models/session"; -import { Config } from '~/common/config'; +import { Config, mockConfig } from '~/common/config'; export interface AuthState { user?: User; @@ -19,6 +19,7 @@ export interface AuthState { loginCluster: string; remoteHosts: { [key: string]: string }; remoteHostsConfig: { [key: string]: Config }; + config: Config; } const initialState: AuthState = { @@ -30,14 +31,16 @@ const initialState: AuthState = { homeCluster: "", loginCluster: "", remoteHosts: {}, - remoteHostsConfig: {} + remoteHostsConfig: {}, + config: mockConfig({}) }; export const authReducer = (services: ServiceRepository) => (state = initialState, action: AuthAction) => { return authActions.match(action, { - CONFIG: ({ config }) => { + SET_CONFIG: ({ config }) => { return { ...state, + config, localCluster: config.uuidPrefix, remoteHosts: { ...config.remoteHosts, [config.uuidPrefix]: new URL(config.rootUrl).host }, homeCluster: config.loginCluster || config.uuidPrefix, @@ -51,7 +54,7 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat remoteHostsConfig: { ...state.remoteHostsConfig, [config.uuidPrefix]: config }, }; }, - INIT: ({ user, token }) => { + INIT_USER: ({ user, token }) => { return { ...state, user, apiToken: token, homeCluster: user.uuid.substr(0, 5) }; }, LOGIN: () => {