1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { unionize, ofType, UnionOf } from "~/common/unionize";
6 import { DataColumns } from "~/components/data-table/data-table";
7 import { DataTableFilters } from '~/components/data-table-filters/data-table-filters-tree';
9 export const dataExplorerActions = unionize({
10 RESET_PAGINATION: ofType<{ id: string }>(),
11 REQUEST_ITEMS: ofType<{ id: string }>(),
12 SET_COLUMNS: ofType<{ id: string, columns: DataColumns<any> }>(),
13 SET_FILTERS: ofType<{ id: string, columnName: string, filters: DataTableFilters }>(),
14 SET_ITEMS: ofType<{ id: string, items: any[], page: number, rowsPerPage: number, itemsAvailable: number }>(),
15 SET_PAGE: ofType<{ id: string, page: number }>(),
16 SET_ROWS_PER_PAGE: ofType<{ id: string, rowsPerPage: number }>(),
17 TOGGLE_COLUMN: ofType<{ id: string, columnName: string }>(),
18 TOGGLE_SORT: ofType<{ id: string, columnName: string }>(),
19 SET_EXPLORER_SEARCH_VALUE: ofType<{ id: string, searchValue: string }>(),
22 export type DataExplorerAction = UnionOf<typeof dataExplorerActions>;
24 export const bindDataExplorerActions = (id: string) => ({
25 RESET_PAGINATION: () =>
26 dataExplorerActions.RESET_PAGINATION({ id }),
28 dataExplorerActions.REQUEST_ITEMS({ id }),
29 SET_COLUMNS: (payload: { columns: DataColumns<any> }) =>
30 dataExplorerActions.SET_COLUMNS({ ...payload, id }),
31 SET_FILTERS: (payload: { columnName: string, filters: DataTableFilters }) =>
32 dataExplorerActions.SET_FILTERS({ ...payload, id }),
33 SET_ITEMS: (payload: { items: any[], page: number, rowsPerPage: number, itemsAvailable: number }) =>
34 dataExplorerActions.SET_ITEMS({ ...payload, id }),
35 SET_PAGE: (payload: { page: number }) =>
36 dataExplorerActions.SET_PAGE({ ...payload, id }),
37 SET_ROWS_PER_PAGE: (payload: { rowsPerPage: number }) =>
38 dataExplorerActions.SET_ROWS_PER_PAGE({ ...payload, id }),
39 TOGGLE_COLUMN: (payload: { columnName: string }) =>
40 dataExplorerActions.TOGGLE_COLUMN({ ...payload, id }),
41 TOGGLE_SORT: (payload: { columnName: string }) =>
42 dataExplorerActions.TOGGLE_SORT({ ...payload, id }),
43 SET_EXPLORER_SEARCH_VALUE: (payload: { searchValue: string }) =>
44 dataExplorerActions.SET_EXPLORER_SEARCH_VALUE({ ...payload, id }),