add keep services panel with state and all dialogs for actions
[arvados-workbench2.git] / src / store / keep-services / keep-services-reducer.ts
diff --git a/src/store/keep-services/keep-services-reducer.ts b/src/store/keep-services/keep-services-reducer.ts
new file mode 100644 (file)
index 0000000..53ef678
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { keepServicesActions, KeepServicesActions } from '~/store/keep-services/keep-services-actions';
+import { KeepServiceResource } from '~/models/keep-services';
+
+export type KeepSericesState = KeepServiceResource[];
+
+const initialState: KeepSericesState = [];
+
+export const keepServicesReducer = (state: KeepSericesState = initialState, action: KeepServicesActions): KeepSericesState =>
+    keepServicesActions.match(action, {
+        SET_KEEP_SERVICES: items => items,
+        REMOVE_KEEP_SERVICE: (uuid: string) => state.filter((keepService) => keepService.uuid !== uuid),
+        RESET_KEEP_SERVICES: () => [],
+        default: () => state
+    });
\ No newline at end of file