9ea71d2ba5
* refactor: migrate MembershipRole usages to PBAC permission checks - Refactor get.handler.ts to use PermissionCheckService for canUpdateTeams - Refactor checkForInvalidAppCredentials.ts to use getTeamIdsWithPermission - Refactor outOfOffice.utils.ts to use checkPermission for ooo.update - Refactor checkIfOrgNeedsUpgrade.handler.ts to use organization.manageBilling - Refactor getActiveOnOptions.handler.ts to use eventType.update permission - Refactor WorkflowRepository.ts to use workflow.update permission - Refactor organization.tsx to use team.update permission - Refactor getEventTypesByViewer.ts to use eventType.update permission - Refactor getPublicEvent.ts to use team.read permission for private teams - Update CreateNewOutOfOfficeEntryButton.tsx to use canUpdateOOO prop Co-Authored-By: sean@cal.com <Sean@brydon.io> * fix: use organization.update permission instead of team.update for org management Co-Authored-By: sean@cal.com <Sean@brydon.io> * fix: rename teamsWithEventTypeManagePermission to teamsWithEventTypeUpdatePermission Renamed variable to match the permission string being used (eventType.update) Co-Authored-By: sean@cal.com <Sean@brydon.io> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
|
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
|
import type { ButtonProps } from "@calcom/ui/components/button";
|
|
import { Button } from "@calcom/ui/components/button";
|
|
|
|
import { OutOfOfficeTab } from "./OutOfOfficeToggleGroup";
|
|
|
|
const CreateNewOutOfOfficeEntryButton = ({
|
|
size,
|
|
onClick,
|
|
...rest
|
|
}: {
|
|
size?: ButtonProps["size"];
|
|
onClick: () => void;
|
|
"data-testid"?: string;
|
|
}) => {
|
|
const { t } = useLocale();
|
|
const me = useMeQuery();
|
|
const { data: orgData } = trpc.viewer.organizations.listCurrent.useQuery();
|
|
const isOrgAdminOrOwner = orgData && checkAdminOrOwner(orgData.user.role);
|
|
const hasTeamOOOAdminAccess = isOrgAdminOrOwner || me?.data?.canUpdateTeams;
|
|
|
|
const params = useCompatSearchParams();
|
|
const selectedTab = params?.get("type") ?? OutOfOfficeTab.MINE;
|
|
|
|
return (
|
|
<Button
|
|
color="primary"
|
|
size={size ?? "base"}
|
|
className="flex items-center justify-between px-2 md:px-4"
|
|
StartIcon="plus"
|
|
onClick={onClick}
|
|
data-testid={rest["data-testid"]}
|
|
disabled={selectedTab === OutOfOfficeTab.TEAM && !hasTeamOOOAdminAccess}>
|
|
<span className="sr-only md:not-sr-only md:inline">{t("add")}</span>
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default CreateNewOutOfOfficeEntryButton;
|