Fix 4363 modify kanban menu (#5337)
**Changes:** - Changed -/+ to eye and eye off icons - Changed menu width to 200px - Created separate menu for hidden fields - Added Edit Fields option to hidden fields menu - Added test file MenuItemSelectTag (wasn't included in the issue) As this is my first pr, feedback is very welcome! **Note:** These changes cover most of #4363 . I left out the implementation of the RightIcon in the "Hidden Fields" menu item. --------- Co-authored-by: kiridarivaki <k.darivaki03@gmail.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -20,6 +20,7 @@ export const RecordIndexOptionsDropdown = ({
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
dropdownId={RECORD_INDEX_OPTIONS_DROPDOWN_ID}
|
dropdownId={RECORD_INDEX_OPTIONS_DROPDOWN_ID}
|
||||||
clickableComponent={<RecordIndexOptionsDropdownButton />}
|
clickableComponent={<RecordIndexOptionsDropdownButton />}
|
||||||
|
dropdownMenuWidth={'200px'}
|
||||||
dropdownHotkeyScope={{ scope: TableOptionsHotkeyScope.Dropdown }}
|
dropdownHotkeyScope={{ scope: TableOptionsHotkeyScope.Dropdown }}
|
||||||
dropdownOffset={{ y: 8 }}
|
dropdownOffset={{ y: 8 }}
|
||||||
dropdownComponents={
|
dropdownComponents={
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Key } from 'ts-key-enum';
|
import { Key } from 'ts-key-enum';
|
||||||
import {
|
import {
|
||||||
IconBaselineDensitySmall,
|
IconBaselineDensitySmall,
|
||||||
IconChevronLeft,
|
IconChevronLeft,
|
||||||
|
IconEyeOff,
|
||||||
IconFileExport,
|
IconFileExport,
|
||||||
IconFileImport,
|
IconFileImport,
|
||||||
|
IconSettings,
|
||||||
IconTag,
|
IconTag,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
|
||||||
@ -17,6 +20,8 @@ import { useRecordIndexOptionsForBoard } from '@/object-record/record-index/opti
|
|||||||
import { useRecordIndexOptionsForTable } from '@/object-record/record-index/options/hooks/useRecordIndexOptionsForTable';
|
import { useRecordIndexOptionsForTable } from '@/object-record/record-index/options/hooks/useRecordIndexOptionsForTable';
|
||||||
import { TableOptionsHotkeyScope } from '@/object-record/record-table/types/TableOptionsHotkeyScope';
|
import { TableOptionsHotkeyScope } from '@/object-record/record-table/types/TableOptionsHotkeyScope';
|
||||||
import { useSpreadsheetRecordImport } from '@/object-record/spreadsheet-import/useSpreadsheetRecordImport';
|
import { useSpreadsheetRecordImport } from '@/object-record/spreadsheet-import/useSpreadsheetRecordImport';
|
||||||
|
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
||||||
|
import { SettingsPath } from '@/types/SettingsPath';
|
||||||
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';
|
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';
|
||||||
@ -28,7 +33,7 @@ import { ViewFieldsVisibilityDropdownSection } from '@/views/components/ViewFiel
|
|||||||
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
|
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
|
||||||
import { ViewType } from '@/views/types/ViewType';
|
import { ViewType } from '@/views/types/ViewType';
|
||||||
|
|
||||||
type RecordIndexOptionsMenu = 'fields';
|
type RecordIndexOptionsMenu = 'fields' | 'hiddenFields';
|
||||||
|
|
||||||
type RecordIndexOptionsDropdownContentProps = {
|
type RecordIndexOptionsDropdownContentProps = {
|
||||||
recordIndexId: string;
|
recordIndexId: string;
|
||||||
@ -43,6 +48,8 @@ export const RecordIndexOptionsDropdownContent = ({
|
|||||||
}: RecordIndexOptionsDropdownContentProps) => {
|
}: RecordIndexOptionsDropdownContentProps) => {
|
||||||
const { currentViewWithCombinedFiltersAndSorts } = useGetCurrentView();
|
const { currentViewWithCombinedFiltersAndSorts } = useGetCurrentView();
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { closeDropdown } = useDropdown(RECORD_INDEX_OPTIONS_DROPDOWN_ID);
|
const { closeDropdown } = useDropdown(RECORD_INDEX_OPTIONS_DROPDOWN_ID);
|
||||||
|
|
||||||
const [currentMenu, setCurrentMenu] = useState<
|
const [currentMenu, setCurrentMenu] = useState<
|
||||||
@ -55,6 +62,10 @@ export const RecordIndexOptionsDropdownContent = ({
|
|||||||
setCurrentMenu(option);
|
setCurrentMenu(option);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleEditClick = () => {
|
||||||
|
navigate(getSettingsPagePath(SettingsPath.Objects));
|
||||||
|
};
|
||||||
|
|
||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Escape],
|
[Key.Escape],
|
||||||
() => {
|
() => {
|
||||||
@ -142,20 +153,45 @@ export const RecordIndexOptionsDropdownContent = ({
|
|||||||
isDraggable
|
isDraggable
|
||||||
onDragEnd={handleReorderFields}
|
onDragEnd={handleReorderFields}
|
||||||
onVisibilityChange={handleChangeFieldVisibility}
|
onVisibilityChange={handleChangeFieldVisibility}
|
||||||
|
showSubheader={false}
|
||||||
/>
|
/>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<MenuItem
|
||||||
|
onClick={() => handleSelectMenu('hiddenFields')}
|
||||||
|
LeftIcon={IconEyeOff}
|
||||||
|
text="Hidden Fields"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{currentMenu === 'hiddenFields' && (
|
||||||
|
<>
|
||||||
|
<DropdownMenuHeader
|
||||||
|
StartIcon={IconChevronLeft}
|
||||||
|
onClick={() => setCurrentMenu('fields')}
|
||||||
|
>
|
||||||
|
Hidden Fields
|
||||||
|
</DropdownMenuHeader>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
{hiddenRecordFields.length > 0 && (
|
{hiddenRecordFields.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<ViewFieldsVisibilityDropdownSection
|
<ViewFieldsVisibilityDropdownSection
|
||||||
title="Hidden"
|
title="Hidden"
|
||||||
fields={hiddenRecordFields}
|
fields={hiddenRecordFields}
|
||||||
isDraggable={false}
|
isDraggable={false}
|
||||||
onVisibilityChange={handleChangeFieldVisibility}
|
onVisibilityChange={handleChangeFieldVisibility}
|
||||||
|
showSubheader={false}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<MenuItem
|
||||||
|
onClick={handleEditClick}
|
||||||
|
LeftIcon={IconSettings}
|
||||||
|
text="Edit Fields"
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{viewType === ViewType.Kanban && (
|
{viewType === ViewType.Kanban && (
|
||||||
<>
|
<>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
|
|||||||
@ -0,0 +1,94 @@
|
|||||||
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import {
|
||||||
|
CatalogDecorator,
|
||||||
|
CatalogDimension,
|
||||||
|
CatalogOptions,
|
||||||
|
CatalogStory,
|
||||||
|
ComponentDecorator,
|
||||||
|
ThemeColor,
|
||||||
|
} from 'twenty-ui';
|
||||||
|
|
||||||
|
import { MenuItemSelectTag } from '../MenuItemSelectTag';
|
||||||
|
|
||||||
|
const meta: Meta<typeof MenuItemSelectTag> = {
|
||||||
|
title: 'UI/Navigation/MenuItem/MenuItemSelectTag',
|
||||||
|
component: MenuItemSelectTag,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof MenuItemSelectTag>;
|
||||||
|
|
||||||
|
export const Default: Story = {
|
||||||
|
args: {
|
||||||
|
selected: false,
|
||||||
|
onClick: undefined,
|
||||||
|
text: 'Item A',
|
||||||
|
},
|
||||||
|
argTypes: {
|
||||||
|
selected: {
|
||||||
|
control: 'boolean',
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
onClick: {
|
||||||
|
control: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
decorators: [ComponentDecorator],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Catalog: CatalogStory<Story, typeof MenuItemSelectTag> = {
|
||||||
|
args: {
|
||||||
|
text: 'Item A',
|
||||||
|
},
|
||||||
|
parameters: {
|
||||||
|
pseudo: {
|
||||||
|
hover: ['.hover'],
|
||||||
|
active: ['.pressed'],
|
||||||
|
focus: ['.focus'],
|
||||||
|
},
|
||||||
|
catalog: {
|
||||||
|
dimensions: [
|
||||||
|
{
|
||||||
|
name: 'color',
|
||||||
|
values: [
|
||||||
|
'green',
|
||||||
|
'turquoise',
|
||||||
|
'sky',
|
||||||
|
'blue',
|
||||||
|
'purple',
|
||||||
|
'pink',
|
||||||
|
'red',
|
||||||
|
'orange',
|
||||||
|
'yellow',
|
||||||
|
'gray',
|
||||||
|
],
|
||||||
|
props: (color: ThemeColor) => ({ color }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'states',
|
||||||
|
values: ['default', 'hover', 'selected', 'hover+selected'],
|
||||||
|
props: (state: string) => {
|
||||||
|
switch (state) {
|
||||||
|
case 'default':
|
||||||
|
return {};
|
||||||
|
case 'hover':
|
||||||
|
return { className: 'hover' };
|
||||||
|
case 'selected':
|
||||||
|
return { selected: true };
|
||||||
|
case 'hover+selected':
|
||||||
|
return { className: 'hover', selected: true };
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
labels: (state: string) => `State: ${state}`,
|
||||||
|
},
|
||||||
|
] as CatalogDimension[],
|
||||||
|
options: {
|
||||||
|
elementContainer: { width: 200 },
|
||||||
|
} as CatalogOptions,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
decorators: [CatalogDecorator],
|
||||||
|
};
|
||||||
@ -7,9 +7,9 @@ import {
|
|||||||
} from '@hello-pangea/dnd';
|
} from '@hello-pangea/dnd';
|
||||||
import {
|
import {
|
||||||
AppTooltip,
|
AppTooltip,
|
||||||
|
IconEye,
|
||||||
|
IconEyeOff,
|
||||||
IconInfoCircle,
|
IconInfoCircle,
|
||||||
IconMinus,
|
|
||||||
IconPlus,
|
|
||||||
useIcons,
|
useIcons,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ type ViewFieldsVisibilityDropdownSectionProps = {
|
|||||||
field: Omit<ColumnDefinition<FieldMetadata>, 'size' | 'position'>,
|
field: Omit<ColumnDefinition<FieldMetadata>, 'size' | 'position'>,
|
||||||
) => void;
|
) => void;
|
||||||
title: string;
|
title: string;
|
||||||
|
showSubheader: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ViewFieldsVisibilityDropdownSection = ({
|
export const ViewFieldsVisibilityDropdownSection = ({
|
||||||
@ -41,6 +42,7 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
|||||||
onDragEnd,
|
onDragEnd,
|
||||||
onVisibilityChange,
|
onVisibilityChange,
|
||||||
title,
|
title,
|
||||||
|
showSubheader = true,
|
||||||
}: ViewFieldsVisibilityDropdownSectionProps) => {
|
}: ViewFieldsVisibilityDropdownSectionProps) => {
|
||||||
const handleOnDrag = (result: DropResult, provided: ResponderProvided) => {
|
const handleOnDrag = (result: DropResult, provided: ResponderProvided) => {
|
||||||
onDragEnd?.(result, provided);
|
onDragEnd?.(result, provided);
|
||||||
@ -69,7 +71,7 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
|||||||
field.isLabelIdentifier
|
field.isLabelIdentifier
|
||||||
? null
|
? null
|
||||||
: {
|
: {
|
||||||
Icon: field.isVisible ? IconMinus : IconPlus,
|
Icon: field.isVisible ? IconEyeOff : IconEye,
|
||||||
onClick: () => onVisibilityChange(field),
|
onClick: () => onVisibilityChange(field),
|
||||||
},
|
},
|
||||||
].filter(isDefined);
|
].filter(isDefined);
|
||||||
@ -94,7 +96,9 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={ref}>
|
<div ref={ref}>
|
||||||
<StyledDropdownMenuSubheader>{title}</StyledDropdownMenuSubheader>
|
{showSubheader && (
|
||||||
|
<StyledDropdownMenuSubheader>{title}</StyledDropdownMenuSubheader>
|
||||||
|
)}
|
||||||
<DropdownMenuItemsContainer>
|
<DropdownMenuItemsContainer>
|
||||||
{nonDraggableItems.map((field, fieldIndex) => (
|
{nonDraggableItems.map((field, fieldIndex) => (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
Reference in New Issue
Block a user