Skip to content

The open alternative to Salesforce, designed for AI.

Record creation form: move Edit into the Options menu (#27946)

Thomas Trompettee737513462aa
diff --git a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx
index ff6f7497996..7493b90b249 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx
@@ -2,6 +2,7 @@ import { getToastOptionsFromError } from '@/error-handler/utils/getToastOptionsF
import { ObjectMetadataIcon } from '@/object-metadata/components/ObjectMetadataIcon';
import { HeaderIdentifier } from '@/ui/layout/page/components/HeaderIdentifier';
import { PageCardHeader } from '@/ui/layout/page/components/PageCardHeader';
+import { SidePanelOptionsDropdown } from '@/side-panel/components/SidePanelOptionsDropdown';
import { SIDE_PANEL_FOCUS_ID } from '@/side-panel/constants/SidePanelFocusId';
import { currentFocusIdSelector } from '@/ui/utilities/focus/states/currentFocusIdSelector';
import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';
@@ -29,7 +30,7 @@ import { getValidationRuleViolationsFromError } from '@/validation-rules/utils/g
import { groupValidationRuleViolationsByField } from '@/validation-rules/utils/groupValidationRuleViolationsByField';
import { useAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentState';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { useState } from 'react';
+import { useId, useState } from 'react';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { Key } from 'ts-key-enum';
@@ -38,7 +39,13 @@ import { PermissionFlagType } from 'twenty-shared/constants';
import { isDefined } from 'twenty-shared/utils';
import { InlineBanner, useToast } from 'twenty-ui/components/feedback';
import { LightButton } from 'twenty-ui/components/input';
-import { IconChevronDown, IconChevronUp, IconPlus } from 'twenty-ui/icon';
+import { Dropdown } from 'twenty-ui/components/navigation';
+import {
+ IconChevronDown,
+ IconChevronUp,
+ IconEdit,
+ IconPlus,
+} from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
@@ -120,6 +127,7 @@ const SidePanelRecordCreationForm = ({
);
const [isSubmitting, setIsSubmitting] = useState(false);
+ const optionsDropdownId = useId();
const [draftValidationRuleViolations, setDraftValidationRuleViolations] =
useState<ValidationRuleViolation[]>([]);
const [serverValidationRuleViolations, setServerValidationRuleViolations] =
@@ -353,15 +361,19 @@ const SidePanelRecordCreationForm = ({
actions={[
...(hasLayoutsPermission
? [
- <Button
- key="edit-form"
- size="sm"
- onClick={() =>
- openRecordCreationFormSettingsInSidePanel(
- objectMetadataItem,
- )
- }
- >{t`Edit`}</Button>,
+ <SidePanelOptionsDropdown
+ key="options"
+ dropdownId={optionsDropdownId}
+ >
+ <Dropdown.ActionItem
+ startIcon={<IconEdit />}
+ onClick={() =>
+ openRecordCreationFormSettingsInSidePanel(
+ objectMetadataItem,
+ )
+ }
+ >{t`Edit form`}</Dropdown.ActionItem>
+ </SidePanelOptionsDropdown>,
]
: []),
<Button
diff --git a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/__tests__/SidePanelRecordCreationFormPage.test.tsx b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/__tests__/SidePanelRecordCreationFormPage.test.tsx
index 15325e0e749..fa31f858c19 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/__tests__/SidePanelRecordCreationFormPage.test.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/__tests__/SidePanelRecordCreationFormPage.test.tsx
@@ -494,25 +494,28 @@ describe('SidePanelRecordCreationFormPage', () => {
expect(screen.queryByLabelText('Nickname')).not.toBeInTheDocument();
});
- it('opens the form configuration for members allowed to edit layouts', async () => {
+ it('opens the form configuration from the options menu for members allowed to edit layouts', async () => {
const user = userEvent.setup();
renderPage();
- await user.click(screen.getByRole('button', { name: 'Edit' }));
+ await user.click(screen.getByRole('button', { name: 'Options' }));
+ await user.click(
+ await screen.findByRole('menuitem', { name: 'Edit form' }),
+ );
expect(openRecordCreationFormSettingsInSidePanel).toHaveBeenCalledWith(
COMPANY_OBJECT,
);
});
- it('hides the edit button from members without the layouts permission', () => {
+ it('hides the options menu from members without the layouts permission', () => {
mockHasPermissionFlag.mockReturnValue(false);
renderPage();
expect(
- screen.queryByRole('button', { name: 'Edit' }),
+ screen.queryByRole('button', { name: 'Options' }),
).not.toBeInTheDocument();
});
});