Fix workflows (#4518)

Co-authored-by: Leo Giovanetti <hello@leog.me>
pull/4537/head^2
Hariom Balhara 2022-09-17 03:19:04 +05:30 committed by GitHub
parent cf7b7d7d3d
commit d71765848c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 35 deletions

View File

@ -19,9 +19,6 @@ function WorkflowsPage() {
const session = useSession();
const router = useRouter();
const me = useMeQuery();
const isFreeUser = me.data?.plan === "FREE";
const { data, isLoading } = trpc.useQuery(["viewer.workflows.list"]);
const createMutation = trpc.useMutation("viewer.workflows.createV2", {
@ -47,7 +44,7 @@ function WorkflowsPage() {
title={t("workflows")}
subtitle={data?.workflows.length ? t("workflows_to_automate_notifications") : ""}
CTA={
session.data?.hasValidLicense && !isFreeUser && data?.workflows && data?.workflows.length > 0 ? (
session.data?.hasValidLicense && data?.workflows && data?.workflows.length > 0 ? (
<Button
StartIcon={Icon.FiPlus}
onClick={() => createMutation.mutate()}
@ -63,11 +60,7 @@ function WorkflowsPage() {
<SkeletonLoader />
) : (
<>
{isFreeUser ? (
<Alert className="border " severity="warning" title={t("pro_feature_workflows")} />
) : (
<WorkflowList workflows={data?.workflows} />
)}
<WorkflowList workflows={data?.workflows} />
</>
)}
</LicenseRequired>

View File

@ -69,8 +69,6 @@ function WorkflowPage() {
const { t, i18n } = useLocale();
const session = useSession();
const router = useRouter();
const me = useMeQuery();
const isFreeUser = me.data?.plan === "FREE";
const [selectedEventTypes, setSelectedEventTypes] = useState<Option[]>([]);
const [isAllDataLoaded, setIsAllDataLoaded] = useState(false);
@ -189,45 +187,36 @@ function WorkflowPage() {
<Shell
title={workflow && workflow.name ? workflow.name : "Untitled"}
CTA={
!isFreeUser && (
<div>
<Button type="submit">{t("save")}</Button>
</div>
)
<div>
<Button type="submit">{t("save")}</Button>
</div>
}
heading={
session.data?.hasValidLicense &&
isAllDataLoaded &&
!isFreeUser && (
isAllDataLoaded && (
<div className={classNames(workflow && !workflow.name ? "text-gray-400" : "")}>
{workflow && workflow.name ? workflow.name : "untitled"}
</div>
)
}>
<LicenseRequired>
{isFreeUser ? (
<Alert className="border " severity="warning" title={t("pro_feature_workflows")} />
) : (
{!isError ? (
<>
{!isError ? (
{isAllDataLoaded ? (
<>
{isAllDataLoaded ? (
<>
<WorkflowDetailsPage
form={form}
workflowId={+workflowId}
selectedEventTypes={selectedEventTypes}
setSelectedEventTypes={setSelectedEventTypes}
/>
</>
) : (
<SkeletonLoader />
)}
<WorkflowDetailsPage
form={form}
workflowId={+workflowId}
selectedEventTypes={selectedEventTypes}
setSelectedEventTypes={setSelectedEventTypes}
/>
</>
) : (
<Alert severity="error" title="Something went wrong" message={error.message} />
<SkeletonLoader />
)}
</>
) : (
<Alert severity="error" title="Something went wrong" message={error.message} />
)}
</LicenseRequired>
</Shell>