diff --git a/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx b/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx index 6b285ca4f..33aebff64 100644 --- a/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx +++ b/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx @@ -4,7 +4,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; type AttachmentDropdownProps = { @@ -18,9 +17,9 @@ export const AttachmentDropdown = ({ onDelete, scopeKey, }: AttachmentDropdownProps) => { - const dropdownScopeId = `${scopeKey}-settings-field-active-action-dropdown`; + const dropdownId = `${scopeKey}-settings-field-active-action-dropdown`; - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); const handleDownload = () => { onDownload(); @@ -33,32 +32,31 @@ export const AttachmentDropdown = ({ }; return ( - - - } - dropdownComponents={ - - - - - - - } - dropdownHotkeyScope={{ - scope: dropdownScopeId, - }} - /> - + + } + dropdownComponents={ + + + + + + + } + dropdownHotkeyScope={{ + scope: dropdownId, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/companies/board/components/CompanyBoard.tsx b/packages/twenty-front/src/modules/companies/board/components/CompanyBoard.tsx index 4199612ca..effe58897 100644 --- a/packages/twenty-front/src/modules/companies/board/components/CompanyBoard.tsx +++ b/packages/twenty-front/src/modules/companies/board/components/CompanyBoard.tsx @@ -6,6 +6,7 @@ import { RecordBoardProps, } from '@/object-record/record-board/components/RecordBoard'; import { RecordBoardEffect } from '@/object-record/record-board/components/RecordBoardEffect'; +import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId'; import { RecordBoardOptionsDropdown } from '@/object-record/record-board/options/components/RecordBoardOptionsDropdown'; import { ViewBar } from '@/views/components/ViewBar'; import { useViewFields } from '@/views/hooks/internal/useViewFields'; @@ -43,7 +44,7 @@ export const CompanyBoard = ({ optionsDropdownButton={ } - optionsDropdownScopeId={recordBoardId} + optionsDropdownScopeId={BoardOptionsDropdownId} /> - } - dropdownComponents={} - dropdownHotkeyScope={hotkeyScope} - dropdownOffset={{ y: 8 }} - /> - + } + dropdownComponents={} + dropdownHotkeyScope={hotkeyScope} + dropdownOffset={{ y: 8 }} + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersDropdownFilterOnFilterChangedEffect.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersDropdownFilterOnFilterChangedEffect.tsx index 477e74d34..2074b0489 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersDropdownFilterOnFilterChangedEffect.tsx +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersDropdownFilterOnFilterChangedEffect.tsx @@ -1,5 +1,6 @@ import { useEffect } from 'react'; +import { ObjectFilterDropdownId } from '@/object-record/object-filter-dropdown/constants/ObjectFilterDropdownId'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; export const MultipleFiltersDropdownFilterOnFilterChangedEffect = ({ @@ -7,7 +8,7 @@ export const MultipleFiltersDropdownFilterOnFilterChangedEffect = ({ }: { filterDefinitionUsedInDropdownType: string | undefined; }) => { - const { setDropdownWidth } = useDropdown(); + const { setDropdownWidth } = useDropdown(ObjectFilterDropdownId); useEffect(() => { switch (filterDefinitionUsedInDropdownType) { diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownEntitySearchSelect.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownEntitySearchSelect.tsx index 1b5a6bb7b..b05854601 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownEntitySearchSelect.tsx +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownEntitySearchSelect.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react'; +import { ObjectFilterDropdownId } from '@/object-record/object-filter-dropdown/constants/ObjectFilterDropdownId'; import { useFilterDropdown } from '@/object-record/object-filter-dropdown/hooks/useFilterDropdown'; import { EntitiesForMultipleEntitySelect } from '@/object-record/relation-picker/components/MultipleEntitySelect'; import { SingleEntitySelectMenuItems } from '@/object-record/relation-picker/components/SingleEntitySelectMenuItems'; @@ -21,7 +22,7 @@ export const ObjectFilterDropdownEntitySearchSelect = ({ selectFilter, } = useFilterDropdown(); - const { closeDropdown } = useDropdown(); + const { closeDropdown } = useDropdown(ObjectFilterDropdownId); const [isAllEntitySelected, setIsAllEntitySelected] = useState(false); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/SingleEntityObjectFilterDropdownButton.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/SingleEntityObjectFilterDropdownButton.tsx index bbf302975..f87665839 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/SingleEntityObjectFilterDropdownButton.tsx +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/SingleEntityObjectFilterDropdownButton.tsx @@ -5,7 +5,6 @@ import { useFilterDropdown } from '@/object-record/object-filter-dropdown/hooks/ import { IconChevronDown } from '@/ui/display/icon/index'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { StyledHeaderDropdownButton } from '@/ui/layout/dropdown/components/StyledHeaderDropdownButton'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; import { ViewFilterOperand } from '@/views/types/ViewFilterOperand'; @@ -42,34 +41,33 @@ export const SingleEntityObjectFilterDropdownButton = ({ const theme = useTheme(); return ( - - - {selectedFilter ? ( - - ) : ( - 'Filter' - )} - - - } - dropdownComponents={ - <> - - - > - } - /> - + + {selectedFilter ? ( + + ) : ( + 'Filter' + )} + + + } + dropdownComponents={ + <> + + + > + } + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx index 02ca68657..dc98dd90e 100644 --- a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx +++ b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx @@ -10,7 +10,6 @@ import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenu import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; @@ -70,63 +69,60 @@ export const ObjectSortDropdownButton = ({ return ( - - - } - dropdownComponents={ - <> - {isSortDirectionMenuUnfolded ? ( + + } + dropdownComponents={ + <> + {isSortDirectionMenuUnfolded ? ( + + {SORT_DIRECTIONS.map((sortOrder, index) => ( + { + setSelectedSortDirection(sortOrder); + setIsSortDirectionMenuUnfolded(false); + }} + text={sortOrder === 'asc' ? 'Ascending' : 'Descending'} + /> + ))} + + ) : ( + <> + setIsSortDirectionMenuUnfolded(true)} + > + {selectedSortDirection === 'asc' ? 'Ascending' : 'Descending'} + + - {SORT_DIRECTIONS.map((sortOrder, index) => ( - { - setSelectedSortDirection(sortOrder); - setIsSortDirectionMenuUnfolded(false); - }} - text={sortOrder === 'asc' ? 'Ascending' : 'Descending'} - /> - ))} + {[...availableSortDefinitions] + .sort((a, b) => a.label.localeCompare(b.label)) + .map((availableSortDefinition, index) => ( + handleAddSort(availableSortDefinition)} + LeftIcon={getIcon(availableSortDefinition.iconName)} + text={availableSortDefinition.label} + /> + ))} - ) : ( - <> - setIsSortDirectionMenuUnfolded(true)} - > - {selectedSortDirection === 'asc' - ? 'Ascending' - : 'Descending'} - - - - {[...availableSortDefinitions] - .sort((a, b) => a.label.localeCompare(b.label)) - .map((availableSortDefinition, index) => ( - handleAddSort(availableSortDefinition)} - LeftIcon={getIcon(availableSortDefinition.iconName)} - text={availableSortDefinition.label} - /> - ))} - - > - )} - > - } - onClose={handleDropdownButtonClose} - /> - + > + )} + > + } + onClose={handleDropdownButtonClose} + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-board/constants/BoardOptionsDropdownId.ts b/packages/twenty-front/src/modules/object-record/record-board/constants/BoardOptionsDropdownId.ts new file mode 100644 index 000000000..d68691780 --- /dev/null +++ b/packages/twenty-front/src/modules/object-record/record-board/constants/BoardOptionsDropdownId.ts @@ -0,0 +1 @@ +export const BoardOptionsDropdownId = 'board-options-dropdown-id'; diff --git a/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdown.tsx b/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdown.tsx index 101061660..26fcdb9bc 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdown.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdown.tsx @@ -1,8 +1,7 @@ +import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId'; import { useViewBar } from '@/views/hooks/useViewBar'; import { Dropdown } from '../../../../ui/layout/dropdown/components/Dropdown'; -import { DropdownScope } from '../../../../ui/layout/dropdown/scopes/DropdownScope'; -import { BoardOptionsDropdownId } from '../../components/constants/BoardOptionsDropdownId'; import { BoardOptionsHotkeyScope } from '../../types/BoardOptionsHotkeyScope'; import { RecordBoardOptionsDropdownButton } from './RecordBoardOptionsDropdownButton'; @@ -23,19 +22,18 @@ export const RecordBoardOptionsDropdown = ({ const { setViewEditMode } = useViewBar(); return ( - - } - dropdownComponents={ - - } - dropdownHotkeyScope={{ scope: BoardOptionsHotkeyScope.Dropdown }} - onClickOutside={() => setViewEditMode('none')} - dropdownMenuWidth={170} - /> - + } + dropdownComponents={ + + } + dropdownHotkeyScope={{ scope: BoardOptionsHotkeyScope.Dropdown }} + onClickOutside={() => setViewEditMode('none')} + dropdownMenuWidth={170} + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownButton.tsx b/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownButton.tsx index 6325b4a6b..12492a5c6 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownButton.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownButton.tsx @@ -1,8 +1,11 @@ +import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId'; import { StyledHeaderDropdownButton } from '@/ui/layout/dropdown/components/StyledHeaderDropdownButton'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; export const RecordBoardOptionsDropdownButton = () => { - const { isDropdownOpen, toggleDropdown } = useDropdown(); + const { isDropdownOpen, toggleDropdown } = useDropdown( + BoardOptionsDropdownId, + ); const handleClick = () => { toggleDropdown(); diff --git a/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownContent.tsx b/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownContent.tsx index 4498dd83a..237469edd 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownContent.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/options/components/RecordBoardOptionsDropdownContent.tsx @@ -4,6 +4,7 @@ import { useRecoilState, useRecoilValue } from 'recoil'; import { Key } from 'ts-key-enum'; import { v4 } from 'uuid'; +import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId'; import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates'; import { IconBaselineDensitySmall, @@ -110,7 +111,7 @@ export const RecordBoardOptionsDropdownContent = ({ recordBoardScopeId: recordBoardId, }); - const { closeDropdown } = useDropdown(); + const { closeDropdown } = useDropdown(BoardOptionsDropdownId); const handleReorderField: OnDragEndResponder = useCallback( (result) => { diff --git a/packages/twenty-front/src/modules/object-record/record-relation-card/components/RecordRelationFieldCardSection.tsx b/packages/twenty-front/src/modules/object-record/record-relation-card/components/RecordRelationFieldCardSection.tsx index 87392588a..56e324bec 100644 --- a/packages/twenty-front/src/modules/object-record/record-relation-card/components/RecordRelationFieldCardSection.tsx +++ b/packages/twenty-front/src/modules/object-record/record-relation-card/components/RecordRelationFieldCardSection.tsx @@ -23,7 +23,6 @@ import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { Card } from '@/ui/layout/card/components/Card'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { Section } from '@/ui/layout/section/components/Section'; const StyledAddDropdown = styled(Dropdown)` @@ -129,9 +128,9 @@ export const RecordRelationFieldCardSection = () => { ); }, [relationRecords, upsertRecordFromState]); - const dropdownScopeId = `record-field-card-relation-picker-${fieldDefinition.label}`; + const dropdownId = `record-field-card-relation-picker-${fieldDefinition.label}`; - const { closeDropdown, isDropdownOpen } = useDropdown(dropdownScopeId); + const { closeDropdown, isDropdownOpen } = useDropdown(dropdownId); const { identifiersMapper, @@ -196,30 +195,29 @@ export const RecordRelationFieldCardSection = () => { {fieldDefinition.label} - - - } - dropdownComponents={ - - } - dropdownHotkeyScope={{ - scope: dropdownScopeId, - }} - /> - + + } + dropdownComponents={ + + } + dropdownHotkeyScope={{ + scope: dropdownId, + }} + /> {!!relationRecords.length && ( diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHeadWithDropdown.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHeadWithDropdown.tsx index be45fa901..a90a85d3b 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHeadWithDropdown.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHeadWithDropdown.tsx @@ -1,7 +1,6 @@ import styled from '@emotion/styled'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { FieldMetadata } from '../../field/types/FieldMetadata'; import { ColumnDefinition } from '../types/ColumnDefinition'; @@ -28,21 +27,20 @@ export const ColumnHeadWithDropdown = ({ primaryColumnKey, }: ColumnHeadWithDropdownProps) => { return ( - - } - dropdownComponents={ - - } - dropdownOffset={{ x: -1 }} - dropdownPlacement="bottom-start" - dropdownHotkeyScope={{ scope: column.fieldMetadataId + '-header' }} - /> - + } + dropdownComponents={ + + } + dropdownOffset={{ x: -1 }} + dropdownPlacement="bottom-start" + dropdownHotkeyScope={{ scope: column.fieldMetadataId + '-header' }} + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx index d43ac048b..37d11b13c 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx @@ -6,7 +6,6 @@ import { RecordTableHeaderCell } from '@/object-record/record-table/components/R import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector'; import { IconPlus } from '@/ui/display/icon'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { useScrollWrapperScopedRef } from '@/ui/utilities/scroll/hooks/useScrollWrapperScopedRef'; import { useRecordTableScopedStates } from '../hooks/internal/useRecordTableScopedStates'; @@ -48,7 +47,7 @@ const StyledPlusIconContainer = styled.div` width: 32px; `; -const HIDDEN_TABLE_COLUMN_DROPDOWN_SCOPE_ID = +export const HIDDEN_TABLE_COLUMN_DROPDOWN_ID = 'hidden-table-columns-dropdown-scope-id'; const HIDDEN_TABLE_COLUMN_DROPDOWN_HOTKEY_SCOPE_ID = @@ -106,22 +105,19 @@ export const RecordTableHeader = ({ isTableWiderThanScreen={isTableWiderThanScreen} > {hiddenTableColumns.length > 0 && ( - - - - - } - dropdownComponents={} - dropdownPlacement="bottom-start" - dropdownHotkeyScope={{ - scope: HIDDEN_TABLE_COLUMN_DROPDOWN_HOTKEY_SCOPE_ID, - }} - /> - + + + + } + dropdownComponents={} + dropdownPlacement="bottom-start" + dropdownHotkeyScope={{ + scope: HIDDEN_TABLE_COLUMN_DROPDOWN_HOTKEY_SCOPE_ID, + }} + /> )} diff --git a/packages/twenty-front/src/modules/object-record/record-table/constants/ColumnHeadDropdownId.ts b/packages/twenty-front/src/modules/object-record/record-table/constants/ColumnHeadDropdownId.ts index 58b4d2735..767e31d61 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/constants/ColumnHeadDropdownId.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/constants/ColumnHeadDropdownId.ts @@ -1 +1 @@ -export const ColumnHeadDropdownId = 'table-head-options'; +export const ColumnHeadDropdownId = 'table-head-options-dropdown-id'; diff --git a/packages/twenty-front/src/modules/object-record/record-board/components/constants/BoardOptionsDropdownId.ts b/packages/twenty-front/src/modules/object-record/record-table/constants/TableHiddenFieldsDropdownId.ts similarity index 58% rename from packages/twenty-front/src/modules/object-record/record-board/components/constants/BoardOptionsDropdownId.ts rename to packages/twenty-front/src/modules/object-record/record-table/constants/TableHiddenFieldsDropdownId.ts index 6085a3301..ce9714934 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/components/constants/BoardOptionsDropdownId.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/constants/TableHiddenFieldsDropdownId.ts @@ -1,2 +1,2 @@ // We should either apply the constant all caps case or maybe define a more general enum to store those ids ? -export const BoardOptionsDropdownId = 'board-options'; +export const TableHiddenFieldsDropdownId = 'table-hidden-fields-dropdown-id'; diff --git a/packages/twenty-front/src/modules/object-record/record-table/constants/TableOptionsDropdownId.ts b/packages/twenty-front/src/modules/object-record/record-table/constants/TableOptionsDropdownId.ts index 2755b8c91..57628d119 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/constants/TableOptionsDropdownId.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/constants/TableOptionsDropdownId.ts @@ -1,2 +1,2 @@ // We should either apply the constant all caps case or maybe define a more general enum to store those ids ? -export const TableOptionsDropdownId = 'table-options'; +export const TableOptionsDropdownId = 'table-options-dropdown-id'; diff --git a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdown.tsx b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdown.tsx index 44bdd29dc..874268a2f 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdown.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdown.tsx @@ -1,5 +1,4 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { useViewBar } from '@/views/hooks/useViewBar'; import { TableOptionsDropdownId } from '../../constants/TableOptionsDropdownId'; @@ -18,19 +17,18 @@ export const TableOptionsDropdown = ({ const { setViewEditMode } = useViewBar(); return ( - - } - dropdownHotkeyScope={{ scope: TableOptionsHotkeyScope.Dropdown }} - dropdownOffset={{ y: 8 }} - dropdownComponents={ - - } - onClickOutside={() => setViewEditMode('none')} - /> - + } + dropdownHotkeyScope={{ scope: TableOptionsHotkeyScope.Dropdown }} + dropdownOffset={{ y: 8 }} + dropdownComponents={ + + } + onClickOutside={() => setViewEditMode('none')} + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx index 9d17d9642..c257a5e9b 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx @@ -3,6 +3,7 @@ import { OnDragEndResponder } from '@hello-pangea/dnd'; import { useRecoilValue } from 'recoil'; import { Key } from 'ts-key-enum'; +import { TableOptionsDropdownId } from '@/object-record/record-table/constants/TableOptionsDropdownId'; import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates'; import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector'; import { IconChevronLeft, IconFileImport, IconTag } from '@/ui/display/icon'; @@ -34,7 +35,7 @@ export const TableOptionsDropdownContent = ({ const viewEditMode = useRecoilValue(viewEditModeState); const currentView = useRecoilValue(currentViewSelector); - const { closeDropdown } = useDropdown(); + const { closeDropdown } = useDropdown(TableOptionsDropdownId); const [currentMenu, setCurrentMenu] = useState( undefined, diff --git a/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx b/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx index 9460d4ba4..3216578ec 100644 --- a/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx +++ b/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx @@ -8,7 +8,6 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { IconButton } from '@/ui/input/button/components/IconButton'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { logError } from '~/utils/logError'; export const PipelineAddButton = () => { @@ -48,33 +47,32 @@ export const PipelineAddButton = () => { }; return ( - - - } - dropdownComponents={ - - } - hotkey={{ - key: 'c', - scope: PageHotkeyScope.OpportunitiesPage, - }} - dropdownHotkeyScope={{ - scope: RelationPickerHotkeyScope.RelationPicker, - }} - /> - + + } + dropdownComponents={ + + } + hotkey={{ + key: 'c', + scope: PageHotkeyScope.OpportunitiesPage, + }} + dropdownHotkeyScope={{ + scope: RelationPickerHotkeyScope.RelationPicker, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx index 963c7b2fd..a9c1c421f 100644 --- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx +++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx @@ -7,7 +7,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; type SettingsAccountsRowDropdownMenuProps = { @@ -21,46 +20,45 @@ export const SettingsAccountsRowDropdownMenu = ({ className, onRemove, }: SettingsAccountsRowDropdownMenuProps) => { - const dropdownScopeId = `settings-account-row-${account.id}`; + const dropdownId = `settings-account-row-${account.id}`; const navigate = useNavigate(); - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); return ( - - - } - dropdownComponents={ - - + + } + dropdownComponents={ + + + { + navigate(`/settings/accounts/emails/${account.id}`); + closeDropdown(); + }} + /> + {!!onRemove && ( { - navigate(`/settings/accounts/emails/${account.id}`); + onRemove(account.id); closeDropdown(); }} /> - {!!onRemove && ( - { - onRemove(account.id); - closeDropdown(); - }} - /> - )} - - - } - /> - + )} + + + } + /> ); }; diff --git a/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldRelationForm.tsx b/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldRelationForm.tsx index 1b409a983..b2ef117b6 100644 --- a/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldRelationForm.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldRelationForm.tsx @@ -105,7 +105,7 @@ export const SettingsObjectFieldRelationForm = ({ onChange({ diff --git a/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx b/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx index 205853f25..ef71223fa 100644 --- a/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx @@ -17,7 +17,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { MenuItemSelectColor } from '@/ui/navigation/menu-item/components/MenuItemSelectColor'; import { mainColorNames } from '@/ui/theme/constants/colors'; @@ -63,16 +62,14 @@ export const SettingsObjectFieldSelectFormOptionRow = ({ }: SettingsObjectFieldSelectFormOptionRowProps) => { const theme = useTheme(); - const dropdownScopeIds = useMemo(() => { + const dropdownIds = useMemo(() => { const baseScopeId = `select-field-option-row-${v4()}`; return { color: `${baseScopeId}-color`, actions: `${baseScopeId}-actions` }; }, []); - const { closeDropdown: closeColorDropdown } = useDropdown( - dropdownScopeIds.color, - ); + const { closeDropdown: closeColorDropdown } = useDropdown(dropdownIds.color); const { closeDropdown: closeActionsDropdown } = useDropdown( - dropdownScopeIds.actions, + dropdownIds.actions, ); return ( @@ -82,82 +79,80 @@ export const SettingsObjectFieldSelectFormOptionRow = ({ stroke={theme.icon.stroke.sm} color={theme.font.color.extraLight} /> - - } - dropdownComponents={ - - - {mainColorNames.map((colorName) => ( - { - onChange({ ...option, color: colorName }); - closeColorDropdown(); - }} - color={colorName} - selected={colorName === option.color} - /> - ))} - - - } - /> - + } + dropdownComponents={ + + + {mainColorNames.map((colorName) => ( + { + onChange({ ...option, color: colorName }); + closeColorDropdown(); + }} + color={colorName} + selected={colorName === option.color} + /> + ))} + + + } + /> onChange({ ...option, label })} RightIcon={isDefault ? IconCheck : undefined} /> - - } - dropdownComponents={ - - - {isDefault ? ( - { - onChange({ ...option, isDefault: false }); - closeActionsDropdown(); - }} - /> - ) : ( - { - onChange({ ...option, isDefault: true }); - closeActionsDropdown(); - }} - /> - )} - {!!onRemove && ( - { - onRemove(); - closeActionsDropdown(); - }} - /> - )} - - - } - /> - + } + dropdownComponents={ + + + {isDefault ? ( + { + onChange({ ...option, isDefault: false }); + closeActionsDropdown(); + }} + /> + ) : ( + { + onChange({ ...option, isDefault: true }); + closeActionsDropdown(); + }} + /> + )} + {!!onRemove && ( + { + onRemove(); + closeActionsDropdown(); + }} + /> + )} + + + } + /> ); }; diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx index e93da2324..cf60f1357 100644 --- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx @@ -12,7 +12,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { Section } from '@/ui/layout/section/components/Section'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; @@ -44,7 +43,7 @@ const StyledTag = styled(Tag)` height: ${({ theme }) => theme.spacing(6)}; `; -const dropdownScopeId = 'settings-object-edit-about-menu-dropdown'; +const dropdownId = 'settings-object-edit-about-menu-dropdown'; export const SettingsAboutSection = ({ iconKey = '', @@ -57,7 +56,7 @@ export const SettingsAboutSection = ({ const { getIcon } = useIcons(); const Icon = getIcon(iconKey); - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); const handleEdit = () => { onEdit(); @@ -83,32 +82,31 @@ export const SettingsAboutSection = ({ ) : ( )} - - - } - dropdownComponents={ - - - - - - - } - dropdownHotkeyScope={{ - scope: dropdownScopeId, - }} - /> - + + } + dropdownComponents={ + + + + + + + } + dropdownHotkeyScope={{ + scope: dropdownId, + }} + /> diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx index e739e882a..cdbfb0b6a 100644 --- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx @@ -9,7 +9,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; type SettingsObjectFieldActiveActionDropdownProps = { @@ -25,9 +24,9 @@ export const SettingsObjectFieldActiveActionDropdown = ({ onEdit, scopeKey, }: SettingsObjectFieldActiveActionDropdownProps) => { - const dropdownScopeId = `${scopeKey}-settings-field-active-action-dropdown`; + const dropdownId = `${scopeKey}-settings-field-active-action-dropdown`; - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); const handleEdit = () => { onEdit(); @@ -40,33 +39,32 @@ export const SettingsObjectFieldActiveActionDropdown = ({ }; return ( - - - } - dropdownComponents={ - - + + } + dropdownComponents={ + + + + {!!onDisable && ( - {!!onDisable && ( - - )} - - - } - dropdownHotkeyScope={{ - scope: dropdownScopeId, - }} - /> - + )} + + + } + dropdownHotkeyScope={{ + scope: dropdownId, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx index a80638e4b..101d5aac2 100644 --- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx @@ -4,7 +4,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; type SettingsObjectFieldDisabledActionDropdownProps = { @@ -18,9 +17,9 @@ export const SettingsObjectFieldDisabledActionDropdown = ({ onActivate, scopeKey, }: SettingsObjectFieldDisabledActionDropdownProps) => { - const dropdownScopeId = `${scopeKey}-settings-field-disabled-action-dropdown`; + const dropdownId = `${scopeKey}-settings-field-disabled-action-dropdown`; - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); const handleActivate = () => { onActivate(); @@ -33,20 +32,20 @@ export const SettingsObjectFieldDisabledActionDropdown = ({ // }; return ( - - - } - dropdownComponents={ - - - - {/* {isCustomField && ( + + } + dropdownComponents={ + + + + {/* {isCustomField && ( )} */} - - - } - dropdownHotkeyScope={{ - scope: dropdownScopeId, - }} - /> - + + + } + dropdownHotkeyScope={{ + scope: dropdownId, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx b/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx index b2a5e4781..18bb9b5f2 100644 --- a/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx @@ -4,7 +4,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; type SettingsObjectDisabledMenuDropDownProps = { @@ -20,9 +19,9 @@ export const SettingsObjectDisabledMenuDropDown = ({ onErase, isCustomObject, }: SettingsObjectDisabledMenuDropDownProps) => { - const dropdownScopeId = `${scopeKey}-settings-object-disabled-menu-dropdown`; + const dropdownId = `${scopeKey}-settings-object-disabled-menu-dropdown`; - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); const handleActivate = () => { onActivate(); @@ -35,34 +34,33 @@ export const SettingsObjectDisabledMenuDropDown = ({ }; return ( - - - } - dropdownComponents={ - - + + } + dropdownComponents={ + + + + {isCustomObject && ( - {isCustomObject && ( - - )} - - - } - dropdownHotkeyScope={{ - scope: dropdownScopeId, - }} - /> - + )} + + + } + dropdownHotkeyScope={{ + scope: dropdownId, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx b/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx index 97182ec1c..bd6d27866 100644 --- a/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx @@ -11,7 +11,6 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop import { DropdownMenuSearchInput } from '@/ui/layout/dropdown/components/DropdownMenuSearchInput'; import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList'; import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; @@ -23,7 +22,7 @@ import { IconPickerHotkeyScope } from '../types/IconPickerHotkeyScope'; type IconPickerProps = { disabled?: boolean; - dropdownScopeId?: string; + dropdownId?: string; onChange: (params: { iconKey: string; Icon: IconComponent }) => void; selectedIconKey?: string; onClickOutside?: () => void; @@ -80,7 +79,7 @@ const IconPickerIcon = ({ export const IconPicker = ({ disabled, - dropdownScopeId = 'icon-picker', + dropdownId = 'icon-picker', onChange, selectedIconKey, onClickOutside, @@ -95,7 +94,7 @@ export const IconPicker = ({ setHotkeyScopeAndMemorizePreviousScope, } = usePreviousHotkeyScope(); - const { closeDropdown } = useDropdown(dropdownScopeId); + const { closeDropdown } = useDropdown(dropdownId); const { getIcons, getIcon } = useIcons(); const icons = getIcons(); @@ -126,71 +125,70 @@ export const IconPicker = ({ ); return ( - - - - } - dropdownMenuWidth={176} - dropdownComponents={ - { - onChange({ iconKey, Icon: getIcon(iconKey) }); - closeDropdown(); - }} - > - - setSearchString(event.target.value)} - /> - - { - setHotkeyScopeAndMemorizePreviousScope( - IconPickerHotkeyScope.IconPicker, - ); - }} - onMouseLeave={goBackToPreviousHotkeyScope} - > - - - {iconKeys.map((iconKey) => ( - { - onChange({ iconKey, Icon: getIcon(iconKey) }); - closeDropdown(); - }} - selectedIconKey={selectedIconKey} - Icon={getIcon(iconKey)} - /> - ))} - - - - - - } - onClickOutside={onClickOutside} - onClose={() => { - onClose?.(); - setSearchString(''); - }} - onOpen={onOpen} - /> - - + + + } + dropdownMenuWidth={176} + dropdownComponents={ + { + onChange({ iconKey, Icon: getIcon(iconKey) }); + closeDropdown(); + }} + > + + setSearchString(event.target.value)} + /> + + { + setHotkeyScopeAndMemorizePreviousScope( + IconPickerHotkeyScope.IconPicker, + ); + }} + onMouseLeave={goBackToPreviousHotkeyScope} + > + + + {iconKeys.map((iconKey) => ( + { + onChange({ iconKey, Icon: getIcon(iconKey) }); + closeDropdown(); + }} + selectedIconKey={selectedIconKey} + Icon={getIcon(iconKey)} + /> + ))} + + + + + + } + onClickOutside={onClickOutside} + onClose={() => { + onClose?.(); + setSearchString(''); + }} + onOpen={onOpen} + /> + ); }; diff --git a/packages/twenty-front/src/modules/ui/input/components/Select.tsx b/packages/twenty-front/src/modules/ui/input/components/Select.tsx index 56fca8ed9..c58404085 100644 --- a/packages/twenty-front/src/modules/ui/input/components/Select.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/Select.tsx @@ -6,7 +6,6 @@ import { IconComponent } from '@/ui/display/icon/types/IconComponent'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { SelectHotkeyScope } from '../types/SelectHotkeyScope'; @@ -98,31 +97,30 @@ export const Select = ({ {selectControl} ) : ( - - - {!!label && {label}} - - {options.map((option) => ( - { - onChange?.(option.value); - closeDropdown(); - }} - /> - ))} - - } - dropdownHotkeyScope={{ scope: SelectHotkeyScope.Select }} - /> - - + + {!!label && {label}} + + {options.map((option) => ( + { + onChange?.(option.value); + closeDropdown(); + }} + /> + ))} + + } + dropdownHotkeyScope={{ scope: SelectHotkeyScope.Select }} + /> + ); }; diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx index 74eec4252..8f5aa8119 100644 --- a/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx @@ -9,7 +9,6 @@ import { CountryCallingCode } from 'libphonenumber-js'; import { IconChevronDown, IconWorld } from '@/ui/display/icon'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { CountryPickerHotkeyScope } from '../types/CountryPickerHotkeyScope'; @@ -119,27 +118,26 @@ export const CountryPickerDropdownButton = ({ }, [countries, value]); return ( - - - - {selectedCountry ? : } - - - - } - dropdownComponents={ - - } - dropdownPlacement="bottom-start" - dropdownOffset={{ x: 0, y: 4 }} - /> - + + + {selectedCountry ? : } + + + + } + dropdownComponents={ + + } + dropdownPlacement="bottom-start" + dropdownOffset={{ x: 0, y: 4 }} + /> ); }; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx index 2f9866221..57f1bc0b4 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx @@ -9,6 +9,7 @@ import { } from '@floating-ui/react'; import { Key } from 'ts-key-enum'; +import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { HotkeyEffect } from '@/ui/utilities/hotkey/components/HotkeyEffect'; import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; @@ -29,6 +30,7 @@ type DropdownProps = { scope: string; }; dropdownHotkeyScope: HotkeyScope; + dropdownId: string; dropdownPlacement?: Placement; dropdownMenuWidth?: number; dropdownOffset?: { x?: number; y?: number }; @@ -43,6 +45,7 @@ export const Dropdown = ({ dropdownComponents, dropdownMenuWidth, hotkey, + dropdownId, dropdownHotkeyScope, dropdownPlacement = 'bottom-end', dropdownOffset = { x: 0, y: 0 }, @@ -53,8 +56,7 @@ export const Dropdown = ({ const containerRef = useRef(null); const { isDropdownOpen, toggleDropdown, closeDropdown, dropdownWidth } = - useDropdown(); - + useDropdown(dropdownId); const offsetMiddlewares = []; if (dropdownOffset.x) { @@ -87,6 +89,7 @@ export const Dropdown = ({ }); useInternalHotkeyScopeManagement({ + dropdownScopeId: `${dropdownId}-scope`, dropdownHotkeyScopeFromParent: dropdownHotkeyScope, }); @@ -100,36 +103,38 @@ export const Dropdown = ({ ); return ( - - {clickableComponent && ( - - {clickableComponent} - - )} - {hotkey && ( - + + {clickableComponent && ( + + {clickableComponent} + + )} + {hotkey && ( + + )} + {isDropdownOpen && ( + + {dropdownComponents} + + )} + - )} - {isDropdownOpen && ( - - {dropdownComponents} - - )} - - + + ); }; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/DropdownMenu.stories.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/DropdownMenu.stories.tsx index ae11a6cff..0e2a412a6 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/DropdownMenu.stories.tsx +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/DropdownMenu.stories.tsx @@ -12,7 +12,6 @@ import { MenuItemSelectAvatar } from '@/ui/navigation/menu-item/components/MenuI import { Avatar } from '@/users/components/Avatar'; import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator'; -import { DropdownScope } from '../../scopes/DropdownScope'; import { Dropdown } from '../Dropdown'; import { DropdownMenuHeader } from '../DropdownMenuHeader'; import { DropdownMenuInput } from '../DropdownMenuInput'; @@ -25,18 +24,12 @@ const meta: Meta = { title: 'UI/Layout/Dropdown/Dropdown', component: Dropdown, - decorators: [ - ComponentDecorator, - (Story) => ( - - - - ), - ], + decorators: [ComponentDecorator, (Story) => ], args: { clickableComponent: , dropdownHotkeyScope: { scope: 'testDropdownMenu' }, dropdownOffset: { x: 0, y: 8 }, + dropdownId: 'test-dropdown-id', }, argTypes: { clickableComponent: { control: false }, diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownScopedStates.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownScopedStates.ts deleted file mode 100644 index 01e2798c8..000000000 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownScopedStates.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { DropdownScopeInternalContext } from '@/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext'; -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { useScopedState } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState'; - -type UseDropdownScopedStatesProps = { - dropdownScopeId?: string; -}; - -export const useDropdownScopedStates = ({ - dropdownScopeId, -}: UseDropdownScopedStatesProps) => { - const scopeId = useAvailableScopeIdOrThrow( - DropdownScopeInternalContext, - dropdownScopeId, - ); - - const { - getScopedState, - getScopedFamilyState, - getScopedSnapshotValue, - getScopedFamilySnapshotValue, - } = useScopedState(scopeId); - - return { - scopeId, - injectStateWithDropdownScopeId: getScopedState, - injectFamilyStateWithDropdownScopeId: getScopedFamilyState, - injectSnapshotValueWithDropdownScopeId: getScopedSnapshotValue, - injectFamilySnapshotValueWithDropdownScopeId: getScopedFamilySnapshotValue, - }; -}; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts new file mode 100644 index 000000000..b0f35ce58 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts @@ -0,0 +1,26 @@ +import { DropdownScopeInternalContext } from '@/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext'; +import { dropdownHotkeyStateScopeMap } from '@/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap'; +import { dropdownWidthStateScopeMap } from '@/ui/layout/dropdown/states/dropdownWidthStateScopeMap'; +import { isDropdownOpenStateScopeMap } from '@/ui/layout/dropdown/states/isDropdownOpenStateScopeMap'; +import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; +import { getState } from '@/ui/utilities/recoil-scope/utils/getState'; + +type UseDropdownStatesProps = { + dropdownScopeId?: string; +}; + +export const useDropdownStates = ({ + dropdownScopeId, +}: UseDropdownStatesProps) => { + const scopeId = useAvailableScopeIdOrThrow( + DropdownScopeInternalContext, + dropdownScopeId, + ); + + return { + scopeId, + dropdownHotkeyScopeState: getState(dropdownHotkeyStateScopeMap, scopeId), + dropdownWidthState: getState(dropdownWidthStateScopeMap, scopeId), + isDropdownOpenState: getState(isDropdownOpenStateScopeMap, scopeId), + }; +}; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts index e77afedf9..5616774c3 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts @@ -1,36 +1,29 @@ import { useRecoilState } from 'recoil'; -import { useDropdownScopedStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownScopedStates'; -import { getDropdownScopeInjectors } from '@/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors'; +import { useDropdownStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownStates'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; export const useDropdown = (dropdownId?: string) => { - const { injectStateWithDropdownScopeId, scopeId } = useDropdownScopedStates({ - dropdownScopeId: dropdownId, - }); - const { - dropdownHotkeyScopeScopeInjector, - dropdownWidthScopeInjector, - isDropdownOpenScopeInjector, - } = getDropdownScopeInjectors(); + scopeId, + dropdownHotkeyScopeState, + dropdownWidthState, + isDropdownOpenState, + } = useDropdownStates({ + dropdownScopeId: `${dropdownId}-scope`, + }); const { setHotkeyScopeAndMemorizePreviousScope, goBackToPreviousHotkeyScope, } = usePreviousHotkeyScope(); - const [dropdownHotkeyScope, setDropdownHotkeyScope] = useRecoilState( - injectStateWithDropdownScopeId(dropdownHotkeyScopeScopeInjector), - ); + const [dropdownHotkeyScope] = useRecoilState(dropdownHotkeyScopeState); - const [dropdownWidth, setDropdownWidth] = useRecoilState( - injectStateWithDropdownScopeId(dropdownWidthScopeInjector), - ); + const [dropdownWidth, setDropdownWidth] = useRecoilState(dropdownWidthState); - const [isDropdownOpen, setIsDropdownOpen] = useRecoilState( - injectStateWithDropdownScopeId(isDropdownOpenScopeInjector), - ); + const [isDropdownOpen, setIsDropdownOpen] = + useRecoilState(isDropdownOpenState); const closeDropdown = () => { goBackToPreviousHotkeyScope(); @@ -61,8 +54,6 @@ export const useDropdown = (dropdownId?: string) => { closeDropdown, toggleDropdown, openDropdown, - dropdownHotkeyScope, - setDropdownHotkeyScope, dropdownWidth, setDropdownWidth, }; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useInternalHotkeyScopeManagement.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useInternalHotkeyScopeManagement.ts index b63587ded..9ea9db797 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useInternalHotkeyScopeManagement.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useInternalHotkeyScopeManagement.ts @@ -1,16 +1,22 @@ import { useEffect } from 'react'; +import { useRecoilState } from 'recoil'; +import { useDropdownStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownStates'; import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; -import { useDropdown } from './useDropdown'; - export const useInternalHotkeyScopeManagement = ({ + dropdownScopeId, dropdownHotkeyScopeFromParent, }: { + dropdownScopeId: string; dropdownHotkeyScopeFromParent?: HotkeyScope; }) => { - const { dropdownHotkeyScope, setDropdownHotkeyScope } = useDropdown(); + const { dropdownHotkeyScopeState } = useDropdownStates({ dropdownScopeId }); + + const [dropdownHotkeyScope, setDropdownHotkeyScope] = useRecoilState( + dropdownHotkeyScopeState, + ); useEffect(() => { if (!isDeeplyEqual(dropdownHotkeyScopeFromParent, dropdownHotkeyScope)) { diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap.ts similarity index 67% rename from packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts rename to packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap.ts index d47015633..60951e8f5 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap.ts @@ -1,9 +1,9 @@ import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const dropdownHotkeyScopeScopedState = createStateScopeMap< +export const dropdownHotkeyStateScopeMap = createStateScopeMap< HotkeyScope | null | undefined >({ - key: 'dropdownHotkeyScopeScopedState', + key: 'dropdownHotkeyStateScopeMap', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts deleted file mode 100644 index 717a3a1cd..000000000 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; - -export const dropdownWidthScopedState = createStateScopeMap( - { - key: 'dropdownWidthScopedState', - defaultValue: 160, - }, -); diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthStateScopeMap.ts new file mode 100644 index 000000000..9a39a52fd --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthStateScopeMap.ts @@ -0,0 +1,8 @@ +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; + +export const dropdownWidthStateScopeMap = createStateScopeMap< + number | undefined +>({ + key: 'dropdownWidthStateScopeMap', + defaultValue: 160, +}); diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenStateScopeMap.ts similarity index 51% rename from packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts rename to packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenStateScopeMap.ts index 65d0c073c..124ae55be 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenStateScopeMap.ts @@ -1,6 +1,6 @@ import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isDropdownOpenScopedState = createStateScopeMap({ - key: 'isDropdownOpenScopedState', +export const isDropdownOpenStateScopeMap = createStateScopeMap({ + key: 'isDropdownOpenStateScopeMap', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors.ts deleted file mode 100644 index 032fe74fd..000000000 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { dropdownHotkeyScopeScopedState } from '@/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState'; -import { dropdownWidthScopedState } from '@/ui/layout/dropdown/states/dropdownWidthScopedState'; -import { isDropdownOpenScopedState } from '@/ui/layout/dropdown/states/isDropdownOpenScopedState'; -import { getScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector'; - -export const getDropdownScopeInjectors = () => { - const dropdownHotkeyScopeScopeInjector = getScopeInjector( - dropdownHotkeyScopeScopedState, - ); - - const dropdownWidthScopeInjector = getScopeInjector(dropdownWidthScopedState); - - const isDropdownOpenScopeInjector = getScopeInjector( - isDropdownOpenScopedState, - ); - - return { - dropdownHotkeyScopeScopeInjector, - dropdownWidthScopeInjector, - isDropdownOpenScopeInjector, - }; -}; diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx index d6bb05d8b..3355f6f0f 100644 --- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx +++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx @@ -12,7 +12,6 @@ import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { Dropdown } from '../../dropdown/components/Dropdown'; import { DropdownMenu } from '../../dropdown/components/DropdownMenu'; -import { DropdownScope } from '../../dropdown/scopes/DropdownScope'; const StyledContainer = styled.div` z-index: 1; @@ -33,41 +32,40 @@ export const ShowPageAddButton = ({ return ( - - - } - dropdownComponents={ - - - handleSelect('Note')} - accent="default" - LeftIcon={IconNotes} - text="Note" - /> - handleSelect('Task')} - accent="default" - LeftIcon={IconCheckbox} - text="Task" - /> - - - } - dropdownHotkeyScope={{ - scope: PageHotkeyScope.ShowPage, - }} - /> - + + } + dropdownComponents={ + + + handleSelect('Note')} + accent="default" + LeftIcon={IconNotes} + text="Note" + /> + handleSelect('Task')} + accent="default" + LeftIcon={IconCheckbox} + text="Task" + /> + + + } + dropdownHotkeyScope={{ + scope: PageHotkeyScope.ShowPage, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx index f7b0cb9b4..fee1454b6 100644 --- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx +++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx @@ -13,7 +13,6 @@ import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMe import { Dropdown } from '../../dropdown/components/Dropdown'; import { DropdownMenu } from '../../dropdown/components/DropdownMenu'; -import { DropdownScope } from '../../dropdown/scopes/DropdownScope'; const StyledContainer = styled.div` z-index: 1; @@ -42,35 +41,34 @@ export const ShowPageMoreButton = ({ return ( - - - } - dropdownComponents={ - - - - - - } - dropdownHotkeyScope={{ - scope: PageHotkeyScope.ShowPage, - }} - /> - + + } + dropdownComponents={ + + + + + + } + dropdownHotkeyScope={{ + scope: PageHotkeyScope.ShowPage, + }} + /> ); }; diff --git a/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx b/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx index ab2d74c90..55537c473 100644 --- a/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx +++ b/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx @@ -68,6 +68,7 @@ export const EditableFilterDropdownButton = ({ return ( } diff --git a/packages/twenty-front/src/modules/views/components/UpdateViewButtonGroup.tsx b/packages/twenty-front/src/modules/views/components/UpdateViewButtonGroup.tsx index 6091251b5..58876d225 100644 --- a/packages/twenty-front/src/modules/views/components/UpdateViewButtonGroup.tsx +++ b/packages/twenty-front/src/modules/views/components/UpdateViewButtonGroup.tsx @@ -7,7 +7,6 @@ import { Button } from '@/ui/input/button/components/Button'; import { ButtonGroup } from '@/ui/input/button/components/ButtonGroup'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; import { UpdateViewDropdownId } from '@/views/constants/UpdateViewDropdownId'; @@ -58,25 +57,24 @@ export const UpdateViewButtonGroup = ({ - - - } - dropdownComponents={ - <> - - - - > - } - /> - + + } + dropdownComponents={ + <> + + + + > + } + /> ); diff --git a/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx b/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx index 85b5d985e..5178580a1 100644 --- a/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx +++ b/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx @@ -5,7 +5,6 @@ import { useRecoilValue } from 'recoil'; import { AddObjectFilterFromDetailsButton } from '@/object-record/object-filter-dropdown/components/AddObjectFilterFromDetailsButton'; import { ObjectFilterDropdownScope } from '@/object-record/object-filter-dropdown/scopes/ObjectFilterDropdownScope'; import { FiltersHotkeyScope } from '@/object-record/object-filter-dropdown/types/FiltersHotkeyScope'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { EditableFilterDropdownButton } from '@/views/components/EditableFilterDropdownButton'; import { EditableSortChip } from '@/views/components/EditableSortChip'; import { ViewBarFilterEffect } from '@/views/components/ViewBarFilterEffect'; @@ -146,19 +145,17 @@ export const ViewBarDetails = ({ - - - - + + ); })} diff --git a/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx b/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx index 2b3118b9a..69ed55f00 100644 --- a/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx +++ b/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx @@ -15,7 +15,6 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { StyledDropdownButtonContainer } from '@/ui/layout/dropdown/components/StyledDropdownButtonContainer'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { MOBILE_VIEWPORT } from '@/ui/theme/constants/theme'; import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; @@ -130,56 +129,55 @@ export const ViewsDropdownButton = ({ }; return ( - - - - {currentView?.name ?? 'All'} - - · {entityCountInCurrentView}{' '} - - - - } - dropdownComponents={ - <> - - {views.map((view) => ( - ) => - handleEditViewButtonClick(event, view.id), - }, - views.length > 1 - ? { - Icon: IconTrash, - onClick: (event: MouseEvent) => - handleDeleteViewButtonClick(event, view.id), - } - : null, - ].filter(assertNotNull)} - onClick={() => handleViewSelect(view.id)} - LeftIcon={IconList} - text={view.name} - /> - ))} - - - + + + {currentView?.name ?? 'All'} + + · {entityCountInCurrentView}{' '} + + + + } + dropdownComponents={ + <> + + {views.map((view) => ( ) => + handleEditViewButtonClick(event, view.id), + }, + views.length > 1 + ? { + Icon: IconTrash, + onClick: (event: MouseEvent) => + handleDeleteViewButtonClick(event, view.id), + } + : null, + ].filter(assertNotNull)} + onClick={() => handleViewSelect(view.id)} + LeftIcon={IconList} + text={view.name} /> - - > - } - /> - + ))} + + + + + + > + } + /> ); };