21700: Install Bundler system-wide in Rails postinst
[arvados.git] / services / workbench2 / 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 { unionize, ofType, UnionOf } from "common/unionize";
6 import { DataColumns, DataTableFetchMode } from "components/data-table/data-table";
7 import { DataTableFilters } from "components/data-table-filters/data-table-filters-tree";
8
9 export enum DataTableRequestState {
10     IDLE,
11     PENDING,
12     NEED_REFRESH,
13 }
14
15 export const dataExplorerActions = unionize({
16     CLEAR: ofType<{ id: string }>(),
17     RESET_PAGINATION: ofType<{ id: string }>(),
18     REQUEST_ITEMS: ofType<{ id: string; criteriaChanged?: boolean, background?: boolean }>(),
19     REQUEST_STATE: ofType<{ id: string; criteriaChanged?: boolean }>(),
20     SET_FETCH_MODE: ofType<{ id: string; fetchMode: DataTableFetchMode }>(),
21     SET_COLUMNS: ofType<{ id: string; columns: DataColumns<any, any> }>(),
22     SET_FILTERS: ofType<{ id: string; columnName: string; filters: DataTableFilters }>(),
23     SET_ITEMS: ofType<{ id: string; items: any[]; page: number; rowsPerPage: number; itemsAvailable: number }>(),
24     APPEND_ITEMS: ofType<{ id: string; items: any[]; page: number; rowsPerPage: number; itemsAvailable: number }>(),
25     SET_PAGE: ofType<{ id: string; page: number }>(),
26     SET_ROWS_PER_PAGE: ofType<{ id: string; rowsPerPage: number }>(),
27     TOGGLE_COLUMN: ofType<{ id: string; columnName: string }>(),
28     TOGGLE_SORT: ofType<{ id: string; columnName: string }>(),
29     SET_EXPLORER_SEARCH_VALUE: ofType<{ id: string; searchValue: string }>(),
30     RESET_EXPLORER_SEARCH_VALUE: ofType<{ id: string }>(),
31     SET_REQUEST_STATE: ofType<{ id: string; requestState: DataTableRequestState }>(),
32     SET_IS_NOT_FOUND: ofType<{ id: string; isNotFound: boolean }>(),
33 });
34
35 export type DataExplorerAction = UnionOf<typeof dataExplorerActions>;
36
37 export const bindDataExplorerActions = (id: string) => ({
38     CLEAR: () => dataExplorerActions.CLEAR({ id }),
39     RESET_PAGINATION: () => dataExplorerActions.RESET_PAGINATION({ id }),
40     REQUEST_ITEMS: (criteriaChanged?: boolean, background?: boolean) => dataExplorerActions.REQUEST_ITEMS({ id, criteriaChanged, background }),
41     SET_FETCH_MODE: (payload: { fetchMode: DataTableFetchMode }) => dataExplorerActions.SET_FETCH_MODE({ ...payload, id }),
42     SET_COLUMNS: (payload: { columns: DataColumns<any, any> }) => dataExplorerActions.SET_COLUMNS({ ...payload, id }),
43     SET_FILTERS: (payload: { columnName: string; filters: DataTableFilters }) => dataExplorerActions.SET_FILTERS({ ...payload, id }),
44     SET_ITEMS: (payload: { items: any[]; page: number; rowsPerPage: number; itemsAvailable: number }) =>
45         dataExplorerActions.SET_ITEMS({ ...payload, id }),
46     APPEND_ITEMS: (payload: { items: any[]; page: number; rowsPerPage: number; itemsAvailable: number }) =>
47         dataExplorerActions.APPEND_ITEMS({ ...payload, id }),
48     SET_PAGE: (payload: { page: number }) => dataExplorerActions.SET_PAGE({ ...payload, id }),
49     SET_ROWS_PER_PAGE: (payload: { rowsPerPage: number }) => dataExplorerActions.SET_ROWS_PER_PAGE({ ...payload, id }),
50     TOGGLE_COLUMN: (payload: { columnName: string }) => dataExplorerActions.TOGGLE_COLUMN({ ...payload, id }),
51     TOGGLE_SORT: (payload: { columnName: string }) => dataExplorerActions.TOGGLE_SORT({ ...payload, id }),
52     SET_EXPLORER_SEARCH_VALUE: (payload: { searchValue: string }) => dataExplorerActions.SET_EXPLORER_SEARCH_VALUE({ ...payload, id }),
53     RESET_EXPLORER_SEARCH_VALUE: () => dataExplorerActions.RESET_EXPLORER_SEARCH_VALUE({ id }),
54     SET_REQUEST_STATE: (payload: { requestState: DataTableRequestState }) => dataExplorerActions.SET_REQUEST_STATE({ ...payload, id }),
55     SET_IS_NOT_FOUND: (payload: { isNotFound: boolean }) => dataExplorerActions.SET_IS_NOT_FOUND({ ...payload, id }),
56 });
57
58 export type BoundDataExplorerActions = ReturnType<typeof bindDataExplorerActions>;