import React from 'react'; import Icon from 'components/Icon'; import { isEmpty } from 'lodash'; import { Button, NavbarGroup, Classes, NavbarDivider, Intent, Switch, Alignment, } from '@blueprintjs/core'; import { FormattedMessage as T } from 'components'; import { AdvancedFilterPopover, If, Can, DashboardActionViewsList, DashboardFilterButton, DashboardRowsHeightButton, } from 'components'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import { useRefreshAccounts } from 'hooks/query/accounts'; import { useAccountsChartContext } from 'containers/Accounts/AccountsChartProvider'; import withDialogActions from 'containers/Dialog/withDialogActions'; import withAccounts from 'containers/Accounts/withAccounts'; import withAlertActions from 'containers/Alert/withAlertActions'; import withAccountsTableActions from './withAccountsTableActions'; import withSettings from '../Settings/withSettings'; import withSettingsActions from '../Settings/withSettingsActions'; import { AccountAction, AbilitySubject } from '../../common/abilityOption'; import { compose } from 'utils'; /** * Accounts actions bar. */ function AccountsActionsBar({ // #withDialogActions openDialog, // #withAccounts accountsSelectedRows, accountsInactiveMode, accountsFilterConditions, // #withAlertActions openAlert, // #withAccountsTableActions setAccountsTableState, // #ownProps onFilterChanged, // #withSettings accountsTableSize, // #withSettingsActions addSetting, }) { const { resourceViews, fields } = useAccountsChartContext(); const onClickNewAccount = () => { openDialog('account-form', {}); }; // Accounts refresh action. const { refresh } = useRefreshAccounts(); // Handle bulk accounts delete. const handleBulkDelete = () => { openAlert('accounts-bulk-delete', { accountsIds: accountsSelectedRows }); }; // Handle bulk accounts activate. const handelBulkActivate = () => { openAlert('accounts-bulk-activate', { accountsIds: accountsSelectedRows }); }; // Handle bulk accounts inactivate. const handelBulkInactive = () => { openAlert('accounts-bulk-inactivate', { accountsIds: accountsSelectedRows, }); }; // Handle tab changing. const handleTabChange = (view) => { setAccountsTableState({ viewSlug: view ? view.slug : null }); }; // Handle inactive switch changing. const handleInactiveSwitchChange = (event) => { const checked = event.target.checked; setAccountsTableState({ inactiveMode: checked }); }; // Handle click a refresh accounts const handleRefreshBtnClick = () => { refresh(); }; // Handle table row size change. const handleTableRowSizeChange = (size) => { addSetting('accounts', 'tableSize', size); }; return ( } views={resourceViews} onChange={handleTabChange} />