Reuse DataColumns type
[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 import { DataColumns } from "../../components/data-table/data-table";
9
10 type WithId<T> = T & { id: string };
11
12 const actions = unionize({
13     SET_COLUMNS: ofType<WithId<{ columns: DataColumns<any> }>>(),
14     SET_FILTERS: ofType<WithId<{columnName: string, filters: DataTableFilterItem[]}>>(),
15     SET_ITEMS: ofType<WithId<{items: any[]}>>(),
16     SET_PAGE: ofType<WithId<{page: number}>>(),
17     SET_ROWS_PER_PAGE: ofType<WithId<{rowsPerPage: number}>>(),
18     TOGGLE_COLUMN: ofType<WithId<{ columnName: string }>>(),
19     TOGGLE_SORT: ofType<WithId<{ columnName: string }>>(),
20     SET_SEARCH_VALUE: ofType<WithId<{searchValue: string}>>()
21 }, { tag: "type", value: "payload" });
22
23 export type DataExplorerAction = UnionOf<typeof actions>;
24
25 export default actions;
26
27
28
29