The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Show draft tag on email threads regardless of visibility (#28028)
Mariee6257a1e92f0
diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsxindex 81a29ae9bab..040b18eb64e 100644--- a/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx+++ b/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx@@ -145,6 +145,9 @@ export const EmailThreadPreview = ({ thread }: EmailThreadPreviewProps) => {isSubjectVisible && isNonEmptyString(thread.subject)? thread.subject: t`Email thread`;+ const draftTag = thread.lastMessageIsDraft ? (+ <Tag color="orange">{t`Draft`}</Tag>+ ) : null;return (<ActivityRow@@ -198,17 +201,21 @@ export const EmailThreadPreview = ({ thread }: EmailThreadPreviewProps) => {<StyledSubjectAndBody>{visibility === MessageChannelVisibility.METADATA && (- <EmailThreadNotShared visibility={visibility} />+ <>+ {draftTag}+ <EmailThreadNotShared visibility={visibility} />+ </>)}{visibility === MessageChannelVisibility.SUBJECT && (<>+ {draftTag}<StyledSubject>{thread.subject}</StyledSubject><EmailThreadNotShared visibility={visibility} /></>)}{visibility === MessageChannelVisibility.SHARE_EVERYTHING && (<>- {thread.lastMessageIsDraft && <Tag color="orange">{t`Draft`}</Tag>}+ {draftTag}<StyledSubject>{thread.subject}</StyledSubject><StyledBody>{thread.lastMessageBody}</StyledBody></>diff --git a/packages/twenty-front/src/modules/activities/emails/components/__stories__/EmailThreadPreview.stories.tsx b/packages/twenty-front/src/modules/activities/emails/components/__stories__/EmailThreadPreview.stories.tsxnew file mode 100644index 00000000000..6f11579e038--- /dev/null+++ b/packages/twenty-front/src/modules/activities/emails/components/__stories__/EmailThreadPreview.stories.tsx@@ -0,0 +1,103 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, within } from 'storybook/test';++import { EmailThreadPreview } from '@/activities/emails/components/EmailThreadPreview';+import { ComponentDecorator } from 'twenty-ui/testing';+import {+ MessageChannelVisibility,+ type TimelineThread,+} from '~/generated/graphql';+import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';+import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';++const thread: TimelineThread = {+ id: '1b2032b1-49da-4b23-8676-916cb19b93fa',+ read: true,+ visibility: MessageChannelVisibility.SHARE_EVERYTHING,+ firstParticipant: {+ personId: '16b5acc6-4f11-43bf-90d4-7e5501f1c2a4',+ workspaceMemberId: null,+ firstName: 'Charles',+ lastName: 'Bochet',+ displayName: 'Charles Bochet',+ avatarUrl: '',+ handle: '[email protected]',+ },+ lastTwoParticipants: [],+ lastMessageReceivedAt: '2026-10-08T18:00:44.000Z',+ lastMessageBody: 'Happy to walk you through the setup',+ lastMessageIsDraft: false,+ subject: 'A quick hello from Twenty',+ numberOfMessagesInThread: 1,+ participantCount: 1,+};++const meta: Meta<typeof EmailThreadPreview> = {+ title: 'Modules/Activities/Emails/EmailThreadPreview',+ component: EmailThreadPreview,+ decorators: [+ MemoryRouterDecorator,+ ComponentDecorator,+ ObjectMetadataItemsDecorator,+ ],+ args: { thread },+};++export default meta;+type Story = StoryObj<typeof EmailThreadPreview>;++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await canvas.findByText('A quick hello from Twenty');+ await expect(canvas.queryByText('Draft')).not.toBeInTheDocument();+ },+};++export const Draft: Story = {+ args: { thread: { ...thread, lastMessageIsDraft: true } },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expect(await canvas.findByText('Draft')).toBeVisible();+ },+};++export const DraftWithSubjectVisibility: Story = {+ args: {+ thread: {+ ...thread,+ lastMessageIsDraft: true,+ visibility: MessageChannelVisibility.SUBJECT,+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expect(await canvas.findByText('Draft')).toBeVisible();+ await expect(canvas.getByText('Not shared')).toBeVisible();+ await expect(+ canvas.queryByText('Happy to walk you through the setup'),+ ).not.toBeInTheDocument();+ },+};++export const DraftWithMetadataVisibility: Story = {+ args: {+ thread: {+ ...thread,+ lastMessageIsDraft: true,+ visibility: MessageChannelVisibility.METADATA,+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expect(await canvas.findByText('Draft')).toBeVisible();+ await expect(canvas.getByText('Not shared')).toBeVisible();+ await expect(+ canvas.queryByText('A quick hello from Twenty'),+ ).not.toBeInTheDocument();+ },+};