Add site manager and initial validation
[arvados-workbench2.git] / src / store / auth / auth-reducer.ts
index a8e4340af52ac35142d9db3c73dce1c78de5fa7a..1edcedee68b6e2296cee4028ce655b9b0736a6ff 100644 (file)
@@ -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,19 @@ 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
+                )};
+        },
         default: () => state
     });
 };