feat: disable workflows and webhooks for orgs + UI changes [CAL-1873] (#9504)
Co-authored-by: sean-brydon <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Efraín Rochín <[email protected]>
This commit is contained in:
20 files changed
+362
-381
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { Suspense } from "react";
|
||||
|
||||
@@ -6,20 +5,9 @@ import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { WebhooksByViewer } from "@calcom/trpc/server/routers/viewer/webhook/getByViewer.handler";
|
||||
import {
|
||||
Button,
|
||||
Meta,
|
||||
SkeletonText,
|
||||
EmptyScreen,
|
||||
Dropdown,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownItem,
|
||||
DropdownMenuLabel,
|
||||
} from "@calcom/ui";
|
||||
import { Meta, EmptyScreen, CreateButtonWithTeamsList } from "@calcom/ui";
|
||||
import { Avatar } from "@calcom/ui";
|
||||
import { Plus, Link as LinkIcon } from "@calcom/ui/components/icon";
|
||||
import { Link as LinkIcon } from "@calcom/ui/components/icon";
|
||||
|
||||
import { getLayout } from "../../settings/layouts/SettingsLayout";
|
||||
import { WebhookListItem, WebhookListSkeleton } from "../components";
|
||||
@@ -33,14 +21,24 @@ const WebhooksView = () => {
|
||||
enabled: router.isReady,
|
||||
});
|
||||
|
||||
const profiles = data?.profiles.filter((profile) => !profile.readOnly);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Meta
|
||||
title="Webhooks"
|
||||
description={t("add_webhook_description", { appName: APP_NAME })}
|
||||
CTA={data && data.webhookGroups.length > 0 ? <NewWebhookButton profiles={profiles} /> : <></>}
|
||||
CTA={
|
||||
data && data.webhookGroups.length > 0 ? (
|
||||
<CreateButtonWithTeamsList
|
||||
subtitle={t("create_for").toUpperCase()}
|
||||
createFunction={(teamId?: number) => {
|
||||
router.push(`webhooks/new${teamId ? `?teamId=${teamId}` : ""}`);
|
||||
}}
|
||||
data-testid="new_webhook"
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<div>
|
||||
<Suspense fallback={<WebhookListSkeleton />}>
|
||||
@@ -51,68 +49,6 @@ const WebhooksView = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const NewWebhookButton = ({
|
||||
teamId,
|
||||
profiles,
|
||||
}: {
|
||||
teamId?: number | null;
|
||||
profiles?: {
|
||||
readOnly?: boolean | undefined;
|
||||
slug: string | null;
|
||||
name: string | null;
|
||||
image?: string | undefined;
|
||||
teamId: number | null | undefined;
|
||||
}[];
|
||||
}) => {
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
|
||||
const url = new URL(`${WEBAPP_URL}/settings/developer/webhooks/new`);
|
||||
if (!!teamId) {
|
||||
url.searchParams.set("teamId", `${teamId}`);
|
||||
}
|
||||
const href = url.href;
|
||||
|
||||
if (!profiles || profiles.length < 2) {
|
||||
return (
|
||||
<Button color="primary" data-testid="new_webhook" StartIcon={Plus} href={href}>
|
||||
{isLocaleReady ? t("new") : <SkeletonText className="h-4 w-24" />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Dropdown>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button color="primary" StartIcon={Plus}>
|
||||
{isLocaleReady ? t("new") : <SkeletonText className="h-4 w-24" />}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent sideOffset={14} align="end">
|
||||
<DropdownMenuLabel>
|
||||
<div className="text-xs">{t("create_for").toUpperCase()}</div>
|
||||
</DropdownMenuLabel>
|
||||
{profiles.map((profile, idx) => (
|
||||
<DropdownMenuItem key={profile.slug}>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
StartIcon={(props) => (
|
||||
<Avatar
|
||||
alt={profile.slug || ""}
|
||||
imageSrc={profile.image || `${WEBAPP_URL}/${profile.name}/avatar.png`}
|
||||
size="sm"
|
||||
{...props}
|
||||
/>
|
||||
)}>
|
||||
<Link href={`webhooks/new${profile.teamId ? `?teamId=${profile.teamId}` : ""}`}>
|
||||
{profile.name}
|
||||
</Link>
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
);
|
||||
};
|
||||
|
||||
const WebhooksList = ({ webhooksByViewer }: { webhooksByViewer: WebhooksByViewer }) => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
@@ -166,7 +102,15 @@ const WebhooksList = ({ webhooksByViewer }: { webhooksByViewer: WebhooksByViewer
|
||||
Icon={LinkIcon}
|
||||
headline={t("create_your_first_webhook")}
|
||||
description={t("create_your_first_webhook_description", { appName: APP_NAME })}
|
||||
buttonRaw={<NewWebhookButton profiles={profiles} />}
|
||||
buttonRaw={
|
||||
<CreateButtonWithTeamsList
|
||||
subtitle={t("create_for").toUpperCase()}
|
||||
createFunction={(teamId?: number) => {
|
||||
router.push(`webhooks/new${teamId ? `?teamId=${teamId}` : ""}`);
|
||||
}}
|
||||
data-testid="new_webhook"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user