* managed by tooltip * updated for team admin * updated for typechecks and naming * for multiple admins * update to show team link when more than 2 admins * nit/chore : variable naming * improvement --------- Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: unknown <[email protected]>
This commit is contained in:
4 files changed
+105
-32
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import Link from "next/link";
|
||||
import { useMemo } from "react";
|
||||
import type { z } from "zod";
|
||||
|
||||
@@ -10,7 +11,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { baseEventTypeSelect } from "@calcom/prisma";
|
||||
import { SchedulingType } from "@calcom/prisma/enums";
|
||||
import type { EventTypeModel } from "@calcom/prisma/zod";
|
||||
import { Badge } from "@calcom/ui";
|
||||
import { Badge, Tooltip } from "@calcom/ui";
|
||||
|
||||
export type EventTypeDescriptionProps = {
|
||||
eventType: Pick<
|
||||
@@ -19,6 +20,7 @@ export type EventTypeDescriptionProps = {
|
||||
> & {
|
||||
descriptionAsSafeHTML?: string | null;
|
||||
recurringEvent: Prisma.JsonValue;
|
||||
managedBy?: { teamId: number | undefined; admins: string[] };
|
||||
};
|
||||
className?: string;
|
||||
shortenDescription?: boolean;
|
||||
@@ -40,6 +42,32 @@ export const EventTypeDescription = ({
|
||||
|
||||
const paymentAppData = getPaymentAppData(eventType);
|
||||
|
||||
const showManagedBadge = eventType.metadata?.managedEventConfig && !isPublic;
|
||||
const numberOfAdmins = eventType.managedBy?.admins.length || 0;
|
||||
let managedByToolTipContent;
|
||||
|
||||
if (numberOfAdmins > 0) {
|
||||
managedByToolTipContent = t("managed_by_teamAdmins", {
|
||||
teamAdmins: eventType.managedBy?.admins?.slice(0, 2).join(", "),
|
||||
});
|
||||
if (numberOfAdmins > 2) {
|
||||
managedByToolTipContent = (
|
||||
<>
|
||||
{`${managedByToolTipContent} ${t("and")} `}
|
||||
{!!eventType.managedBy?.teamId ? (
|
||||
<Link
|
||||
href={`/settings/teams/${eventType.managedBy?.teamId}/members`}
|
||||
className="text-blue-500 underline hover:text-blue-600 focus:outline-none">
|
||||
{`${numberOfAdmins - 2} ${t("more")}`}
|
||||
</Link>
|
||||
) : (
|
||||
<span>{`${numberOfAdmins - 2} ${t("more")}`}</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={classNames("text-subtle", className)}>
|
||||
@@ -78,11 +106,22 @@ export const EventTypeDescription = ({
|
||||
</Badge>
|
||||
</li>
|
||||
)}
|
||||
{eventType.metadata?.managedEventConfig && !isPublic && (
|
||||
<Badge variant="gray" startIcon="lock">
|
||||
{t("managed")}
|
||||
</Badge>
|
||||
)}
|
||||
{showManagedBadge &&
|
||||
(numberOfAdmins === 0 ? (
|
||||
<div>
|
||||
<Badge variant="gray" startIcon="lock">
|
||||
{t("managed")}
|
||||
</Badge>
|
||||
</div>
|
||||
) : (
|
||||
<Tooltip content={managedByToolTipContent}>
|
||||
<div>
|
||||
<Badge variant="gray" startIcon="lock">
|
||||
{t("managed")}
|
||||
</Badge>
|
||||
</div>
|
||||
</Tooltip>
|
||||
))}
|
||||
{recurringEvent?.count && recurringEvent.count > 0 && (
|
||||
<li className="hidden xl:block" data-testid="repeat-eventtype">
|
||||
<Badge variant="gray" startIcon="refresh-cw">
|
||||
|
||||
Reference in new issue
Block a user