-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolbar.tsx
More file actions
29 lines (24 loc) · 1.29 KB
/
toolbar.tsx
File metadata and controls
29 lines (24 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react';
import { Menu, MenuProps } from 'semantic-ui-react';
import { useRelatableStateContext } from '../../states';
import { withFilters, withGrouping, withSelection, withSorting } from '../../add-ons';
import { isActionAvailable } from '../../utils/relatable-actions';
import SortableToolbar from './sortable.toolbar';
import FilterableToolbar from './filterable.toolbar';
import GroupableToolbar from './groupable.toolbar';
import SelectableToolbar from './selectable.toolbar';
export default function Toolbar(props: React.PropsWithChildren<MenuProps> = {}): JSX.Element {
const { className = '', children, ...rest } = props;
const { availableGlobalActions } = useRelatableStateContext();
if (children) {
return <Menu icon secondary {...rest} className={`relatable__toolbar ${className}`}>
{children}
</Menu>;
}
return <Menu icon secondary {...rest} className={`relatable__toolbar ${className}`}>
{isActionAvailable(availableGlobalActions, withGrouping.name) && <GroupableToolbar/>}
{isActionAvailable(availableGlobalActions, withFilters.name) && <FilterableToolbar/>}
{isActionAvailable(availableGlobalActions, withSorting.name) && <SortableToolbar/>}
{isActionAvailable(availableGlobalActions, withSelection.name) && <SelectableToolbar/>}
</Menu>;
}