Skip to content

The open alternative to Salesforce, designed for AI.

fix(front): hide the remove icon on the last invite-team input (#24039)

Félix Malfait480d6e59e7b8
diff --git a/packages/twenty-front/src/pages/onboarding/InviteTeam.tsx b/packages/twenty-front/src/pages/onboarding/InviteTeam.tsx
index d1aa132a836..023a20d4da1 100644
--- a/packages/twenty-front/src/pages/onboarding/InviteTeam.tsx
+++ b/packages/twenty-front/src/pages/onboarding/InviteTeam.tsx
@@ -58,6 +58,8 @@ export const InviteTeam = () => {
const creditsRewardPerUser = onboardingConfig?.inviteTeamCreditsRewardPerUser;
const transition = useOnboardingMotionTransition();
+ const canRemoveEmailField = fields.length > 1;
+
return (
<StyledOnboardingStepPage>
<StyledOnboardingStepHeading>
@@ -108,8 +110,10 @@ export const InviteTeam = () => {
onBlur={onBlur}
error={error?.message}
onChange={onChange}
- RightIcon={IconX}
- onRightIconClick={() => remove(index)}
+ RightIcon={canRemoveEmailField ? IconX : undefined}
+ onRightIconClick={
+ canRemoveEmailField ? () => remove(index) : undefined
+ }
noErrorHelper
fullWidth
/>
diff --git a/packages/twenty-front/src/pages/onboarding/__stories__/InviteTeam.stories.tsx b/packages/twenty-front/src/pages/onboarding/__stories__/InviteTeam.stories.tsx
index 8102922f63a..7d049855f77 100644
--- a/packages/twenty-front/src/pages/onboarding/__stories__/InviteTeam.stories.tsx
+++ b/packages/twenty-front/src/pages/onboarding/__stories__/InviteTeam.stories.tsx
@@ -1,7 +1,7 @@
import { getOperationName } from '~/utils/getOperationName';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { HttpResponse, graphql } from 'msw';
-import { within } from 'storybook/test';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
import { AppPath } from 'twenty-shared/types';
import { OnboardingStatus } from '~/generated-metadata/graphql';
@@ -31,6 +31,11 @@ const meta: Meta<PageDecoratorArgs> = {
},
});
}),
+ graphql.query('GetInviteSuggestions', () => {
+ return HttpResponse.json({
+ data: { getInviteSuggestions: [] },
+ });
+ }),
graphqlMocks.handlers,
],
},
@@ -41,9 +46,42 @@ export default meta;
export type Story = StoryObj<typeof InviteTeam>;
+const findEmailInputs = (canvas: ReturnType<typeof within>) =>
+ canvas.findAllByPlaceholderText(/@apple\.com$/);
+
+const getRemoveButtons = (canvasElement: HTMLElement) =>
+ canvasElement.ownerDocument.body.querySelectorAll('.tabler-icon-x');
+
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement.ownerDocument.body);
await canvas.findByText('Invite your team');
},
};
+
+export const RemovesAllInputsButTheLast: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement.ownerDocument.body);
+
+ await canvas.findByText('Invite your team');
+ await waitFor(async () =>
+ expect(await findEmailInputs(canvas)).toHaveLength(3),
+ );
+
+ expect(getRemoveButtons(canvasElement)).toHaveLength(3);
+
+ await userEvent.click(getRemoveButtons(canvasElement)[2]);
+ await waitFor(async () =>
+ expect(await findEmailInputs(canvas)).toHaveLength(2),
+ );
+ expect(getRemoveButtons(canvasElement)).toHaveLength(2);
+
+ await userEvent.click(getRemoveButtons(canvasElement)[1]);
+ await waitFor(async () =>
+ expect(await findEmailInputs(canvas)).toHaveLength(1),
+ );
+ await waitFor(() =>
+ expect(getRemoveButtons(canvasElement)).toHaveLength(0),
+ );
+ },
+};