Support sender variable on workflow send-email action (#22512)
## Context Draft-email workflow steps already accept a workspace member variable as the sender: the step input's `connectedAccountId` can hold a workflow variable that resolves to a workspace member id, which the action then maps to that member's first connected account. Send-email steps were gated out of this and only accepted a static connected account pick. This enables the same dynamic sender resolution on send-email, e.g. sending from the assignee/owner of the record that triggered the workflow. ## What changed - Removed the draft-only gate in `EmailWorkflowActionBase.postprocessInput` so send-email resolves a workspace member id to a connected account the same way draft-email does - Exposed the variable picker and hint on the Account field for both email actions in the workflow step editor - Updated the send-email action spec to cover sender resolution (mirrors the draft-email spec) and replaced the `SendEmailHasNoVariablePicker` story with a variable-sender story for `SEND_EMAIL` <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/22512?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This commit is contained in:
+2
-11
@@ -121,9 +121,6 @@ export const WorkflowEditActionEmailBase = ({
|
||||
const { accounts: myAccounts, loading: myAccountsLoading } =
|
||||
useMyConnectedAccounts();
|
||||
|
||||
// Sender variables are only enabled for DRAFT_EMAIL for now; SEND_EMAIL keeps a plain account select.
|
||||
const isSenderVariableEnabled = action.type === 'DRAFT_EMAIL';
|
||||
|
||||
const configuredAccountId = formData.connectedAccountId;
|
||||
const isSenderVariable = isStandaloneVariableString(configuredAccountId);
|
||||
const isConfiguredAccountMine = myAccounts.some(
|
||||
@@ -205,17 +202,11 @@ export const WorkflowEditActionEmailBase = ({
|
||||
<FormSelectFieldInput
|
||||
key={`connected-account-${formData.connectedAccountId ?? 'none'}`}
|
||||
label={t`Account`}
|
||||
hint={
|
||||
isSenderVariableEnabled
|
||||
? t`Pick a connected account or set a workspace member as variable`
|
||||
: undefined
|
||||
}
|
||||
hint={t`Pick a connected account or set a workspace member as variable`}
|
||||
defaultValue={formData.connectedAccountId}
|
||||
options={connectedAccountOptions}
|
||||
onChange={handleConnectedAccountChange}
|
||||
VariablePicker={
|
||||
isSenderVariableEnabled ? WorkflowVariablePicker : undefined
|
||||
}
|
||||
VariablePicker={WorkflowVariablePicker}
|
||||
readonly={actionOptions.readonly}
|
||||
callToActionButton={{
|
||||
onClick: () => {
|
||||
|
||||
+35
-6
@@ -128,6 +128,36 @@ const DEFAULT_DRAFT_EMAIL_ACTION: WorkflowDraftEmailAction = {
|
||||
},
|
||||
};
|
||||
|
||||
const VARIABLE_SENDER_SEND_EMAIL_ACTION: WorkflowSendEmailAction = {
|
||||
id: getWorkflowNodeIdMock(),
|
||||
name: 'Send Email',
|
||||
type: 'SEND_EMAIL',
|
||||
valid: true,
|
||||
settings: {
|
||||
input: {
|
||||
connectedAccountId: '{{trigger._metadata.workspaceMemberId}}',
|
||||
recipients: {
|
||||
to: 'test@twenty.com',
|
||||
cc: '',
|
||||
bcc: '',
|
||||
},
|
||||
subject: 'Welcome to Twenty!',
|
||||
body: 'Hello',
|
||||
files: [],
|
||||
inReplyTo: '',
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
retryOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const VARIABLE_SENDER_DRAFT_EMAIL_ACTION: WorkflowDraftEmailAction = {
|
||||
id: getWorkflowNodeIdMock(),
|
||||
name: 'Draft Email',
|
||||
@@ -283,11 +313,9 @@ export const VariableSender: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
// SEND_EMAIL does not expose the sender variable picker yet (DRAFT_EMAIL only),
|
||||
// so the account field stays a plain select with no variable hint.
|
||||
export const SendEmailHasNoVariablePicker: Story = {
|
||||
export const VariableSenderSendEmail: Story = {
|
||||
args: {
|
||||
action: DEFAULT_SEND_EMAIL_ACTION,
|
||||
action: VARIABLE_SENDER_SEND_EMAIL_ACTION,
|
||||
actionOptions: {
|
||||
onActionUpdate: fn(),
|
||||
},
|
||||
@@ -296,10 +324,11 @@ export const SendEmailHasNoVariablePicker: Story = {
|
||||
const canvas = within(canvasElement);
|
||||
|
||||
expect(await canvas.findByText('Account')).toBeVisible();
|
||||
expect(await canvas.findByLabelText('Remove variable')).toBeInTheDocument();
|
||||
expect(
|
||||
canvas.queryByText(
|
||||
await canvas.findByText(
|
||||
'Pick a connected account or set a workspace member as variable',
|
||||
),
|
||||
).not.toBeInTheDocument();
|
||||
).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user