Scheduling infrastructure for absolutely everyone.
feat: added workflows to all actions (#16691)
Gaurav Verma706e8e4c1f42
diff --git a/packages/features/ee/workflows/components/WorkflowStepContainer.tsx b/packages/features/ee/workflows/components/WorkflowStepContainer.tsxindex 099742aa19d..6da41d15206 100644--- a/packages/features/ee/workflows/components/WorkflowStepContainer.tsx+++ b/packages/features/ee/workflows/components/WorkflowStepContainer.tsx@@ -161,14 +161,8 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {? form.register(`steps.${step.stepNumber - 1}.emailSubject`): { ref: null, name: "" };- const { ref: reminderBodyFormRef, ...restReminderBodyForm } = step- ? form.register(`steps.${step.stepNumber - 1}.reminderBody`)- : { ref: null, name: "" };-const refEmailSubject = useRef<HTMLTextAreaElement | null>(null);- const refReminderBody = useRef<HTMLTextAreaElement | null>(null);-const getNumberVerificationStatus = () =>!!step &&!!verifiedNumbers.find(@@ -185,17 +179,6 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {useEffect(() => setNumberVerified(getNumberVerificationStatus()), [verifiedNumbers.length]);useEffect(() => setEmailVerified(getEmailVerificationStatus()), [verifiedEmails.length]);- const addVariableBody = (variable: string) => {- if (step) {- const currentMessageBody = refReminderBody?.current?.value || "";- const cursorPosition = refReminderBody?.current?.selectionStart || currentMessageBody.length;- const messageWithAddedVariable = `${currentMessageBody.substring(0, cursorPosition)}{${variable- .toUpperCase()- .replace(/ /g, "_")}}${currentMessageBody.substring(cursorPosition)}`;- form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, messageWithAddedVariable);- }- };-const addVariableEmailSubject = (variable: string) => {if (step) {const currentEmailSubject = refEmailSubject?.current?.value || "";@@ -920,57 +903,35 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {</div>)}- {step.action !== WorkflowActions.SMS_ATTENDEE &&- step.action !== WorkflowActions.SMS_NUMBER ? (- <>- <div className="mb-2 flex items-center pb-[1.5px]">- <Label className="mb-0 flex-none ">- {isEmailSubjectNeeded ? t("email_body") : t("text_message")}- </Label>- </div>- <Editor- getText={() => {- return props.form.getValues(`steps.${step.stepNumber - 1}.reminderBody`) || "";- }}- setText={(text: string) => {- props.form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, text);- props.form.clearErrors();- }}- variables={DYNAMIC_TEXT_VARIABLES}- height="200px"- updateTemplate={updateTemplate}- firstRender={firstRender}- setFirstRender={setFirstRender}- editable={!props.readOnly && !isWhatsappAction(step.action)}- />- </>- ) : (- <>- <div className="flex items-center">- <Label className={classNames("flex-none", props.readOnly ? "mb-2" : "mb-0")}>- {isEmailSubjectNeeded ? t("email_body") : t("text_message")}- </Label>- {!props.readOnly && (- <div className="flex-grow text-right">- <AddVariablesDropdown- addVariable={addVariableBody}- variables={DYNAMIC_TEXT_VARIABLES}- />- </div>- )}- </div>- <TextArea- ref={(e) => {- reminderBodyFormRef?.(e);- refReminderBody.current = e;- }}- className="my-0 h-24"- disabled={props.readOnly}- required- {...restReminderBodyForm}- />- </>- )}+ <div className="mb-2 flex items-center pb-1">+ <Label className="mb-0 flex-none ">+ {isEmailSubjectNeeded ? t("email_body") : t("text_message")}+ </Label>+ </div>+ <Editor+ getText={() => {+ return props.form.getValues(`steps.${step.stepNumber - 1}.reminderBody`) || "";+ }}+ setText={(text: string) => {+ props.form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, text);+ props.form.clearErrors();+ }}+ variables={DYNAMIC_TEXT_VARIABLES}+ addVariableButtonTop={+ step.action === WorkflowActions.SMS_ATTENDEE || step.action === WorkflowActions.SMS_NUMBER+ }+ height="200px"+ updateTemplate={updateTemplate}+ firstRender={firstRender}+ setFirstRender={setFirstRender}+ editable={!props.readOnly && !isWhatsappAction(step.action)}+ excludedToolbarItems={+ step.action !== WorkflowActions.SMS_ATTENDEE && step.action !== WorkflowActions.SMS_NUMBER+ ? []+ : ["blockType", "bold", "italic", "link"]+ }+ />+{form.formState.errors.steps &&form.formState?.errors?.steps[step.stepNumber - 1]?.reminderBody && (<p className="mt-1 text-sm text-red-500">diff --git a/packages/ui/components/editor/Editor.tsx b/packages/ui/components/editor/Editor.tsxindex 109abd2e8fb..5eefa7afd0b 100644--- a/packages/ui/components/editor/Editor.tsx+++ b/packages/ui/components/editor/Editor.tsx@@ -36,6 +36,7 @@ export type TextEditorProps = {setText: (text: string) => void;excludedToolbarItems?: string[];variables?: string[];+ addVariableButtonTop?: boolean;height?: string;maxHeight?: string;placeholder?: string;@@ -80,6 +81,7 @@ export const Editor = (props: TextEditorProps) => {editable={editable}excludedToolbarItems={props.excludedToolbarItems}variables={props.variables}+ addVariableButtonTop={props.addVariableButtonTop}updateTemplate={props.updateTemplate}firstRender={props.firstRender}setFirstRender={props.setFirstRender}diff --git a/packages/ui/components/editor/plugins/AddVariablesDropdown.tsx b/packages/ui/components/editor/plugins/AddVariablesDropdown.tsxindex 73f1850826f..5ab70749997 100644--- a/packages/ui/components/editor/plugins/AddVariablesDropdown.tsx+++ b/packages/ui/components/editor/plugins/AddVariablesDropdown.tsx@@ -7,6 +7,7 @@ interface IAddVariablesDropdown {addVariable: (variable: string) => void;isTextEditor?: boolean;variables: string[];+ addVariableButtonTop?: boolean;}export const AddVariablesDropdown = (props: IAddVariablesDropdown) => {@@ -22,7 +23,16 @@ export const AddVariablesDropdown = (props: IAddVariablesDropdown) => {{t("add_variable")}<Icon name="chevron-down" className="ml-1 mt-[2px] h-4 w-4" /></div>- <div className="block sm:hidden">+</div>+ <div className="block sm:hidden">+ {props.addVariableButtonTop ? (+ <div className="flex">+ {t("add_variable")}+ <Icon name="chevron-down" className="ml-1 mt-[2px] h-4 w-4" />+ </div>+ ) : (+ "+"+ )}+ </div></>) : (<div className="flex">diff --git a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx b/packages/ui/components/editor/plugins/ToolbarPlugin.tsxindex 989d40bea8d..e3d51a9d0cc 100644--- a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx+++ b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx@@ -507,11 +507,12 @@ export default function ToolbarPlugin(props: TextEditorProps) {)}</>{props.variables && (- <div className="ml-auto">+ <div className={`${props.addVariableButtonTop ? "-mt-10" : ""} ml-auto`}><AddVariablesDropdownaddVariable={addVariable}isTextEditor={true}variables={props.variables || []}+ addVariableButtonTop={props.addVariableButtonTop}/></div>)}