Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / src / store / link-account-panel / link-account-panel-reducer.ts
index 0e61abdd2f55bf094cfe96716cd223fdafd92a65..15d07810cd6b64064f936334409655e6a1965d4f 100644 (file)
@@ -2,8 +2,8 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { linkAccountPanelActions, LinkAccountPanelAction } from "~/store/link-account-panel/link-account-panel-actions";
-import { UserResource } from "~/models/user";
+import { linkAccountPanelActions, LinkAccountPanelAction } from "store/link-account-panel/link-account-panel-actions";
+import { UserResource } from "models/user";
 
 export enum LinkAccountPanelStatus {
     NONE,
@@ -27,6 +27,7 @@ export enum OriginatingUser {
 }
 
 export interface LinkAccountPanelState {
+    selectedCluster: string | undefined;
     originatingUser: OriginatingUser | undefined;
     targetUser: UserResource | undefined;
     targetUserToken: string | undefined;
@@ -34,14 +35,17 @@ export interface LinkAccountPanelState {
     userToLinkToken: string | undefined;
     status: LinkAccountPanelStatus;
     error: LinkAccountPanelError;
+    isProcessing: boolean;
 }
 
 const initialState = {
+    selectedCluster: undefined,
     originatingUser: OriginatingUser.NONE,
     targetUser: undefined,
     targetUserToken: undefined,
     userToLink: undefined,
     userToLinkToken: undefined,
+    isProcessing: false,
     status: LinkAccountPanelStatus.NONE,
     error: LinkAccountPanelError.NONE
 };
@@ -50,22 +54,32 @@ export const linkAccountPanelReducer = (state: LinkAccountPanelState = initialSt
     linkAccountPanelActions.match(action, {
         default: () => state,
         LINK_INIT: ({ targetUser }) => ({
+            ...state,
             targetUser, targetUserToken: undefined,
             userToLink: undefined, userToLinkToken: undefined,
             status: LinkAccountPanelStatus.INITIAL, error: LinkAccountPanelError.NONE, originatingUser: OriginatingUser.NONE
         }),
         LINK_LOAD: ({ originatingUser, userToLink, targetUser, targetUserToken, userToLinkToken}) => ({
+            ...state,
             originatingUser,
             targetUser, targetUserToken,
             userToLink, userToLinkToken,
             status: LinkAccountPanelStatus.LINKING, error: LinkAccountPanelError.NONE
         }),
-        LINK_INVALID: ({originatingUser, targetUser, userToLink, error}) => ({
+        LINK_INVALID: ({ originatingUser, targetUser, userToLink, error }) => ({
+            ...state,
             originatingUser,
             targetUser, targetUserToken: undefined,
             userToLink, userToLinkToken: undefined,
             error, status: LinkAccountPanelStatus.ERROR
         }),
+        SET_SELECTED_CLUSTER: ({ selectedCluster }) => ({
+            ...state, selectedCluster
+        }),
+        SET_IS_PROCESSING: ({ isProcessing }) =>({
+            ...state,
+            isProcessing
+        }),
         HAS_SESSION_DATA: () => ({
             ...state, status: LinkAccountPanelStatus.HAS_SESSION_DATA
         })