Skip to content

The open alternative to Salesforce, designed for AI.

Bring back companies focused actions (#15961)

Baptiste Devessier9c6d8330dfca
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/RecordPageLayoutActionsConfig.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/RecordPageLayoutActionsConfig.tsx
deleted file mode 100644
index 258ae5296a2..00000000000
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/RecordPageLayoutActionsConfig.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-import { CancelRecordPageLayoutSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/CancelRecordPageLayoutSingleRecordAction';
-import { EditRecordPageLayoutSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/EditRecordPageLayoutSingleRecordAction';
-import { SaveRecordPageLayoutSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/SaveRecordPageLayoutSingleRecordAction';
-import { SingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/types/SingleRecordActionsKey';
-import { inheritActionsFromDefaultConfig } from '@/action-menu/actions/record-actions/utils/inheritActionsFromDefaultConfig';
-import { ActionScope } from '@/action-menu/actions/types/ActionScope';
-import { ActionType } from '@/action-menu/actions/types/ActionType';
-import { ActionViewType } from '@/action-menu/actions/types/ActionViewType';
-import { PageLayoutSingleRecordActionKeys } from '@/page-layout/actions/PageLayoutSingleRecordActionKeys';
-import { msg } from '@lingui/core/macro';
-import { isDefined } from 'twenty-shared/utils';
-import { IconDeviceFloppy, IconPencil, IconX } from 'twenty-ui/display';
-
-export const RECORD_PAGE_LAYOUT_ACTIONS_CONFIG =
- inheritActionsFromDefaultConfig({
- config: {
- [PageLayoutSingleRecordActionKeys.EDIT_LAYOUT]: {
- key: PageLayoutSingleRecordActionKeys.EDIT_LAYOUT,
- label: msg`Edit Layout`,
- shortLabel: msg`Edit`,
- isPinned: true,
- position: 2,
- Icon: IconPencil,
- type: ActionType.Standard,
- scope: ActionScope.RecordSelection,
- shouldBeRegistered: ({ selectedRecord }) =>
- isDefined(selectedRecord) &&
- !selectedRecord?.isRemote &&
- !isDefined(selectedRecord?.deletedAt),
- // TODO: Once backend is ready, uncomment the line below
- // isDefined(selectedRecord?.pageLayoutId),
- availableOn: [ActionViewType.SHOW_PAGE],
- component: <EditRecordPageLayoutSingleRecordAction />,
- },
- [PageLayoutSingleRecordActionKeys.SAVE_LAYOUT]: {
- key: PageLayoutSingleRecordActionKeys.SAVE_LAYOUT,
- label: msg`Save Layout`,
- shortLabel: msg`Save`,
- isPinned: true,
- position: 1,
- Icon: IconDeviceFloppy,
- type: ActionType.Standard,
- scope: ActionScope.RecordSelection,
- shouldBeRegistered: ({ selectedRecord }) =>
- isDefined(selectedRecord) &&
- !selectedRecord?.isRemote &&
- !isDefined(selectedRecord?.deletedAt),
- // TODO: Once backend is ready, uncomment the line below
- // isDefined(selectedRecord?.pageLayoutId),
- availableOn: [ActionViewType.PAGE_EDIT_MODE],
- component: <SaveRecordPageLayoutSingleRecordAction />,
- },
- [PageLayoutSingleRecordActionKeys.CANCEL_LAYOUT_EDITION]: {
- key: PageLayoutSingleRecordActionKeys.CANCEL_LAYOUT_EDITION,
- label: msg`Cancel Edition`,
- shortLabel: msg`Cancel`,
- isPinned: true,
- position: 0,
- Icon: IconX,
- type: ActionType.Standard,
- scope: ActionScope.RecordSelection,
- shouldBeRegistered: ({ selectedRecord }) =>
- isDefined(selectedRecord) &&
- !selectedRecord?.isRemote &&
- !isDefined(selectedRecord?.deletedAt),
- // TODO: Once backend is ready, uncomment the line below
- // isDefined(selectedRecord?.pageLayoutId),
- availableOn: [ActionViewType.PAGE_EDIT_MODE],
- component: <CancelRecordPageLayoutSingleRecordAction />,
- },
- },
- actionKeys: [
- SingleRecordActionKeys.ADD_TO_FAVORITES,
- SingleRecordActionKeys.REMOVE_FROM_FAVORITES,
- SingleRecordActionKeys.DELETE,
- SingleRecordActionKeys.DESTROY,
- SingleRecordActionKeys.RESTORE,
- SingleRecordActionKeys.EXPORT_FROM_RECORD_SHOW,
- SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD,
- SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD,
- ],
- propertiesToOverwrite: {
- [SingleRecordActionKeys.ADD_TO_FAVORITES]: {
- position: 3,
- },
- [SingleRecordActionKeys.REMOVE_FROM_FAVORITES]: {
- position: 4,
- },
- [SingleRecordActionKeys.DELETE]: {
- position: 5,
- label: msg`Delete record`,
- },
- [SingleRecordActionKeys.EXPORT_FROM_RECORD_SHOW]: {
- position: 6,
- label: msg`Export record`,
- },
- [SingleRecordActionKeys.DESTROY]: {
- position: 7,
- label: msg`Permanently destroy record`,
- },
- [SingleRecordActionKeys.RESTORE]: {
- position: 8,
- label: msg`Restore record`,
- },
- [SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD]: {
- position: 9,
- label: msg`Navigate to previous record`,
- },
- [SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD]: {
- position: 10,
- label: msg`Navigate to next record`,
- },
- },
- });
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/CancelRecordPageLayoutSingleRecordAction.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/CancelRecordPageLayoutSingleRecordAction.tsx
deleted file mode 100644
index ce6309c12a9..00000000000
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/CancelRecordPageLayoutSingleRecordAction.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Action } from '@/action-menu/actions/components/Action';
-import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
-import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow';
-import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
-import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
-import { DEFAULT_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultRecordPageLayoutId';
-import { useResetDraftPageLayoutToPersistedPageLayout } from '@/page-layout/hooks/useResetDraftPageLayoutToPersistedPageLayout';
-import { useSetIsPageLayoutInEditMode } from '@/page-layout/hooks/useSetIsPageLayoutInEditMode';
-import { useRecoilValue } from 'recoil';
-
-export const CancelRecordPageLayoutSingleRecordAction = () => {
- const { objectMetadataItem } = useContextStoreObjectMetadataItemOrThrow();
-
- const recordId = useSelectedRecordIdOrThrow();
-
- const selectedRecord = useRecoilValue(recordStoreFamilyState(recordId));
-
- const pageLayoutId =
- objectMetadataItem.nameSingular === CoreObjectNameSingular.Company
- ? DEFAULT_RECORD_PAGE_LAYOUT_ID
- : selectedRecord?.pageLayoutId;
-
- const { setIsPageLayoutInEditMode } =
- useSetIsPageLayoutInEditMode(pageLayoutId);
-
- const { resetDraftPageLayoutToPersistedPageLayout } =
- useResetDraftPageLayoutToPersistedPageLayout(pageLayoutId);
-
- const handleClick = () => {
- resetDraftPageLayoutToPersistedPageLayout();
- setIsPageLayoutInEditMode(false);
- };
-
- return <Action onClick={handleClick} />;
-};
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/EditRecordPageLayoutSingleRecordAction.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/EditRecordPageLayoutSingleRecordAction.tsx
deleted file mode 100644
index 6405db58967..00000000000
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/EditRecordPageLayoutSingleRecordAction.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Action } from '@/action-menu/actions/components/Action';
-import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
-import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow';
-import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
-import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
-import { DEFAULT_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultRecordPageLayoutId';
-import { useSetIsPageLayoutInEditMode } from '@/page-layout/hooks/useSetIsPageLayoutInEditMode';
-import { useRecoilValue } from 'recoil';
-
-export const EditRecordPageLayoutSingleRecordAction = () => {
- const { objectMetadataItem } = useContextStoreObjectMetadataItemOrThrow();
-
- const recordId = useSelectedRecordIdOrThrow();
-
- const selectedRecord = useRecoilValue(recordStoreFamilyState(recordId));
-
- const pageLayoutId =
- objectMetadataItem.nameSingular === CoreObjectNameSingular.Company
- ? DEFAULT_RECORD_PAGE_LAYOUT_ID
- : selectedRecord?.pageLayoutId;
-
- const { setIsPageLayoutInEditMode } =
- useSetIsPageLayoutInEditMode(pageLayoutId);
-
- const handleClick = () => {
- setIsPageLayoutInEditMode(true);
- };
-
- return <Action onClick={handleClick} />;
-};
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/SaveRecordPageLayoutSingleRecordAction.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/SaveRecordPageLayoutSingleRecordAction.tsx
deleted file mode 100644
index 66a5b9288e0..00000000000
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/record-page-layout-actions/components/SaveRecordPageLayoutSingleRecordAction.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Action } from '@/action-menu/actions/components/Action';
-import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';
-import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow';
-import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
-import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
-import { DEFAULT_RECORD_PAGE_LAYOUT_ID } from '@/page-layout/constants/DefaultRecordPageLayoutId';
-import { useSavePageLayout } from '@/page-layout/hooks/useSavePageLayout';
-import { useSetIsPageLayoutInEditMode } from '@/page-layout/hooks/useSetIsPageLayoutInEditMode';
-import { useRecoilValue } from 'recoil';
-
-export const SaveRecordPageLayoutSingleRecordAction = () => {
- const { objectMetadataItem } = useContextStoreObjectMetadataItemOrThrow();
-
- const recordId = useSelectedRecordIdOrThrow();
-
- const selectedRecord = useRecoilValue(recordStoreFamilyState(recordId));
-
- const pageLayoutId =
- objectMetadataItem.nameSingular === CoreObjectNameSingular.Company
- ? DEFAULT_RECORD_PAGE_LAYOUT_ID
- : selectedRecord?.pageLayoutId;
-
- const { savePageLayout } = useSavePageLayout(pageLayoutId);
-
- const { setIsPageLayoutInEditMode } =
- useSetIsPageLayoutInEditMode(pageLayoutId);
-
- const handleClick = async () => {
- await savePageLayout();
- setIsPageLayoutInEditMode(false);
- };
-
- return <Action onClick={handleClick} />;
-};
diff --git a/packages/twenty-front/src/modules/action-menu/actions/utils/getActionConfig.ts b/packages/twenty-front/src/modules/action-menu/actions/utils/getActionConfig.ts
index c5bed2d8e27..2aa3b314039 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/utils/getActionConfig.ts
+++ b/packages/twenty-front/src/modules/action-menu/actions/utils/getActionConfig.ts
@@ -1,6 +1,5 @@
import { DASHBOARD_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/DashboardActionsConfig';
import { DEFAULT_RECORD_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/DefaultRecordActionsConfig';
-import { RECORD_PAGE_LAYOUT_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/RecordPageLayoutActionsConfig';
import { WORKFLOW_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowActionsConfig';
import { WORKFLOW_RUNS_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig';
import { WORKFLOW_VERSIONS_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig';
@@ -12,10 +11,8 @@ import { isDefined } from 'twenty-shared/utils';
export const getActionConfig = ({
objectMetadataItem,
- isRecordPageLayoutEnabled,
}: {
objectMetadataItem?: ObjectMetadataItem;
- isRecordPageLayoutEnabled: boolean;
}): Record<string, ActionConfig> => {
if (!isDefined(objectMetadataItem)) {
return {};
@@ -38,10 +35,6 @@ export const getActionConfig = ({
return WORKSPACE_MEMBERS_ACTIONS_CONFIG;
}
case CoreObjectNameSingular.Company: {
- if (isRecordPageLayoutEnabled) {
- return RECORD_PAGE_LAYOUT_ACTIONS_CONFIG;
- }
-
return DEFAULT_RECORD_ACTIONS_CONFIG;
}
default: {
diff --git a/packages/twenty-front/src/modules/action-menu/hooks/useRegisteredActions.ts b/packages/twenty-front/src/modules/action-menu/hooks/useRegisteredActions.ts
index 1a0e214bb1e..0e583568b27 100644
--- a/packages/twenty-front/src/modules/action-menu/hooks/useRegisteredActions.ts
+++ b/packages/twenty-front/src/modules/action-menu/hooks/useRegisteredActions.ts
@@ -9,10 +9,8 @@ import { contextStoreIsPageInEditModeComponentState } from '@/context-store/stat
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
import { usePermissionFlagMap } from '@/settings/roles/hooks/usePermissionFlagMap';
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
-import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { isDefined } from 'twenty-shared/utils';
import { useIcons } from 'twenty-ui/display';
-import { FeatureFlagKey } from '~/generated/graphql';
export const useRegisteredActions = (
shouldBeRegisteredParams: ShouldBeRegisteredFunctionParams,
@@ -34,10 +32,6 @@ export const useRegisteredActions = (
contextStoreIsPageInEditModeComponentState,
);
- const isRecordPageLayoutEnabled = useIsFeatureEnabled(
- FeatureFlagKey.IS_RECORD_PAGE_LAYOUT_ENABLED,
- );
-
const viewType = getActionViewType(
contextStoreCurrentViewType,
contextStoreTargetedRecordsRule,
@@ -45,7 +39,6 @@ export const useRegisteredActions = (
const recordActionConfig = getActionConfig({
objectMetadataItem,
- isRecordPageLayoutEnabled,
});
const relatedRecordActionConfig = useRelatedRecordActions({