// @ts-nocheck import React from 'react'; import { useHistory } from 'react-router-dom'; import { NavbarGroup, NavbarDivider, Button, Classes, Intent, Switch, Alignment, } from '@blueprintjs/core'; import { DashboardActionsBar, DashboardRowsHeightButton, FormattedMessage as T, } from '@/components'; import { If, Can, Icon, DashboardActionViewsList, AdvancedFilterPopover, DashboardFilterButton, } from '@/components'; import { ItemAction, AbilitySubject } from '@/constants/abilityOption'; import { useItemsListContext } from './ItemsListProvider'; import { useRefreshItems } from '@/hooks/query/items'; import withItems from './withItems'; import withItemsActions from './withItemsActions'; import withAlertActions from '@/containers/Alert/withAlertActions'; import withSettings from '@/containers/Settings/withSettings'; import withSettingsActions from '@/containers/Settings/withSettingsActions'; import { compose } from '@/utils'; /** * Items actions bar. */ function ItemsActionsBar({ // #withItems itemsSelectedRows, itemsFilterRoles, // #withItemActions setItemsTableState, itemsInactiveMode, // #withAlertActions openAlert, // #withSettings itemsTableSize, // #withSettingsActions addSetting, }) { // Items list context. const { itemsViews, fields } = useItemsListContext(); // Items refresh action. const { refresh } = useRefreshItems(); // History context. const history = useHistory(); // Handle `new item` button click. const onClickNewItem = () => { history.push('/items/new'); }; // Handle tab changing. const handleTabChange = (view) => { setItemsTableState({ viewSlug: view ? view.slug : null }); }; // Handle cancel/confirm items bulk. const handleBulkDelete = () => { openAlert('items-bulk-delete', { itemsIds: itemsSelectedRows }); }; // Handle inactive switch changing. const handleInactiveSwitchChange = (event) => { const checked = event.target.checked; setItemsTableState({ inactiveMode: checked }); }; // Handle refresh button click. const handleRefreshBtnClick = () => { refresh(); }; // Handle table row size change. const handleTableRowSizeChange = (size) => { addSetting('items', 'tableSize', size); }; return ( } views={itemsViews} onChange={handleTabChange} />