1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { TCheckedList } from "components/data-table/data-table";
6 import { isExactlyOneSelected } from "components/multiselect-toolbar/MultiselectToolbar";
8 export const multiselectActionContants = {
9 TOGGLE_VISIBLITY: "TOGGLE_VISIBLITY",
10 SET_CHECKEDLIST: "SET_CHECKEDLIST",
11 SELECT_ONE: 'SELECT_ONE',
12 DESELECT_ONE: "DESELECT_ONE",
13 TOGGLE_ONE: 'TOGGLE_ONE',
14 SET_SELECTED_UUID: 'SET_SELECTED_UUID'
17 export const toggleMSToolbar = (isVisible: boolean) => {
19 dispatch({ type: multiselectActionContants.TOGGLE_VISIBLITY, payload: isVisible });
23 export const setCheckedListOnStore = (checkedList: TCheckedList) => {
25 dispatch(setSelectedUuid(isExactlyOneSelected(checkedList)))
26 dispatch({ type: multiselectActionContants.SET_CHECKEDLIST, payload: checkedList });
30 export const selectOne = (uuid: string) => {
32 dispatch({ type: multiselectActionContants.SELECT_ONE, payload: uuid });
36 export const deselectOne = (uuid: string) => {
38 dispatch({ type: multiselectActionContants.DESELECT_ONE, payload: uuid });
42 export const toggleOne = (uuid: string) => {
44 dispatch({ type: multiselectActionContants.TOGGLE_ONE, payload: uuid });
48 export const setSelectedUuid = (uuid: string | null) => {
50 dispatch({ type: multiselectActionContants.SET_SELECTED_UUID, payload: uuid });
54 export const multiselectActions = {
56 setCheckedListOnStore,