Chore: First table column should not be hideable (#1711)

* First table column should not be hideable

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: chiazokam <chiazokamecheta@gmail.com>

* Refactor according to review

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: chiazokam <chiazokamecheta@gmail.com>

---------

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: chiazokam <chiazokamecheta@gmail.com>
This commit is contained in:
gitstart-twenty
2023-09-25 11:26:41 +01:00
committed by GitHub
parent 0ce11b6908
commit fabbe7ddf2
6 changed files with 117 additions and 74 deletions

View File

@ -41,6 +41,18 @@ export const ViewFieldsVisibilityDropdownSection = <
const handleOnDrag = (result: DropResult, provided: ResponderProvided) => {
onDragEnd?.(result, provided);
};
const getIconButtons = (index: number, field: Field) => {
if (index !== 0) {
return [
{
Icon: field.isVisible ? IconMinus : IconPlus,
onClick: () => onVisibilityChange(field),
},
];
}
};
return (
<>
<StyledDropdownMenuSubheader>{title}</StyledDropdownMenuSubheader>
@ -56,6 +68,7 @@ export const ViewFieldsVisibilityDropdownSection = <
key={field.key}
draggableId={field.key}
index={index}
isDragDisabled={index === 0}
>
{(draggableProvided) => {
const draggableStyle =
@ -79,17 +92,10 @@ export const ViewFieldsVisibilityDropdownSection = <
{...draggableProvided.dragHandleProps}
>
<MenuItem
isDraggable={isDraggable}
isDraggable={index !== 0 && isDraggable}
key={field.key}
LeftIcon={field.Icon}
iconButtons={[
{
Icon: field.isVisible
? IconMinus
: IconPlus,
onClick: () => onVisibilityChange(field),
},
]}
iconButtons={getIconButtons(index, field)}
text={field.name}
/>
</div>