X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/4ab30205d4a2ea82d6fd4a71798ec2e1eba4ac0a..3b7eae043b41eaebd5cd78d3a74584bcc1290ee7:/src/store/auth/auth-reducer.ts diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts index a8e4340a..a2822f10 100644 --- a/src/store/auth/auth-reducer.ts +++ b/src/store/auth/auth-reducer.ts @@ -6,17 +6,20 @@ import { authActions, AuthAction } from "./auth-action"; import { User } from "~/models/user"; import { ServiceRepository } from "~/services/services"; import { SshKeyResource } from '~/models/ssh-key'; +import { Session } from "~/models/session"; export interface AuthState { user?: User; apiToken?: string; sshKeys: SshKeyResource[]; + sessions: Session[]; } const initialState: AuthState = { user: undefined, apiToken: undefined, - sshKeys: [] + sshKeys: [], + sessions: [] }; export const authReducer = (services: ServiceRepository) => (state = initialState, action: AuthAction) => { @@ -45,6 +48,26 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat REMOVE_SSH_KEY: (uuid: string) => { return { ...state, sshKeys: state.sshKeys.filter((sshKey) => sshKey.uuid !== uuid )}; }, + SET_SESSIONS: (sessions: Session[]) => { + return { ...state, sessions }; + }, + ADD_SESSION: (session: Session) => { + return { ...state, sessions: state.sessions.concat(session) }; + }, + REMOVE_SESSION: (clusterId: string) => { + return { + ...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 }); };