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:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user