fix: save workflow button not visible on dev env (#14910)
* fix: save workflow button not visible on dev env * refactor: use the CALCOM_ENV constant * fix: ui fix for header on workspace pages * refactor: remove unused variable --------- Co-authored-by: Carina Wollendorfer <[email protected]>
This commit is contained in:
1 parent
c2a07e221d
commit
097a69d7d7
2 files changed
+166
-157
No files matched your search
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
|
|||||||
import type { Dispatch, SetStateAction } from "react";
|
import type { Dispatch, SetStateAction } from "react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import Shell from "@calcom/features/shell/Shell";
|
import Shell, { ShellMain } from "@calcom/features/shell/Shell";
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
@@ -51,50 +51,51 @@ function WorkflowsPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Shell
|
<Shell withoutMain>
|
||||||
withoutMain={false}
|
|
||||||
heading={t("workflows")}
|
|
||||||
subtitle={t("workflows_to_automate_notifications")}
|
|
||||||
title="Workflows"
|
|
||||||
description="Create workflows to automate notifications and reminders."
|
|
||||||
hideHeadingOnMobile
|
|
||||||
CTA={
|
|
||||||
session.data?.hasValidLicense ? (
|
|
||||||
<CreateButtonWithTeamsList
|
|
||||||
subtitle={t("new_workflow_subtitle").toUpperCase()}
|
|
||||||
createFunction={(teamId?: number) => {
|
|
||||||
createMutation.mutate({ teamId });
|
|
||||||
}}
|
|
||||||
isPending={createMutation.isPending}
|
|
||||||
disableMobileButton={true}
|
|
||||||
onlyShowWithNoTeams={true}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}>
|
|
||||||
<LicenseRequired>
|
<LicenseRequired>
|
||||||
<>
|
<ShellMain
|
||||||
{queryRes.data?.totalCount ? (
|
heading={t("workflows")}
|
||||||
<div className="flex">
|
subtitle={t("workflows_to_automate_notifications")}
|
||||||
<TeamsFilter />
|
title="Workflows"
|
||||||
<div className="ml-auto">
|
description="Create workflows to automate notifications and reminders."
|
||||||
<CreateButtonWithTeamsList
|
hideHeadingOnMobile
|
||||||
subtitle={t("new_workflow_subtitle").toUpperCase()}
|
CTA={
|
||||||
createFunction={(teamId?: number) => createMutation.mutate({ teamId })}
|
session.data?.hasValidLicense ? (
|
||||||
isPending={createMutation.isPending}
|
<CreateButtonWithTeamsList
|
||||||
disableMobileButton={true}
|
subtitle={t("new_workflow_subtitle").toUpperCase()}
|
||||||
onlyShowWithTeams={true}
|
createFunction={(teamId?: number) => {
|
||||||
/>
|
createMutation.mutate({ teamId });
|
||||||
|
}}
|
||||||
|
isPending={createMutation.isPending}
|
||||||
|
disableMobileButton={true}
|
||||||
|
onlyShowWithNoTeams={true}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
}>
|
||||||
|
<>
|
||||||
|
{queryRes.data?.totalCount ? (
|
||||||
|
<div className="flex">
|
||||||
|
<TeamsFilter />
|
||||||
|
<div className="ml-auto">
|
||||||
|
<CreateButtonWithTeamsList
|
||||||
|
subtitle={t("new_workflow_subtitle").toUpperCase()}
|
||||||
|
createFunction={(teamId?: number) => createMutation.mutate({ teamId })}
|
||||||
|
isPending={createMutation.isPending}
|
||||||
|
disableMobileButton={true}
|
||||||
|
onlyShowWithTeams={true}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
) : null}
|
||||||
) : null}
|
<FilterResults
|
||||||
<FilterResults
|
queryRes={queryRes}
|
||||||
queryRes={queryRes}
|
emptyScreen={<EmptyScreen isFilteredView={false} />}
|
||||||
emptyScreen={<EmptyScreen isFilteredView={false} />}
|
noResultsScreen={<EmptyScreen isFilteredView={true} />}
|
||||||
noResultsScreen={<EmptyScreen isFilteredView={true} />}
|
SkeletonLoader={SkeletonLoader}>
|
||||||
SkeletonLoader={SkeletonLoader}>
|
<WorkflowList workflows={queryRes.data?.filtered} />
|
||||||
<WorkflowList workflows={queryRes.data?.filtered} />
|
</FilterResults>
|
||||||
</FilterResults>
|
</>
|
||||||
</>
|
</ShellMain>
|
||||||
</LicenseRequired>
|
</LicenseRequired>
|
||||||
</Shell>
|
</Shell>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import Shell from "@calcom/features/shell/Shell";
|
import Shell, { ShellMain } from "@calcom/features/shell/Shell";
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { SENDER_ID } from "@calcom/lib/constants";
|
import { SENDER_ID } from "@calcom/lib/constants";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
@@ -204,124 +204,132 @@ function WorkflowPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return session.data ? (
|
return session.data ? (
|
||||||
<Form
|
<Shell withoutMain backPath="/workflows">
|
||||||
form={form}
|
<LicenseRequired>
|
||||||
handleSubmit={async (values) => {
|
<Form
|
||||||
let activeOnEventTypeIds: number[] = [];
|
form={form}
|
||||||
let isEmpty = false;
|
handleSubmit={async (values) => {
|
||||||
let isVerified = true;
|
let activeOnEventTypeIds: number[] = [];
|
||||||
|
let isEmpty = false;
|
||||||
|
let isVerified = true;
|
||||||
|
|
||||||
values.steps.forEach((step) => {
|
values.steps.forEach((step) => {
|
||||||
const strippedHtml = step.reminderBody?.replace(/<[^>]+>/g, "") || "";
|
const strippedHtml = step.reminderBody?.replace(/<[^>]+>/g, "") || "";
|
||||||
|
|
||||||
const isBodyEmpty = !isSMSOrWhatsappAction(step.action) && strippedHtml.length <= 1;
|
const isBodyEmpty = !isSMSOrWhatsappAction(step.action) && strippedHtml.length <= 1;
|
||||||
|
|
||||||
if (isBodyEmpty) {
|
if (isBodyEmpty) {
|
||||||
form.setError(`steps.${step.stepNumber - 1}.reminderBody`, {
|
form.setError(`steps.${step.stepNumber - 1}.reminderBody`, {
|
||||||
type: "custom",
|
type: "custom",
|
||||||
message: t("fill_this_field"),
|
message: t("fill_this_field"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step.reminderBody) {
|
||||||
|
step.reminderBody = translateVariablesToEnglish(step.reminderBody, {
|
||||||
|
locale: i18n.language,
|
||||||
|
t,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (step.emailSubject) {
|
||||||
|
step.emailSubject = translateVariablesToEnglish(step.emailSubject, {
|
||||||
|
locale: i18n.language,
|
||||||
|
t,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
isEmpty = !isEmpty ? isBodyEmpty : isEmpty;
|
||||||
|
|
||||||
|
//check if phone number is verified
|
||||||
|
if (
|
||||||
|
(step.action === WorkflowActions.SMS_NUMBER ||
|
||||||
|
step.action === WorkflowActions.WHATSAPP_NUMBER) &&
|
||||||
|
!verifiedNumbers?.find((verifiedNumber) => verifiedNumber.phoneNumber === step.sendTo)
|
||||||
|
) {
|
||||||
|
isVerified = false;
|
||||||
|
|
||||||
|
form.setError(`steps.${step.stepNumber - 1}.sendTo`, {
|
||||||
|
type: "custom",
|
||||||
|
message: t("not_verified"),
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (step.reminderBody) {
|
if (!isEmpty && isVerified) {
|
||||||
step.reminderBody = translateVariablesToEnglish(step.reminderBody, { locale: i18n.language, t });
|
if (values.activeOn) {
|
||||||
}
|
activeOnEventTypeIds = values.activeOn.map((option) => {
|
||||||
if (step.emailSubject) {
|
return parseInt(option.value, 10);
|
||||||
step.emailSubject = translateVariablesToEnglish(step.emailSubject, { locale: i18n.language, t });
|
});
|
||||||
}
|
}
|
||||||
isEmpty = !isEmpty ? isBodyEmpty : isEmpty;
|
updateMutation.mutate({
|
||||||
|
id: workflowId,
|
||||||
//check if phone number is verified
|
name: values.name,
|
||||||
if (
|
activeOn: activeOnEventTypeIds,
|
||||||
(step.action === WorkflowActions.SMS_NUMBER || step.action === WorkflowActions.WHATSAPP_NUMBER) &&
|
steps: values.steps,
|
||||||
!verifiedNumbers?.find((verifiedNumber) => verifiedNumber.phoneNumber === step.sendTo)
|
trigger: values.trigger,
|
||||||
) {
|
time: values.time || null,
|
||||||
isVerified = false;
|
timeUnit: values.timeUnit || null,
|
||||||
|
});
|
||||||
form.setError(`steps.${step.stepNumber - 1}.sendTo`, {
|
utils.viewer.workflows.getVerifiedNumbers.invalidate();
|
||||||
type: "custom",
|
}
|
||||||
message: t("not_verified"),
|
}}>
|
||||||
});
|
<ShellMain
|
||||||
}
|
backPath="/workflows"
|
||||||
});
|
title={workflow && workflow.name ? workflow.name : "Untitled"}
|
||||||
|
CTA={
|
||||||
if (!isEmpty && isVerified) {
|
!readOnly && (
|
||||||
if (values.activeOn) {
|
<div>
|
||||||
activeOnEventTypeIds = values.activeOn.map((option) => {
|
<Button data-testid="save-workflow" type="submit" loading={updateMutation.isPending}>
|
||||||
return parseInt(option.value, 10);
|
{t("save")}
|
||||||
});
|
</Button>
|
||||||
}
|
</div>
|
||||||
updateMutation.mutate({
|
)
|
||||||
id: workflowId,
|
}
|
||||||
name: values.name,
|
hideHeadingOnMobile
|
||||||
activeOn: activeOnEventTypeIds,
|
heading={
|
||||||
steps: values.steps,
|
isAllDataLoaded && (
|
||||||
trigger: values.trigger,
|
<div className="flex">
|
||||||
time: values.time || null,
|
<div className={classNames(workflow && !workflow.name ? "text-muted" : "")}>
|
||||||
timeUnit: values.timeUnit || null,
|
{workflow && workflow.name ? workflow.name : "untitled"}
|
||||||
});
|
</div>
|
||||||
utils.viewer.workflows.getVerifiedNumbers.invalidate();
|
{workflow && workflow.team && (
|
||||||
}
|
<Badge className="ml-4 mt-1" variant="gray">
|
||||||
}}>
|
{workflow.team.name}
|
||||||
<Shell
|
</Badge>
|
||||||
backPath="/workflows"
|
)}
|
||||||
title={workflow && workflow.name ? workflow.name : "Untitled"}
|
{readOnly && (
|
||||||
CTA={
|
<Badge className="ml-4 mt-1" variant="gray">
|
||||||
!readOnly && (
|
{t("readonly")}
|
||||||
<div>
|
</Badge>
|
||||||
<Button data-testid="save-workflow" type="submit" loading={updateMutation.isPending}>
|
)}
|
||||||
{t("save")}
|
</div>
|
||||||
</Button>
|
)
|
||||||
</div>
|
}>
|
||||||
)
|
{!isError ? (
|
||||||
}
|
<>
|
||||||
hideHeadingOnMobile
|
{isAllDataLoaded && user ? (
|
||||||
heading={
|
<>
|
||||||
session.data?.hasValidLicense &&
|
<WorkflowDetailsPage
|
||||||
isAllDataLoaded && (
|
form={form}
|
||||||
<div className="flex">
|
workflowId={+workflowId}
|
||||||
<div className={classNames(workflow && !workflow.name ? "text-muted" : "")}>
|
user={user}
|
||||||
{workflow && workflow.name ? workflow.name : "untitled"}
|
selectedEventTypes={selectedEventTypes}
|
||||||
</div>
|
setSelectedEventTypes={setSelectedEventTypes}
|
||||||
{workflow && workflow.team && (
|
teamId={workflow ? workflow.teamId || undefined : undefined}
|
||||||
<Badge className="ml-4 mt-1" variant="gray">
|
isMixedEventType={isMixedEventType}
|
||||||
{workflow.team.name}
|
readOnly={readOnly}
|
||||||
</Badge>
|
/>
|
||||||
)}
|
</>
|
||||||
{readOnly && (
|
) : (
|
||||||
<Badge className="ml-4 mt-1" variant="gray">
|
<SkeletonLoader />
|
||||||
{t("readonly")}
|
)}
|
||||||
</Badge>
|
</>
|
||||||
)}
|
) : (
|
||||||
</div>
|
<Alert severity="error" title="Something went wrong" message={error.message} />
|
||||||
)
|
)}
|
||||||
}>
|
</ShellMain>
|
||||||
<LicenseRequired>
|
</Form>
|
||||||
{!isError ? (
|
</LicenseRequired>
|
||||||
<>
|
</Shell>
|
||||||
{isAllDataLoaded && user ? (
|
|
||||||
<>
|
|
||||||
<WorkflowDetailsPage
|
|
||||||
form={form}
|
|
||||||
workflowId={+workflowId}
|
|
||||||
user={user}
|
|
||||||
selectedEventTypes={selectedEventTypes}
|
|
||||||
setSelectedEventTypes={setSelectedEventTypes}
|
|
||||||
teamId={workflow ? workflow.teamId || undefined : undefined}
|
|
||||||
isMixedEventType={isMixedEventType}
|
|
||||||
readOnly={readOnly}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<SkeletonLoader />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Alert severity="error" title="Something went wrong" message={error.message} />
|
|
||||||
)}
|
|
||||||
</LicenseRequired>
|
|
||||||
</Shell>
|
|
||||||
</Form>
|
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user