Create data explorer actions and reducer
[arvados-workbench2.git] / src / store / data-explorer / data-explorer-action.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { default as unionize, ofType, UnionOf } from "unionize";
6 import { SortDirection, DataColumn } from "../../components/data-table/data-column";
7 import { DataTableFilterItem } from "../../components/data-table-filters/data-table-filters";
8
9 type WithId<T> = T & { id: string };
10
11 const actions = unionize({
12     SET_COLUMNS: ofType<WithId<{ columns: Array<DataColumn<any>> }>>(),
13     SET_FILTERS: ofType<WithId<{columnName: string, filters: DataTableFilterItem[]}>>(),
14     SET_ITEMS: ofType<WithId<{items: any[]}>>(),
15     SET_PAGE: ofType<WithId<{page: number}>>(),
16     SET_ROWS_PER_PAGE: ofType<WithId<{rowsPerPage: number}>>(),
17     TOGGLE_COLUMN: ofType<WithId<{ columnName: string }>>(),
18     TOGGLE_SORT: ofType<WithId<{ columnName: string }>>(),
19     SET_SEARCH_VALUE: ofType<WithId<{searchValue: string}>>()
20 }, { tag: "type", value: "payload" });
21
22 export type DataExplorerAction = UnionOf<typeof actions>;
23
24 export default actions;
25
26
27
28