* fix: dont check OrganizationSettings.orgAutoAcceptEmail uniqueness for platform teams * feat: display organizationId in OAuthClientCard * feat: ApiAuthStrategy handle oauth credentials * refactor: clean up ApiAuthStrategy test * refactor: use ApiAuthGuard in OauthClientsUsersController and OAuthFlowController * fix: copying org id * refactor: more specific error message when api auth * refactor: auto accept team creator membership * feat: useTeamEventType and useTeamEventTypes hooks * refactor: make team event-types public & searchable by eventSlug * feat: include host name in team event-types hosts response * fix: isFixed=true by default for COLLECTIVE event hosts * fix: useTeamEventType eventSlug access * feat: BookerPlatformWrapper enable team events by exposting orgId and teamId props * refactor: provide orgId in atoms context * refactor: use orgId from context in team event-types hooks * refactor: return teams in useMe * chore: examples app teams setup * Revert "refactor: return teams in useMe" This reverts commit de992ddc9af6ee9a2111938069f5b9c34cc2d8ea. * Revert "chore: examples app teams setup" This reverts commit 0766aa21acc25efa2361d38c3f87ddba773a0245. * feat: useTeams hook * chore: setup examples app with team event-type * fix: small fixes * swagger * Revert "refactor: provide orgId in atoms context" This reverts commit f053a498ee6f8fa8ece5ec8d8630c59eda8873e3. * feat: orgId in atoms context * feat: PlatformBilling guard * chore: delete test of the deleted oauth-client-credentials.guard * refactor: org event-types collective events isFixed always true and priority medium * refactor: org event-types COLLECTIVE response ignore isFixed and priority as they are same * fix: organizations event-types e2e * fix: billing guard * refactor: tests cleanup * fix: platform plan guard spec * refactor: e2e test cleanup * seed error if not team * refactor: rename authenticateApiKey to authenticateBearerToken * refactor: transforming response hosts * refactor: rename findUniqueByMatchingAutoAcceptEmail to findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail * refactor: rename findUniqueByMatchingAutoAcceptEmail to findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail --------- Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
175 lines
5.8 KiB
TypeScript
175 lines
5.8 KiB
TypeScript
import { useRouter } from "next/navigation";
|
|
import React from "react";
|
|
|
|
import { classNames } from "@calcom/lib";
|
|
import { PERMISSIONS_GROUPED_MAP } from "@calcom/platform-constants";
|
|
import type { Avatar } from "@calcom/prisma/client";
|
|
import { Button, Icon, showToast } from "@calcom/ui";
|
|
|
|
import { hasPermission } from "../../../../../../packages/platform/utils/permissions";
|
|
|
|
type OAuthClientCardProps = {
|
|
name: string;
|
|
logo?: Avatar;
|
|
redirectUris: string[];
|
|
bookingRedirectUri: string | null;
|
|
bookingCancelRedirectUri: string | null;
|
|
bookingRescheduleRedirectUri: string | null;
|
|
areEmailsEnabled: boolean;
|
|
permissions: number;
|
|
lastItem: boolean;
|
|
id: string;
|
|
secret: string;
|
|
onDelete: (id: string) => Promise<void>;
|
|
isLoading: boolean;
|
|
organizationId: number;
|
|
};
|
|
|
|
export const OAuthClientCard = ({
|
|
name,
|
|
logo,
|
|
redirectUris,
|
|
bookingRedirectUri,
|
|
bookingCancelRedirectUri,
|
|
bookingRescheduleRedirectUri,
|
|
permissions,
|
|
id,
|
|
secret,
|
|
lastItem,
|
|
onDelete,
|
|
isLoading,
|
|
areEmailsEnabled,
|
|
organizationId,
|
|
}: OAuthClientCardProps) => {
|
|
const router = useRouter();
|
|
|
|
const clientPermissions = Object.values(PERMISSIONS_GROUPED_MAP).map((value, index) => {
|
|
let permissionsMessage = "";
|
|
const hasReadPermission = hasPermission(permissions, value.read);
|
|
const hasWritePermission = hasPermission(permissions, value.write);
|
|
|
|
if (hasReadPermission || hasWritePermission) {
|
|
permissionsMessage = hasReadPermission ? "read" : "write";
|
|
}
|
|
|
|
if (hasReadPermission && hasWritePermission) {
|
|
permissionsMessage = "read/write";
|
|
}
|
|
|
|
return (
|
|
!!permissionsMessage && (
|
|
<div key={value.read} className="relative text-sm">
|
|
{permissionsMessage} {`${value.label}s`.toLocaleLowerCase()}
|
|
{Object.values(PERMISSIONS_GROUPED_MAP).length === index + 1 ? " " : ", "}
|
|
</div>
|
|
)
|
|
);
|
|
});
|
|
|
|
return (
|
|
<div
|
|
className={classNames(
|
|
"flex w-full justify-between px-4 py-4 sm:px-6",
|
|
lastItem ? "" : "border-subtle border-b"
|
|
)}>
|
|
<div className="flex flex-col gap-2">
|
|
<div className="flex gap-1">
|
|
<p className="font-semibold">
|
|
Client name: <span className="font-normal">{name}</span>
|
|
</p>
|
|
</div>
|
|
{!!logo && (
|
|
<div>
|
|
<>{logo}</>
|
|
</div>
|
|
)}
|
|
<div className="flex flex-col gap-2">
|
|
<div className="flex flex-row items-center gap-2">
|
|
<div className="font-semibold">Client Id:</div>
|
|
<div>{id}</div>
|
|
<Icon
|
|
name="clipboard"
|
|
type="button"
|
|
className="h-4 w-4 cursor-pointer"
|
|
onClick={() => {
|
|
navigator.clipboard.writeText(id);
|
|
showToast("Client id copied to clipboard.", "success");
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-2">
|
|
<div className="font-semibold">Client Secret:</div>
|
|
<div className="flex items-center justify-center rounded-md">
|
|
{[...new Array(20)].map((_, index) => (
|
|
<Icon name="asterisk" key={`${index}asterisk`} className="h-2 w-2" />
|
|
))}
|
|
<Icon
|
|
name="clipboard"
|
|
type="button"
|
|
className="ml-2 h-4 w-4 cursor-pointer"
|
|
onClick={() => {
|
|
navigator.clipboard.writeText(secret);
|
|
showToast("Client secret copied to clipboard.", "success");
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-col gap-2">
|
|
<div className="flex flex-row items-center gap-2">
|
|
<div className="font-semibold">Organization Id:</div>
|
|
<div>{organizationId}</div>
|
|
<Icon
|
|
name="clipboard"
|
|
type="button"
|
|
className="h-4 w-4 cursor-pointer"
|
|
onClick={() => {
|
|
navigator.clipboard.writeText(organizationId.toString());
|
|
showToast("Organization id copied to clipboard.", "success");
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="border-subtle flex text-sm">
|
|
<span className="font-semibold">Permissions: </span>
|
|
{permissions ? <div className="flex">{clientPermissions}</div> : <> Disabled</>}
|
|
</div>
|
|
<div className="flex gap-1 text-sm">
|
|
<span className="font-semibold">Redirect uris: </span>
|
|
{redirectUris.map((item, index) => (redirectUris.length === index + 1 ? `${item}` : `${item}, `))}
|
|
</div>
|
|
{bookingRedirectUri && (
|
|
<div className="flex gap-1 text-sm">
|
|
<span className="font-semibold">Booking redirect uri: </span> {bookingRedirectUri}
|
|
</div>
|
|
)}
|
|
{bookingRescheduleRedirectUri && (
|
|
<div className="flex gap-1 text-sm">
|
|
<span className="font-semibold">Booking reschedule uri: </span> {bookingRescheduleRedirectUri}
|
|
</div>
|
|
)}
|
|
{bookingCancelRedirectUri && (
|
|
<div className="flex gap-1 text-sm">
|
|
<span className="font-semibold">Booking cancel uri: </span> {bookingCancelRedirectUri}
|
|
</div>
|
|
)}
|
|
<div className="flex gap-1 text-sm">
|
|
<span className="text-sm font-semibold">Emails enabled:</span> {areEmailsEnabled ? "Yes" : "No"}
|
|
</div>
|
|
</div>
|
|
<div className="flex items-start gap-4">
|
|
<Button
|
|
className="bg-subtle hover:bg-emphasis text-white"
|
|
loading={isLoading}
|
|
disabled={isLoading}
|
|
onClick={() => router.push(`/settings/platform/oauth-clients/${id}/edit`)}>
|
|
Edit
|
|
</Button>
|
|
<Button color="destructive" loading={isLoading} disabled={isLoading} onClick={() => onDelete(id)}>
|
|
Delete
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|