Skip to content

The open alternative to Salesforce, designed for AI.

Treat no value view group as normal & enable hide/dnd for no value (#8613)

Khudditedfb966d47e0b
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx
index 8aa81fe1b21..70bd645af24 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx
@@ -56,10 +56,9 @@ export const RecordGroupMenuItemDraggable = ({
/>
}
accent={isNoValue || showDragGrip ? 'placeholder' : 'default'}
- iconButtons={!isNoValue ? getIconButtons(recordGroup) : undefined}
+ iconButtons={getIconButtons(recordGroup)}
showGrip={isNoValue ? true : showDragGrip}
- isDragDisabled={isNoValue ? true : !isDraggable}
- isHoverDisabled={isNoValue}
+ isDragDisabled={!isDraggable}
/>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx
index 4b742a50cd8..e43afd1eeff 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx
@@ -6,10 +6,7 @@ import {
import { useRef } from 'react';
import { RecordGroupMenuItemDraggable } from '@/object-record/record-group/components/RecordGroupMenuItemDraggable';
-import {
- RecordGroupDefinition,
- RecordGroupDefinitionType,
-} from '@/object-record/record-group/types/RecordGroupDefinition';
+import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
@@ -38,15 +35,6 @@ export const RecordGroupsVisibilityDropdownSection = ({
onDragEnd?.(result, provided);
};
- const noValueRecordGroups =
- recordGroups.filter(
- (recordGroup) => recordGroup.type === RecordGroupDefinitionType.NoValue,
- ) ?? [];
-
- const recordGroupsWithoutNoValueGroups = recordGroups.filter(
- (recordGroup) => recordGroup.type !== RecordGroupDefinitionType.NoValue,
- );
-
const ref = useRef<HTMLDivElement>(null);
return (
@@ -58,7 +46,7 @@ export const RecordGroupsVisibilityDropdownSection = ({
{!!recordGroups.length && (
<>
{!isDraggable ? (
- recordGroupsWithoutNoValueGroups.map((recordGroup) => (
+ recordGroups.map((recordGroup) => (
<RecordGroupMenuItemDraggable
recordGroup={recordGroup}
onVisibilityChange={onVisibilityChange}
@@ -71,33 +59,25 @@ export const RecordGroupsVisibilityDropdownSection = ({
onDragEnd={handleOnDrag}
draggableItems={
<>
- {recordGroupsWithoutNoValueGroups.map(
- (recordGroup, index) => (
- <DraggableItem
- key={recordGroup.id}
- draggableId={recordGroup.id}
- index={index + 1}
- itemComponent={
- <RecordGroupMenuItemDraggable
- recordGroup={recordGroup}
- onVisibilityChange={onVisibilityChange}
- showDragGrip={showDragGrip}
- isDraggable={isDraggable}
- />
- }
- />
- ),
- )}
+ {recordGroups.map((recordGroup, index) => (
+ <DraggableItem
+ key={recordGroup.id}
+ draggableId={recordGroup.id}
+ index={index + 1}
+ itemComponent={
+ <RecordGroupMenuItemDraggable
+ recordGroup={recordGroup}
+ onVisibilityChange={onVisibilityChange}
+ showDragGrip={showDragGrip}
+ isDraggable={isDraggable}
+ />
+ }
+ />
+ ))}
</>
}
/>
)}
- {noValueRecordGroups.map((recordGroup) => (
- <RecordGroupMenuItemDraggable
- recordGroup={recordGroup}
- onVisibilityChange={onVisibilityChange}
- />
- ))}
</>
)}
</DropdownMenuItemsContainer>
diff --git a/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupActions.ts b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupActions.ts
index 42ad8b3f5c4..b99af28b695 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupActions.ts
+++ b/packages/twenty-front/src/modules/object-record/record-group/hooks/useRecordGroupActions.ts
@@ -5,7 +5,6 @@ import { RecordBoardColumnContext } from '@/object-record/record-board/record-bo
import { useRecordGroups } from '@/object-record/record-group/hooks/useRecordGroups';
import { useRecordGroupVisibility } from '@/object-record/record-group/hooks/useRecordGroupVisibility';
import { RecordGroupAction } from '@/object-record/record-group/types/RecordGroupActions';
-import { RecordGroupDefinitionType } from '@/object-record/record-group/types/RecordGroupDefinition';
import { RecordIndexRootPropsContext } from '@/object-record/record-index/contexts/RecordIndexRootPropsContext';
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
import { ViewType } from '@/views/types/ViewType';
@@ -81,17 +80,15 @@ export const useRecordGroupActions = ({
navigateToSelectSettings();
},
},
- recordGroupDefinition.type !== RecordGroupDefinitionType.NoValue
- ? {
- id: 'hide',
- label: 'Hide',
- icon: IconEyeOff,
- position: 1,
- callback: () => {
- handleRecordGroupVisibilityChange(recordGroupDefinition);
- },
- }
- : undefined,
+ {
+ id: 'hide',
+ label: 'Hide',
+ icon: IconEyeOff,
+ position: 1,
+ callback: () => {
+ handleRecordGroupVisibilityChange(recordGroupDefinition);
+ },
+ },
].filter(isDefined),
[
handleRecordGroupVisibilityChange,
diff --git a/packages/twenty-front/src/modules/views/utils/mapViewGroupsToRecordGroupDefinitions.ts b/packages/twenty-front/src/modules/views/utils/mapViewGroupsToRecordGroupDefinitions.ts
index 3767abe6a65..7c7aba97abc 100644
--- a/packages/twenty-front/src/modules/views/utils/mapViewGroupsToRecordGroupDefinitions.ts
+++ b/packages/twenty-front/src/modules/views/utils/mapViewGroupsToRecordGroupDefinitions.ts
@@ -41,7 +41,18 @@ export const mapViewGroupsToRecordGroupDefinitions = ({
(option) => option.value === viewGroup.fieldValue,
);
- if (!selectedOption) return null;
+ if (!selectedOption) {
+ return {
+ id: 'no-value',
+ title: 'No Value',
+ type: RecordGroupDefinitionType.NoValue,
+ value: null,
+ position: viewGroup.position,
+ isVisible: viewGroup.isVisible,
+ fieldMetadataId: selectFieldMetadataItem.id,
+ color: 'transparent',
+ } satisfies RecordGroupDefinition;
+ }
return {
id: viewGroup.id,
@@ -57,23 +68,5 @@ export const mapViewGroupsToRecordGroupDefinitions = ({
.filter(isDefined)
.sort((a, b) => a.position - b.position);
- if (selectFieldMetadataItem.isNullable === true) {
- const noValueColumn = {
- id: 'no-value',
- title: 'No Value',
- type: RecordGroupDefinitionType.NoValue,
- value: null,
- position:
- recordGroupDefinitionsFromViewGroups
- .map((option) => option.position)
- .reduce((a, b) => Math.max(a, b), 0) + 1,
- isVisible: true,
- fieldMetadataId: selectFieldMetadataItem.id,
- color: 'transparent',
- } satisfies RecordGroupDefinition;
-
- return [...recordGroupDefinitionsFromViewGroups, noValueColumn];
- }
-
return recordGroupDefinitionsFromViewGroups;
};