feat: allow delete event-type platform atoms (#17065)
* feat: allow delete event-type platform atoms * fixup! feat: allow delete event-type platform atoms
This commit is contained in:
1 parent
f0cfbede7e
commit
9c3f4ec055
5 files changed
+150
-43
No files matched your search
@@ -47,26 +47,40 @@ export type EventTypeSetup = RouterOutputs["viewer"]["eventTypes"]["get"]["event
|
||||
export type EventTypeAssignedUsers = RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"]["children"];
|
||||
export type EventTypeHosts = RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"]["hosts"];
|
||||
|
||||
export const EventType = (
|
||||
props: EventTypeSetupProps & {
|
||||
allActiveWorkflows?: Workflow[];
|
||||
tabMap: TabMap;
|
||||
onDelete: (id: number) => void;
|
||||
isDeleting?: boolean;
|
||||
onConflict: (eventTypes: ChildrenEventType[]) => void;
|
||||
children?: React.ReactNode;
|
||||
handleSubmit: (values: FormValues) => void;
|
||||
formMethods: UseFormReturn<FormValues>;
|
||||
eventTypeApps?: EventTypeApps;
|
||||
isUpdating: boolean;
|
||||
isPlatform?: boolean;
|
||||
tabName: (typeof tabs)[number];
|
||||
tabsNavigation: VerticalTabItemProps[];
|
||||
}
|
||||
) => {
|
||||
const { formMethods, isPlatform, tabName } = props;
|
||||
const { eventType, team, currentUserMembership, tabMap, isUpdating } = props;
|
||||
export type EventTypeComponentProps = EventTypeSetupProps & {
|
||||
allActiveWorkflows?: Workflow[];
|
||||
tabMap: TabMap;
|
||||
onDelete: (id: number) => void;
|
||||
isDeleting?: boolean;
|
||||
onConflict: (eventTypes: ChildrenEventType[]) => void;
|
||||
children?: React.ReactNode;
|
||||
handleSubmit: (values: FormValues) => void;
|
||||
formMethods: UseFormReturn<FormValues>;
|
||||
eventTypeApps?: EventTypeApps;
|
||||
isUpdating: boolean;
|
||||
isPlatform?: boolean;
|
||||
tabName: (typeof tabs)[number];
|
||||
tabsNavigation: VerticalTabItemProps[];
|
||||
allowDelete?: boolean;
|
||||
};
|
||||
|
||||
export const EventType = ({
|
||||
formMethods,
|
||||
isPlatform,
|
||||
tabName,
|
||||
eventType,
|
||||
team,
|
||||
currentUserMembership,
|
||||
tabMap,
|
||||
isUpdating,
|
||||
isUserOrganizationAdmin,
|
||||
onDelete,
|
||||
isDeleting,
|
||||
tabsNavigation,
|
||||
handleSubmit,
|
||||
children,
|
||||
allowDelete = true,
|
||||
}: EventTypeComponentProps) => {
|
||||
const [animationParentRef] = useAutoAnimate<HTMLDivElement>();
|
||||
|
||||
return (
|
||||
@@ -80,16 +94,17 @@ export const EventType = (
|
||||
disableBorder={true}
|
||||
currentUserMembership={currentUserMembership}
|
||||
bookerUrl={eventType.bookerUrl}
|
||||
isUserOrganizationAdmin={props.isUserOrganizationAdmin}
|
||||
onDelete={props.onDelete}
|
||||
isDeleting={props.isDeleting}
|
||||
isUserOrganizationAdmin={isUserOrganizationAdmin}
|
||||
onDelete={onDelete}
|
||||
isDeleting={isDeleting}
|
||||
isPlatform={isPlatform}
|
||||
tabsNavigation={props.tabsNavigation}>
|
||||
<Form form={formMethods} id="event-type-form" handleSubmit={props.handleSubmit}>
|
||||
allowDelete={allowDelete}
|
||||
tabsNavigation={tabsNavigation}>
|
||||
<Form form={formMethods} id="event-type-form" handleSubmit={handleSubmit}>
|
||||
<div ref={animationParentRef}>{tabMap[tabName]}</div>
|
||||
</Form>
|
||||
</EventTypeSingleLayout>
|
||||
{props.children}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -47,6 +47,7 @@ type Props = {
|
||||
isDeleting?: boolean;
|
||||
isPlatform?: boolean;
|
||||
tabsNavigation: VerticalTabItemProps[];
|
||||
allowDelete?: boolean;
|
||||
};
|
||||
|
||||
function EventTypeSingleLayout({
|
||||
@@ -63,6 +64,7 @@ function EventTypeSingleLayout({
|
||||
isDeleting,
|
||||
isPlatform,
|
||||
tabsNavigation,
|
||||
allowDelete = true,
|
||||
}: Props) {
|
||||
const { t } = useLocale();
|
||||
const eventTypesLockedByOrg = eventType.team?.parent?.organizationSettings?.lockEventTypeCreationForUsers;
|
||||
@@ -187,7 +189,7 @@ function EventTypeSingleLayout({
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{!isChildrenManagedEventType && (
|
||||
{!isChildrenManagedEventType && allowDelete && (
|
||||
<Button
|
||||
color="destructive"
|
||||
variant="icon"
|
||||
@@ -201,7 +203,7 @@ function EventTypeSingleLayout({
|
||||
)}
|
||||
</ButtonGroup>
|
||||
|
||||
<VerticalDivider className="hidden lg:block" />
|
||||
{(!isPlatform || (isPlatform && allowDelete)) && <VerticalDivider className="hidden lg:block" />}
|
||||
|
||||
<Dropdown>
|
||||
<DropdownMenuTrigger asChild>
|
||||
@@ -229,16 +231,18 @@ function EventTypeSingleLayout({
|
||||
{t("copy_link")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem className="focus:ring-muted">
|
||||
<DropdownItem
|
||||
type="button"
|
||||
color="destructive"
|
||||
StartIcon="trash"
|
||||
disabled={!hasPermsToDelete}
|
||||
onClick={() => setDeleteDialogOpen(true)}>
|
||||
{t("delete")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
{allowDelete && (
|
||||
<DropdownMenuItem className="focus:ring-muted">
|
||||
<DropdownItem
|
||||
type="button"
|
||||
color="destructive"
|
||||
StartIcon="trash"
|
||||
disabled={!hasPermsToDelete}
|
||||
onClick={() => setDeleteDialogOpen(true)}>
|
||||
{t("delete")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuSeparator />
|
||||
<div className="hover:bg-subtle flex h-9 cursor-pointer flex-row items-center justify-between px-4 py-2 transition">
|
||||
<Skeleton
|
||||
|
||||
Reference in new issue
Block a user