Skip to content

The open alternative to Salesforce, designed for AI.

New record button on dashboard index page and reorder (#15367)

nitin347ccef191aa
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DashboardActionsConfig.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DashboardActionsConfig.tsx
index d44e6b13e95..e2d6f7d5dbb 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DashboardActionsConfig.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DashboardActionsConfig.tsx
@@ -1,3 +1,5 @@
+import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKeys';
+import { AddToFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/components/AddToFavoritesSingleRecordAction';
import { CancelDashboardSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/dashboard-actions/components/CancelDashboardSingleRecordAction';
import { EditDashboardSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/dashboard-actions/components/EditDashboardSingleRecordAction';
import { SaveDashboardSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/dashboard-actions/components/SaveDashboardSingleRecordAction';
@@ -9,34 +11,38 @@ 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';
+import {
+ IconDeviceFloppy,
+ IconHeart,
+ IconPencil,
+ IconX,
+} from 'twenty-ui/display';
export const DASHBOARD_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
config: {
- [PageLayoutSingleRecordActionKeys.EDIT_LAYOUT]: {
- key: PageLayoutSingleRecordActionKeys.EDIT_LAYOUT,
- label: msg`Edit Dashboard`,
- shortLabel: msg`Edit`,
+ [PageLayoutSingleRecordActionKeys.ADD_TO_FAVORITES_READ_MODE]: {
+ key: PageLayoutSingleRecordActionKeys.ADD_TO_FAVORITES_READ_MODE,
+ label: msg`Add to favorites`,
+ shortLabel: msg`Add to favorites`,
isPinned: true,
position: 0,
- Icon: IconPencil,
+ Icon: IconHeart,
type: ActionType.Standard,
scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ selectedRecord }) =>
isDefined(selectedRecord) &&
!selectedRecord?.isRemote &&
- !isDefined(selectedRecord?.deletedAt) &&
- isDefined(selectedRecord?.pageLayoutId),
+ !isDefined(selectedRecord?.deletedAt),
availableOn: [ActionViewType.SHOW_PAGE],
- component: <EditDashboardSingleRecordAction />,
+ component: <AddToFavoritesSingleRecordAction />,
},
- [PageLayoutSingleRecordActionKeys.SAVE_LAYOUT]: {
- key: PageLayoutSingleRecordActionKeys.SAVE_LAYOUT,
- label: msg`Save Dashboard`,
- shortLabel: msg`Save`,
+ [PageLayoutSingleRecordActionKeys.EDIT_LAYOUT]: {
+ key: PageLayoutSingleRecordActionKeys.EDIT_LAYOUT,
+ label: msg`Edit Dashboard`,
+ shortLabel: msg`Edit`,
isPinned: true,
position: 1,
- Icon: IconDeviceFloppy,
+ Icon: IconPencil,
type: ActionType.Standard,
scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ selectedRecord }) =>
@@ -45,14 +51,14 @@ export const DASHBOARD_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
!isDefined(selectedRecord?.deletedAt) &&
isDefined(selectedRecord?.pageLayoutId),
availableOn: [ActionViewType.SHOW_PAGE],
- component: <SaveDashboardSingleRecordAction />,
+ component: <EditDashboardSingleRecordAction />,
},
[PageLayoutSingleRecordActionKeys.CANCEL_LAYOUT_EDITION]: {
key: PageLayoutSingleRecordActionKeys.CANCEL_LAYOUT_EDITION,
label: msg`Cancel Edition`,
shortLabel: msg`Cancel`,
isPinned: true,
- position: 2,
+ position: 0,
Icon: IconX,
type: ActionType.Standard,
scope: ActionScope.RecordSelection,
@@ -64,8 +70,26 @@ export const DASHBOARD_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
availableOn: [ActionViewType.SHOW_PAGE],
component: <CancelDashboardSingleRecordAction />,
},
+ [PageLayoutSingleRecordActionKeys.SAVE_LAYOUT]: {
+ key: PageLayoutSingleRecordActionKeys.SAVE_LAYOUT,
+ label: msg`Save Dashboard`,
+ shortLabel: msg`Save`,
+ isPinned: true,
+ position: 1,
+ Icon: IconDeviceFloppy,
+ type: ActionType.Standard,
+ scope: ActionScope.RecordSelection,
+ shouldBeRegistered: ({ selectedRecord }) =>
+ isDefined(selectedRecord) &&
+ !selectedRecord?.isRemote &&
+ !isDefined(selectedRecord?.deletedAt) &&
+ isDefined(selectedRecord?.pageLayoutId),
+ availableOn: [ActionViewType.SHOW_PAGE],
+ component: <SaveDashboardSingleRecordAction />,
+ },
},
actionKeys: [
+ NoSelectionRecordActionKeys.CREATE_NEW_RECORD,
SingleRecordActionKeys.ADD_TO_FAVORITES,
SingleRecordActionKeys.REMOVE_FROM_FAVORITES,
SingleRecordActionKeys.DELETE,
@@ -76,34 +100,39 @@ export const DASHBOARD_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD,
],
propertiesToOverwrite: {
+ [NoSelectionRecordActionKeys.CREATE_NEW_RECORD]: {
+ position: 0,
+ label: msg`Create new dashboard`,
+ },
[SingleRecordActionKeys.ADD_TO_FAVORITES]: {
position: 3,
+ isPinned: false,
},
[SingleRecordActionKeys.REMOVE_FROM_FAVORITES]: {
position: 4,
},
[SingleRecordActionKeys.DELETE]: {
- position: 5,
+ position: 2,
label: msg`Delete dashboard`,
},
[SingleRecordActionKeys.EXPORT_FROM_RECORD_SHOW]: {
- position: 6,
+ position: 5,
label: msg`Export dashboard`,
},
[SingleRecordActionKeys.DESTROY]: {
- position: 7,
+ position: 6,
label: msg`Permanently destroy dashboard`,
},
[SingleRecordActionKeys.RESTORE]: {
- position: 8,
+ position: 7,
label: msg`Restore dashboard`,
},
[SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD]: {
- position: 9,
+ position: 8,
label: msg`Navigate to previous dashboard`,
},
[SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD]: {
- position: 10,
+ position: 9,
label: msg`Navigate to next dashboard`,
},
},
diff --git a/packages/twenty-front/src/modules/page-layout/actions/PageLayoutSingleRecordActionKeys.ts b/packages/twenty-front/src/modules/page-layout/actions/PageLayoutSingleRecordActionKeys.ts
index 8c9cb500442..b911bb2a749 100644
--- a/packages/twenty-front/src/modules/page-layout/actions/PageLayoutSingleRecordActionKeys.ts
+++ b/packages/twenty-front/src/modules/page-layout/actions/PageLayoutSingleRecordActionKeys.ts
@@ -2,4 +2,5 @@ export enum PageLayoutSingleRecordActionKeys {
EDIT_LAYOUT = 'edit-layout-single-record',
SAVE_LAYOUT = 'save-layout-single-record',
CANCEL_LAYOUT_EDITION = 'cancel-layout-edition-single-record',
+ ADD_TO_FAVORITES_READ_MODE = 'add-to-favorites-read-mode-dashboard',
}
diff --git a/packages/twenty-front/src/modules/page-layout/hooks/useSetIsPageLayoutInEditMode.ts b/packages/twenty-front/src/modules/page-layout/hooks/useSetIsPageLayoutInEditMode.ts
index 5e38d7cdd99..061877ed9b4 100644
--- a/packages/twenty-front/src/modules/page-layout/hooks/useSetIsPageLayoutInEditMode.ts
+++ b/packages/twenty-front/src/modules/page-layout/hooks/useSetIsPageLayoutInEditMode.ts
@@ -1,3 +1,4 @@
+import { SingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/types/SingleRecordActionsKey';
import { forceRegisteredActionsByKeyState } from '@/action-menu/actions/states/forceRegisteredActionsMapComponentState';
import { PageLayoutSingleRecordActionKeys } from '@/page-layout/actions/PageLayoutSingleRecordActionKeys';
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
@@ -26,6 +27,8 @@ export const useSetIsPageLayoutInEditMode = (pageLayoutIdFromProps: string) => {
[PageLayoutSingleRecordActionKeys.EDIT_LAYOUT]: !value,
[PageLayoutSingleRecordActionKeys.SAVE_LAYOUT]: value,
[PageLayoutSingleRecordActionKeys.CANCEL_LAYOUT_EDITION]: value,
+ [PageLayoutSingleRecordActionKeys.ADD_TO_FAVORITES_READ_MODE]: !value,
+ [SingleRecordActionKeys.ADD_TO_FAVORITES]: value,
}));
},
[isPageLayoutInEditModeState],