From 7d27a0330896f62494f8de1f1ebf58d179116fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Magrin?= Date: Tue, 15 Oct 2024 12:08:57 +0200 Subject: [PATCH] feat: view group actions --- .../RecordBoardColumnDropdownMenu.tsx | 10 +- .../components/RecordBoardColumnHeader.tsx | 14 ++- .../hooks/useRecordGroupActions.ts | 87 +++++++++++++++++ .../hooks/useRecordGroupReorder.ts | 60 ++++++++++++ .../hooks/useRecordGroupStates.ts | 65 +++++++++++++ .../hooks/useRecordGroupVisibility.ts | 47 +++++++++ .../types/RecordGroupDefinition.ts | 3 - .../RecordIndexBoardDataLoaderEffect.tsx | 4 +- .../components/RecordIndexContainer.tsx | 37 +------ .../RecordIndexOptionsDropdownContent.tsx | 40 +++++--- .../hooks/useRecordIndexOptionsForBoard.ts | 96 ------------------- .../utils/mapViewGroupsToGroupDefinitions.ts | 2 - .../standard-objects/index.ts | 2 + 13 files changed, 306 insertions(+), 161 deletions(-) create mode 100644 packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupActions.ts create mode 100644 packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupReorder.ts create mode 100644 packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupStates.ts create mode 100644 packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupVisibility.ts diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnDropdownMenu.tsx b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnDropdownMenu.tsx index ef129890ad02..ee76f5697d4c 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnDropdownMenu.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnDropdownMenu.tsx @@ -1,11 +1,11 @@ import styled from '@emotion/styled'; -import { useCallback, useContext, useRef } from 'react'; +import { useCallback, useRef } from 'react'; -import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside'; +import { useRecordGroupActions } from '@/object-record/record-group/hooks/useRecordGroupActions'; const StyledMenuContainer = styled.div` position: absolute; @@ -25,6 +25,8 @@ export const RecordBoardColumnDropdownMenu = ({ }: RecordBoardColumnDropdownMenuProps) => { const boardColumnMenuRef = useRef(null); + const recordGroupActions = useRecordGroupActions(); + const closeMenu = useCallback(() => { onClose(); }, [onClose]); @@ -34,13 +36,11 @@ export const RecordBoardColumnDropdownMenu = ({ callback: closeMenu, }); - const { columnDefinition } = useContext(RecordBoardColumnContext); - return ( - {columnDefinition.actions.map((action) => ( + {recordGroupActions.map((action) => ( { diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx index ec3805977e96..9658f470f0f8 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx @@ -137,13 +137,11 @@ export const RecordBoardColumnHeader = () => { {isHeaderHovered && ( - {columnDefinition.actions.length > 0 && ( - - )} + { - {isBoardColumnMenuOpen && columnDefinition.actions.length > 0 && ( + {isBoardColumnMenuOpen && ( { + const navigate = useNavigate(); + const location = useLocation(); + + const { objectNameSingular, recordIndexId } = useContext( + RecordIndexRootPropsContext, + ); + + const { columnDefinition: recordGroupDefinition } = useContext( + RecordBoardColumnContext, + ); + + const { objectMetadataItem } = useObjectMetadataItem({ + objectNameSingular, + }); + + const { viewGroupFieldMetadataItem } = useRecordGroupStates({ + objectNameSingular, + viewBarId: recordIndexId, + }); + + const { handleVisibilityChange: handleRecordGroupVisibilityChange } = + useRecordGroupVisibility({ + viewBarId: recordIndexId, + }); + + const setNavigationMemorizedUrl = useSetRecoilState( + navigationMemorizedUrlState, + ); + + const navigateToSelectSettings = useCallback(() => { + setNavigationMemorizedUrl(location.pathname + location.search); + navigate( + `/settings/objects/${getObjectSlug(objectMetadataItem)}/${viewGroupFieldMetadataItem?.name}`, + ); + }, [ + setNavigationMemorizedUrl, + location.pathname, + location.search, + navigate, + objectMetadataItem, + viewGroupFieldMetadataItem?.name, + ]); + + const recordGroupActions: RecordGroupAction[] = useMemo( + () => [ + { + id: 'edit', + label: 'Edit', + icon: IconSettings, + position: 0, + callback: () => { + navigateToSelectSettings(); + }, + }, + { + id: 'hide', + label: 'Hide', + icon: IconEyeOff, + position: 1, + callback: () => { + handleRecordGroupVisibilityChange(recordGroupDefinition); + }, + }, + ], + [ + handleRecordGroupVisibilityChange, + navigateToSelectSettings, + recordGroupDefinition, + ], + ); + + return recordGroupActions; +}; diff --git a/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupReorder.ts b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupReorder.ts new file mode 100644 index 000000000000..5a999c612ef4 --- /dev/null +++ b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupReorder.ts @@ -0,0 +1,60 @@ +import { OnDragEndResponder } from '@hello-pangea/dnd'; +import { useCallback } from 'react'; +import { useSetRecoilState } from 'recoil'; + +import { moveArrayItem } from '~/utils/array/moveArrayItem'; +import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; +import { useSaveCurrentViewGroups } from '@/views/hooks/useSaveCurrentViewGroups'; +import { recordIndexGroupDefinitionsState } from '@/object-record/record-index/states/recordIndexGroupDefinitionsState'; +import { mapGroupDefinitionsToViewGroups } from '@/views/utils/mapGroupDefinitionsToViewGroups'; +import { useRecordGroupStates } from '@/object-record/record-group/hooks/useRecordGroupStates'; + +type UseRecordGroupHandlersParams = { + objectNameSingular: string; + viewBarId: string; +}; + +export const useRecordGroupReoder = ({ + objectNameSingular, + viewBarId, +}: UseRecordGroupHandlersParams) => { + const setRecordIndexGroupDefinitions = useSetRecoilState( + recordIndexGroupDefinitionsState, + ); + + const { visibleRecordGroups } = useRecordGroupStates({ + objectNameSingular, + viewBarId, + }); + + const { saveViewGroups } = useSaveCurrentViewGroups(viewBarId); + + const handleOrderChange: OnDragEndResponder = useCallback( + (result) => { + if (!result.destination) { + return; + } + + const reorderedVisibleBoardGroups = moveArrayItem(visibleRecordGroups, { + fromIndex: result.source.index - 1, + toIndex: result.destination.index - 1, + }); + + if (isDeeplyEqual(visibleRecordGroups, reorderedVisibleBoardGroups)) + return; + + const updatedGroups = [...reorderedVisibleBoardGroups].map( + (group, index) => ({ ...group, position: index }), + ); + + setRecordIndexGroupDefinitions(updatedGroups); + saveViewGroups(mapGroupDefinitionsToViewGroups(updatedGroups)); + }, + [saveViewGroups, setRecordIndexGroupDefinitions, visibleRecordGroups], + ); + + return { + visibleRecordGroups, + handleOrderChange, + }; +}; diff --git a/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupStates.ts b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupStates.ts new file mode 100644 index 000000000000..4d12d126cc3d --- /dev/null +++ b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupStates.ts @@ -0,0 +1,65 @@ +import { useMemo } from 'react'; +import { useRecoilValue } from 'recoil'; + +import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; +import { recordIndexGroupDefinitionsState } from '@/object-record/record-index/states/recordIndexGroupDefinitionsState'; + +type UseRecordGroupStatesParams = { + objectNameSingular: string; + viewBarId: string; +}; + +export const useRecordGroupStates = ({ + objectNameSingular, +}: UseRecordGroupStatesParams) => { + const recordIndexGroupDefinitions = useRecoilValue( + recordIndexGroupDefinitionsState, + ); + + const { objectMetadataItem } = useObjectMetadataItem({ + objectNameSingular, + }); + + const viewGroupFieldMetadataItem = useMemo(() => { + if (recordIndexGroupDefinitions.length === 0) return null; + // We're assuming that all groups have the same fieldMetadataId for now + const fieldMetadataId = + 'fieldMetadataId' in recordIndexGroupDefinitions[0] + ? recordIndexGroupDefinitions[0].fieldMetadataId + : null; + + if (!fieldMetadataId) return null; + + return objectMetadataItem.fields.find( + (field) => field.id === fieldMetadataId, + ); + }, [objectMetadataItem, recordIndexGroupDefinitions]); + + const visibleRecordGroups = useMemo( + () => + recordIndexGroupDefinitions + .filter((boardGroup) => boardGroup.isVisible) + .sort( + (boardGroupA, boardGroupB) => + boardGroupA.position - boardGroupB.position, + ), + [recordIndexGroupDefinitions], + ); + + const hiddenRecordGroups = useMemo( + () => + recordIndexGroupDefinitions + .filter((boardGroup) => !boardGroup.isVisible) + .map((boardGroup) => ({ + ...boardGroup, + isVisible: false, + })), + [recordIndexGroupDefinitions], + ); + + return { + hiddenRecordGroups, + visibleRecordGroups, + viewGroupFieldMetadataItem, + }; +}; diff --git a/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupVisibility.ts b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupVisibility.ts new file mode 100644 index 000000000000..0c9a9c9296f0 --- /dev/null +++ b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupVisibility.ts @@ -0,0 +1,47 @@ +import { useCallback } from 'react'; +import { useRecoilState } from 'recoil'; + +import { useSaveCurrentViewGroups } from '@/views/hooks/useSaveCurrentViewGroups'; +import { recordIndexGroupDefinitionsState } from '@/object-record/record-index/states/recordIndexGroupDefinitionsState'; +import { mapGroupDefinitionsToViewGroups } from '@/views/utils/mapGroupDefinitionsToViewGroups'; +import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition'; + +type UseRecordGroupVisibilityParams = { + viewBarId: string; +}; + +export const useRecordGroupVisibility = ({ + viewBarId, +}: UseRecordGroupVisibilityParams) => { + const [recordIndexGroupDefinitions, setRecordIndexGroupDefinitions] = + useRecoilState(recordIndexGroupDefinitionsState); + + const { saveViewGroups } = useSaveCurrentViewGroups(viewBarId); + + const handleVisibilityChange = useCallback( + async (updatedGroupDefinition: RecordGroupDefinition) => { + const updatedGroupsDefinitions = recordIndexGroupDefinitions.map( + (groupDefinition) => + groupDefinition.id === updatedGroupDefinition.id + ? { + ...groupDefinition, + isVisible: !groupDefinition.isVisible, + } + : groupDefinition, + ); + + setRecordIndexGroupDefinitions(updatedGroupsDefinitions); + + saveViewGroups(mapGroupDefinitionsToViewGroups(updatedGroupsDefinitions)); + }, + [ + recordIndexGroupDefinitions, + setRecordIndexGroupDefinitions, + saveViewGroups, + ], + ); + + return { + handleVisibilityChange, + }; +}; diff --git a/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts b/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts index d4ea925ad300..33dd80d7af12 100644 --- a/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts +++ b/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts @@ -1,4 +1,3 @@ -import { RecordGroupAction } from '@/object-record/record-group/types/RecordGroupActions'; import { ThemeColor } from 'twenty-ui'; export const enum RecordGroupDefinitionType { @@ -13,7 +12,6 @@ export type RecordGroupDefinitionNoValue = { position: number; value: null; isVisible: boolean; - actions: RecordGroupAction[]; }; export type RecordGroupDefinitionValue = { @@ -25,7 +23,6 @@ export type RecordGroupDefinitionValue = { color: ThemeColor; position: number; isVisible: boolean; - actions: RecordGroupAction[]; }; export type RecordGroupDefinition = diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx index 2bf2f827d85f..5401d34ae50f 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx +++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx @@ -1,5 +1,6 @@ -import { useEffect } from 'react'; +import { useCallback, useEffect } from 'react'; import { useRecoilValue, useSetRecoilState } from 'recoil'; +import { useNavigate, useLocation } from 'react-router-dom'; import { contextStoreCurrentObjectMetadataIdState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdState'; import { contextStoreTargetedRecordIdsState } from '@/context-store/states/contextStoreTargetedRecordIdsState'; @@ -12,6 +13,7 @@ import { recordIndexKanbanFieldMetadataIdState } from '@/object-record/record-in import { FieldMetadataType } from '~/generated-metadata/graphql'; import { isDefined } from '~/utils/isDefined'; import { recordIndexGroupDefinitionsState } from '@/object-record/record-index/states/recordIndexGroupDefinitionsState'; +import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; type RecordIndexBoardDataLoaderEffectProps = { objectNameSingular: string; diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx index e2f77be13069..a9752626f93e 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx +++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx @@ -3,7 +3,6 @@ import { useRecoilCallback, useRecoilState, useSetRecoilState } from 'recoil'; import { useColumnDefinitionsFromFieldMetadata } from '@/object-metadata/hooks/useColumnDefinitionsFromFieldMetadata'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; -import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural'; import { RecordIndexBoardContainer } from '@/object-record/record-index/components/RecordIndexBoardContainer'; import { RecordIndexBoardDataLoader } from '@/object-record/record-index/components/RecordIndexBoardDataLoader'; import { RecordIndexBoardDataLoaderEffect } from '@/object-record/record-index/components/RecordIndexBoardDataLoaderEffect'; @@ -46,7 +45,6 @@ import { useRecordBoard } from '@/object-record/record-board/hooks/useRecordBoar import { useLocation, useNavigate } from 'react-router-dom'; import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug'; -import { IconSettings } from 'twenty-ui'; const StyledContainer = styled.div` display: flex; @@ -72,14 +70,10 @@ export const RecordIndexContainer = () => { recordIndexViewTypeState, ); - const { objectNamePlural, recordIndexId } = useContext( + const { objectNameSingular, objectNamePlural, recordIndexId } = useContext( RecordIndexRootPropsContext, ); - const { objectNameSingular } = useObjectNameSingularFromPlural({ - objectNamePlural, - }); - const { objectMetadataItem } = useObjectMetadataItem({ objectNameSingular, }); @@ -142,36 +136,11 @@ export const RecordIndexContainer = () => { const onViewGroupsChange = useRecoilCallback( ({ set, snapshot }) => (viewGroups: ViewGroup[]) => { - let newGroupDefinitions = mapViewGroupsToGroupDefinitions({ + const newGroupDefinitions = mapViewGroupsToGroupDefinitions({ objectMetadataItem, viewGroups, }); - newGroupDefinitions = newGroupDefinitions.map((groupDefition) => ({ - ...groupDefition, - actions: [ - { - id: 'edit', - label: 'Edit', - icon: IconSettings, - position: 0, - callback: () => { - navigateToSelectSettings(); - }, - }, - // TODO: Maybe we should define actions somewhere else - // { - // id: 'hide', - // label: 'Hide', - // icon: IconEyeOff, - // position: 1, - // callback: () => { - // handleBoardGroupVisibilityChange(groupDefition); - // }, - // }, - ], - })); - setColumns(newGroupDefinitions); const existingRecordIndexGroupDefinitions = snapshot @@ -187,7 +156,7 @@ export const RecordIndexContainer = () => { set(recordIndexGroupDefinitionsState, newGroupDefinitions); } }, - [navigateToSelectSettings, objectMetadataItem, setColumns], + [objectMetadataItem, setColumns], ); return ( diff --git a/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx b/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx index e181dd17a52b..bf84442db5c0 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx +++ b/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx @@ -41,6 +41,9 @@ import { ViewType } from '@/views/types/ViewType'; import { useLocation } from 'react-router-dom'; import { useSetRecoilState } from 'recoil'; import { ViewGroupsVisibilityDropdownSection } from '@/views/components/ViewGroupsVisibilityDropdownSection'; +import { useRecordGroupStates } from '@/object-record/record-group/hooks/useRecordGroupStates'; +import { useRecordGroupVisibility } from '@/object-record/record-group/hooks/useRecordGroupVisibility'; +import { useRecordGroupReoder } from '@/object-record/record-group/hooks/useRecordGroupReorder'; type RecordIndexOptionsMenu = | 'viewGroups' @@ -107,13 +110,8 @@ export const RecordIndexOptionsDropdownContent = ({ const { visibleBoardFields, hiddenBoardFields, - visibleBoardGroups, - hiddenBoardGroups, - viewGroupFieldMetadataItem, handleReorderBoardFields, handleBoardFieldVisibilityChange, - handleBoardGroupVisibilityChange, - handleReorderGroups, isCompactModeActive, setAndPersistIsCompactModeActive, } = useRecordIndexOptionsForBoard({ @@ -122,6 +120,24 @@ export const RecordIndexOptionsDropdownContent = ({ viewBarId: recordIndexId, }); + const { + hiddenRecordGroups, + visibleRecordGroups, + viewGroupFieldMetadataItem, + } = useRecordGroupStates({ + objectNameSingular, + viewBarId: recordIndexId, + }); + const { handleVisibilityChange: handleRecordGroupVisibilityChange } = + useRecordGroupVisibility({ + viewBarId: recordIndexId, + }); + const { handleOrderChange: handleRecordGroupOrderChange } = + useRecordGroupReoder({ + objectNameSingular, + viewBarId: recordIndexId, + }); + const viewGroupSettingsUrl = getSettingsPagePath(SettingsPath.ObjectDetail, { id: viewGroupFieldMetadataItem?.name, objectSlug: objectNamePlural, @@ -161,7 +177,7 @@ export const RecordIndexOptionsDropdownContent = ({ const viewGroupMenuItem = viewGroupFieldMetadataItem && - (visibleBoardGroups.length > 0 || hiddenBoardGroups.length > 0) ? ( + (visibleRecordGroups.length > 0 || hiddenRecordGroups.length > 0) ? ( handleSelectMenu('viewGroups')} LeftIcon={getIcon(currentViewWithCombinedFiltersAndSorts?.icon)} @@ -209,14 +225,14 @@ export const RecordIndexOptionsDropdownContent = ({ - {hiddenBoardGroups.length > 0 && ( + {hiddenRecordGroups.length > 0 && ( <> @@ -264,8 +280,8 @@ export const RecordIndexOptionsDropdownContent = ({ { const [recordIndexFieldDefinitions, setRecordIndexFieldDefinitions] = useRecoilState(recordIndexFieldDefinitionsState); - const [recordIndexGroupDefinitions, setRecordIndexGroupDefinitions] = - useRecoilState(recordIndexGroupDefinitionsState); const { saveViewFields } = useSaveCurrentViewFields(viewBarId); - const { saveViewGroups } = useSaveCurrentViewGroups(viewBarId); const { updateCurrentView } = useUpdateCurrentView(viewBarId); const { isCompactModeActiveState } = useRecordBoard(recordBoardId); @@ -58,21 +51,6 @@ export const useRecordIndexOptionsForBoard = ({ [columnDefinitions], ); - const viewGroupFieldMetadataItem = useMemo(() => { - if (recordIndexGroupDefinitions.length === 0) return null; - // We're assuming that all groups have the same fieldMetadataId for now - const fieldMetadataId = - 'fieldMetadataId' in recordIndexGroupDefinitions[0] - ? recordIndexGroupDefinitions[0].fieldMetadataId - : null; - - if (!fieldMetadataId) return null; - - return objectMetadataItem.fields.find( - (field) => field.id === fieldMetadataId, - ); - }, [objectMetadataItem, recordIndexGroupDefinitions]); - const recordIndexFieldDefinitionsByKey = useMemo( () => mapArrayToObject( @@ -93,17 +71,6 @@ export const useRecordIndexOptionsForBoard = ({ [recordIndexFieldDefinitions], ); - const visibleBoardGroups = useMemo( - () => - recordIndexGroupDefinitions - .filter((boardGroup) => boardGroup.isVisible) - .sort( - (boardGroupA, boardGroupB) => - boardGroupA.position - boardGroupB.position, - ), - [recordIndexGroupDefinitions], - ); - const hiddenBoardFields = useMemo( () => availableColumnDefinitions @@ -124,17 +91,6 @@ export const useRecordIndexOptionsForBoard = ({ [availableColumnDefinitions, recordIndexFieldDefinitionsByKey], ); - const hiddenBoardGroups = useMemo( - () => - recordIndexGroupDefinitions - .filter((boardGroup) => !boardGroup.isVisible) - .map((boardGroup) => ({ - ...boardGroup, - isVisible: false, - })), - [recordIndexGroupDefinitions], - ); - const handleReorderBoardFields: OnDragEndResponder = useCallback( (result) => { if (!result.destination) { @@ -159,30 +115,6 @@ export const useRecordIndexOptionsForBoard = ({ [saveViewFields, setRecordIndexFieldDefinitions, visibleBoardFields], ); - const handleReorderGroups: OnDragEndResponder = useCallback( - (result) => { - if (!result.destination) { - return; - } - - const reorderedVisibleBoardGroups = moveArrayItem(visibleBoardGroups, { - fromIndex: result.source.index - 1, - toIndex: result.destination.index - 1, - }); - - if (isDeeplyEqual(visibleBoardGroups, reorderedVisibleBoardGroups)) - return; - - const updatedGroups = [...reorderedVisibleBoardGroups].map( - (group, index) => ({ ...group, position: index }), - ); - - setRecordIndexGroupDefinitions(updatedGroups); - saveViewGroups(mapGroupDefinitionsToViewGroups(updatedGroups)); - }, - [saveViewGroups, setRecordIndexGroupDefinitions, visibleBoardGroups], - ); - // Todo : this seems over complex and should at least be extracted to an util with unit test. // Let's refactor this as we introduce the new viewBar const handleBoardFieldVisibilityChange = useCallback( @@ -248,29 +180,6 @@ export const useRecordIndexOptionsForBoard = ({ ], ); - const handleBoardGroupVisibilityChange = useCallback( - async (updatedGroupDefinition: RecordGroupDefinition) => { - const updatedGroupsDefinitions = recordIndexGroupDefinitions.map( - (groupDefinition) => - groupDefinition.id === updatedGroupDefinition.id - ? { - ...groupDefinition, - isVisible: !groupDefinition.isVisible, - } - : groupDefinition, - ); - - setRecordIndexGroupDefinitions(updatedGroupsDefinitions); - - saveViewGroups(mapGroupDefinitionsToViewGroups(updatedGroupsDefinitions)); - }, - [ - recordIndexGroupDefinitions, - setRecordIndexGroupDefinitions, - saveViewGroups, - ], - ); - const setAndPersistIsCompactModeActive = useCallback( (isCompactModeActive: boolean, view: GraphQLView | undefined) => { if (!view) return; @@ -285,13 +194,8 @@ export const useRecordIndexOptionsForBoard = ({ return { handleReorderBoardFields, handleBoardFieldVisibilityChange, - handleBoardGroupVisibilityChange, - viewGroupFieldMetadataItem, visibleBoardFields, hiddenBoardFields, - visibleBoardGroups, - hiddenBoardGroups, - handleReorderGroups, isCompactModeActive, setAndPersistIsCompactModeActive, }; diff --git a/packages/twenty-front/src/modules/views/utils/mapViewGroupsToGroupDefinitions.ts b/packages/twenty-front/src/modules/views/utils/mapViewGroupsToGroupDefinitions.ts index 76a84e3a5a3c..2e7d27887444 100644 --- a/packages/twenty-front/src/modules/views/utils/mapViewGroupsToGroupDefinitions.ts +++ b/packages/twenty-front/src/modules/views/utils/mapViewGroupsToGroupDefinitions.ts @@ -52,7 +52,6 @@ export const mapViewGroupsToGroupDefinitions = ({ color: selectedOption.color, position: viewGroup.position, isVisible: viewGroup.isVisible, - actions: [], } as RecordGroupDefinition; }) .filter(isDefined) @@ -64,7 +63,6 @@ export const mapViewGroupsToGroupDefinitions = ({ title: 'No Value', type: RecordGroupDefinitionType.NoValue, value: null, - actions: [], position: groupDefinitionsFromViewGroups .map((option) => option.position) diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/standard-objects/index.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/standard-objects/index.ts index 87cd71536096..98b5a062e050 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/standard-objects/index.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/standard-objects/index.ts @@ -75,6 +75,8 @@ export const standardObjectMetadataDefinitions = [ MessageChannelMessageAssociationWorkspaceEntity, NoteWorkspaceEntity, NoteTargetWorkspaceEntity, + OpportunityWorkspaceEntity, + PersonWorkspaceEntity, TaskWorkspaceEntity, TaskTargetWorkspaceEntity, ];