* Renamed AuthAutoRouter * Moved RecoilScope * Refactored old WithTopBarContainer to make it less transclusive * Created new add opportunity button and refactored DropdownButton * Added tests * Deactivated new eslint rule * Refactored Table options with new dropdown * Started BoardDropdown * Fix lint * Refactor dropdown openstate * Fix according to PR * Fix tests --------- Co-authored-by: Charles Bochet <charles@twenty.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { cloneElement } from 'react';
|
|
import { useTheme } from '@emotion/react';
|
|
|
|
import {
|
|
DropdownMenuItem,
|
|
DropdownMenuItemProps,
|
|
} from '@/ui/dropdown/components/DropdownMenuItem';
|
|
import { StyledDropdownMenuItemsContainer } from '@/ui/dropdown/components/StyledDropdownMenuItemsContainer';
|
|
import { StyledDropdownMenuSubheader } from '@/ui/dropdown/components/StyledDropdownMenuSubheader';
|
|
import {
|
|
ViewFieldDefinition,
|
|
ViewFieldMetadata,
|
|
} from '@/ui/editable-field/types/ViewField';
|
|
|
|
type TableOptionsDropdownSectionProps = {
|
|
renderActions: (
|
|
column: ViewFieldDefinition<ViewFieldMetadata>,
|
|
) => DropdownMenuItemProps['actions'];
|
|
title: string;
|
|
columns: ViewFieldDefinition<ViewFieldMetadata>[];
|
|
};
|
|
|
|
export function TableOptionsDropdownSection({
|
|
renderActions,
|
|
title,
|
|
columns,
|
|
}: TableOptionsDropdownSectionProps) {
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
<>
|
|
<StyledDropdownMenuSubheader>{title}</StyledDropdownMenuSubheader>
|
|
<StyledDropdownMenuItemsContainer>
|
|
{columns.map((column) => (
|
|
<DropdownMenuItem key={column.id} actions={renderActions(column)}>
|
|
{column.columnIcon &&
|
|
cloneElement(column.columnIcon, {
|
|
size: theme.icon.size.md,
|
|
})}
|
|
{column.columnLabel}
|
|
</DropdownMenuItem>
|
|
))}
|
|
</StyledDropdownMenuItemsContainer>
|
|
</>
|
|
);
|
|
}
|