refactor: Move trpc-dependent components from features to web [1] (#25859)
* refactor: migrate UnconfirmedBookingBadge from features to apps/web Move UnconfirmedBookingBadge.tsx from packages/features/bookings/ to apps/web/modules/bookings/components/ as part of the architectural refactor to remove trpc client imports from the features layer. Also removes unused preserveBookingsQueryParams function from Navigation.tsx. Co-Authored-By: [email protected] <[email protected]> * refactor: move shell navigation and badges to apps/web Move shell navigation components and trpc-using badges from packages/features to apps/web/modules to fix circular dependency: - Move navigation folder to apps/web/modules/shell/navigation/ - Move TeamInviteBadge.tsx to apps/web/modules/shell/ - Create Shell wrapper in apps/web that provides MobileNavigationContainer - Update all Shell imports in apps/web to use the new wrapper - Remove MobileNavigationContainer default from features Shell.tsx - Fix pre-existing lint warnings in touched files This establishes the pattern for migrating React components that use trpc hooks from the features layer to the web app layer, ensuring proper dependency direction: apps/web imports from packages/features, never the reverse. Co-Authored-By: [email protected] <[email protected]> * fix: move SideBar.tsx to apps/web to fix build error SideBar.tsx was importing Navigation from the moved navigation folder, causing a build error. Moving SideBar.tsx to apps/web and updating the features Shell to not have a default SidebarContainer fixes this. The web Shell wrapper now provides both the default SidebarContainer and MobileNavigationContainer, maintaining the injection pattern. Co-Authored-By: [email protected] <[email protected]> * revert * revert * revert * wip * wip * wip * wip * wip * wip * not used anywhere * wip * wip * wip * wip * fix * fix * wip * wip * wip * wip * wip * fix * fix * fix * fix * migrate * migrate admin-adpi * wip * feat: migrate organization settings components from packages/features to apps/web/modules - Migrate profile.tsx, appearance.tsx, general.tsx, privacy.tsx, guest-notifications.tsx, delegationCredential.tsx, other-team-members-view.tsx, other-team-profile-view.tsx - Migrate attributes directory (AttributesForm.tsx, DeleteAttributeModal.tsx, ListSkeleton.tsx, attributes-create-view.tsx, attributes-edit-view.tsx, attributes-list-view.tsx) - Migrate admin directory (AdminOrgEditPage.tsx, AdminOrgPage.tsx, WorkspacePlatformPage.tsx) - Update all page imports to use new paths from ~/settings/organizations/ - Update relative imports in migrated files to use @calcom/features paths - Fix lint warnings in migrated files Co-Authored-By: [email protected] <[email protected]> * fix: update test import path after migration Co-Authored-By: [email protected] <[email protected]> * fix: remove unnecessary test-setup import (already in vitest config) Co-Authored-By: [email protected] <[email protected]> * wip * refactor: delete original files after migration to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * wip * refactor more * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * mv * update import paths * wip * wip * fix * fix * fix * fix * fix * fix * fix * mv * mv * mv * fix * wip * wip * fix * fix * fix * fix: make test mocks resilient to vi.resetAllMocks() Co-Authored-By: [email protected] <[email protected]> * fix: fix AttributeForm test failures Co-Authored-By: [email protected] <[email protected]> * fix * fix * refactor: move ee files to apps/web/modules/ee/ folder - Move teams, workflows, and organizations folders to apps/web/modules/ee/ - Add LICENSE file to apps/web/modules/ee/ - Update all import paths from ~/teams/ to ~/ee/teams/ - Update all import paths from ~/settings/organizations/ to ~/ee/organizations/ - Remove duplicate MemberInvitationModal copy.tsx file Co-Authored-By: [email protected] <[email protected]> * fix: move useHasPaidPlan and dependent files to apps/web/modules - Move useHasPaidPlan.ts from packages/features/billing/hooks to apps/web/modules/billing/hooks - Move intercom files from packages/features/ee/support to apps/web/modules/ee/support - Move ContactMenuItem.tsx and dependencies (freshchat, helpscout, zendesk) to apps/web/modules/ee/support - Move ViewRecordingsDialog.tsx and RecordingListSkeleton to apps/web/modules/ee/video - Move CalVideoSettings.tsx to apps/web/modules/eventtypes/components/locations - Move CreateOrEditOutOfOfficeModal.tsx to apps/web/modules/settings/outOfOffice - Refactor UpgradeTeamsBadge to accept props and create wrapper in apps/web/modules/billing - Update all callers to use new file locations - Add eslint-disable comments for pre-existing lint warnings This fixes the tRPC server build failure caused by circular dependency where the server build was traversing into packages/features and pulling in React hooks that depend on @calcom/trpc/react types. Co-Authored-By: [email protected] <[email protected]> * fix: correct UpgradeTeamsBadge import path to use package export Co-Authored-By: [email protected] <[email protected]> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * fix * fix * fix * fix: pass plan state through SelectProps to UpgradeTeamsBadge - Add upgradeTeamsBadgeProps field to ExtendedOption type in Select component - Update OptionComponent to spread upgradeTeamsBadgeProps to UpgradeTeamsBadge - Update getOptions.ts to accept PlanState object and include upgradeTeamsBadgeProps - Update WorkflowStepContainer.tsx to pass planState to getWorkflowTriggerOptions/getWorkflowTemplateOptions - Update WorkflowDetailsPage.tsx to pass upgradeTeamsBadgeProps in transformed action options - Update AddActionDialog.tsx interface and mapping to include upgradeTeamsBadgeProps - Add eslint-disable comments for pre-existing React Hook dependency warnings This fixes the UpgradeTeamsBadge refactoring issue where the badge was always showing 'upgrade' text instead of the correct text based on plan state (trial_mode, inactive_team_plan, etc.) Co-Authored-By: [email protected] <[email protected]> * fix: update import paths to use /ee/ folder for workflows and organizations Co-Authored-By: [email protected] <[email protected]> * fix: update workflow component imports to use /ee/ folder Co-Authored-By: [email protected] <[email protected]> * fix: add missing types.ts for LocationInput.tsx Co-Authored-By: [email protected] <[email protected]> * fix: extract BookingRedirectForm type to shared location Co-Authored-By: [email protected] <[email protected]> * fix * wip * wip * fix: update BookingRedirectForm import to use local types file Co-Authored-By: [email protected] <[email protected]> * wip * fix * fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
7847177e8b
commit
8afe87ff75
374 files changed
+1213
-1417
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { ShellMainAppDirBackButton } from "app/(use-page-wrapper)/(main-nav)/ShellMainAppDirBackButton";
|
||||
import classNames from "classnames";
|
||||
|
||||
import type { LayoutProps } from "@calcom/features/shell/Shell";
|
||||
import type { LayoutProps } from "~/shell/Shell";
|
||||
|
||||
// Copied from `ShellMain` but with a different `ShellMainAppDirBackButton` import
|
||||
// for client/server component separation
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import type { LayoutProps } from "@calcom/features/shell/Shell";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
import type { LayoutProps } from "~/shell/Shell";
|
||||
|
||||
export const ShellMainAppDirBackButton = ({ backPath }: { backPath: LayoutProps["backPath"] }) => {
|
||||
const router = useRouter();
|
||||
return (
|
||||
|
||||
@@ -8,10 +8,10 @@ import { redirect } from "next/navigation";
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import { getOrganizationRepository } from "@calcom/features/ee/organizations/di/OrganizationRepository.container";
|
||||
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
|
||||
import { AvailabilitySliderTable } from "@calcom/features/timezone-buddy/components/AvailabilitySliderTable";
|
||||
import { getScheduleListItemData } from "@calcom/lib/schedules/transformers/getScheduleListItemData";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import { availabilityRouter } from "@calcom/trpc/server/routers/viewer/availability/_router";
|
||||
import { AvailabilitySliderTable } from "@calcom/web/modules/timezone-buddy/components/AvailabilitySliderTable";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
@@ -64,8 +64,8 @@ const Page = async ({ searchParams: _searchParams }: PageProps) => {
|
||||
const organizationRepository = getOrganizationRepository();
|
||||
const isOrgPrivate = organizationId
|
||||
? await organizationRepository.checkIfPrivate({
|
||||
orgId: organizationId,
|
||||
})
|
||||
orgId: organizationId,
|
||||
})
|
||||
: false;
|
||||
|
||||
const permissionService = new PermissionCheckService();
|
||||
@@ -80,9 +80,7 @@ const Page = async ({ searchParams: _searchParams }: PageProps) => {
|
||||
<ShellMainAppDir
|
||||
heading={t("availability")}
|
||||
subtitle={t("configure_availability")}
|
||||
CTA={
|
||||
<AvailabilityCTA canViewTeamAvailability={canViewTeamAvailability} />
|
||||
}>
|
||||
CTA={<AvailabilityCTA canViewTeamAvailability={canViewTeamAvailability} />}>
|
||||
{searchParams?.type === "team" && canViewTeamAvailability ? (
|
||||
<AvailabilitySliderTable isOrg={!!organizationId} />
|
||||
) : (
|
||||
|
||||
@@ -3,10 +3,11 @@ import { cookies, headers } from "next/headers";
|
||||
import React from "react";
|
||||
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
const Layout = async ({ children }: { children: React.ReactNode }) => {
|
||||
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
|
||||
if (session?.user?.id) SentrySetUser({ id: session.user.id });
|
||||
|
||||
@@ -2,7 +2,6 @@ import type { SearchParams } from "app/_types";
|
||||
import type { Session } from "next-auth";
|
||||
import { unstable_cache } from "next/cache";
|
||||
|
||||
import { TeamsListing } from "@calcom/features/ee/teams/components/TeamsListing";
|
||||
import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
|
||||
import { TeamService } from "@calcom/features/ee/teams/services/teamService";
|
||||
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
|
||||
@@ -10,6 +9,8 @@ import { ErrorWithCode } from "@calcom/lib/errors";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
import { TeamsListing } from "~/ee/teams/components/TeamsListing";
|
||||
|
||||
import { TeamsCTA } from "./CTA";
|
||||
|
||||
const getCachedTeams = unstable_cache(
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import { ShellMainAppDir } from "app/(use-page-wrapper)/(main-nav)/ShellMainAppDir";
|
||||
import { TeamsCTA } from "app/(use-page-wrapper)/(main-nav)/teams/CTA";
|
||||
|
||||
import SkeletonLoaderTeamList from "@calcom/features/ee/teams/components/SkeletonloaderTeamList";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import SkeletonLoaderTeamList from "~/ee/teams/components/SkeletonloaderTeamList";
|
||||
|
||||
export const TeamsListSkeleton = () => {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||
import posthog from "posthog-js";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { isFallbackRoute } from "@calcom/app-store/routing-forms/lib/isFallbackRoute";
|
||||
import type { RoutingFormWithResponseCount } from "@calcom/app-store/routing-forms/types/types";
|
||||
import { useHasPaidPlan } from "@calcom/features/billing/hooks/useHasPaidPlan";
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import SkeletonLoaderTeamList from "@calcom/features/ee/teams/components/SkeletonloaderTeamList";
|
||||
import { CreateButtonWithTeamsList } from "@calcom/features/ee/teams/components/createButton/CreateButtonWithTeamsList";
|
||||
import { FilterResults } from "@calcom/features/filters/components/FilterResults";
|
||||
import { TeamsFilter } from "@calcom/features/filters/components/TeamsFilter";
|
||||
import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
|
||||
import { ShellMain } from "@calcom/features/shell/Shell";
|
||||
import { UpgradeTip } from "@calcom/features/tips";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
|
||||
@@ -39,6 +34,12 @@ import {
|
||||
FormActionsProvider,
|
||||
} from "@calcom/web/components/apps/routing-forms/FormActions";
|
||||
|
||||
import { useHasPaidPlan } from "~/billing/hooks/useHasPaidPlan";
|
||||
import SkeletonLoaderTeamList from "~/ee/teams/components/SkeletonloaderTeamList";
|
||||
import { CreateButtonWithTeamsList } from "~/ee/teams/components/createButton/CreateButtonWithTeamsList";
|
||||
import { ShellMain } from "~/shell/Shell";
|
||||
import { UpgradeTip } from "~/shell/UpgradeTip";
|
||||
|
||||
function NewFormButton({ setNewFormDialogState }: { setNewFormDialogState: SetNewFormDialogState }) {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
|
||||
@@ -3,10 +3,11 @@ import { redirect } from "next/navigation";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
import FormProvider from "../[...pages]/FormProvider";
|
||||
|
||||
export default async function Layout({ children }: { children: ReactNode }) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { SkeletonText, SkeletonContainer, SkeletonButton } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export function AvailabilityScheduleSkeleton() {
|
||||
return (
|
||||
<Shell withoutMain={true}>
|
||||
@@ -106,7 +107,7 @@ export function AvailabilityScheduleSkeleton() {
|
||||
</div>
|
||||
|
||||
{/* Sidebar - only visible on desktop */}
|
||||
<div className="min-w-40 col-span-3 hidden stack-y-2 md:block lg:col-span-1 xl:w-[25%]">
|
||||
<div className="min-w-40 stack-y-2 col-span-3 hidden md:block lg:col-span-1 xl:w-[25%]">
|
||||
<div className="xl:max-w-80 w-full pr-4 sm:ml-0 sm:mr-36 sm:p-0">
|
||||
<div>
|
||||
<SkeletonText className="mb-1 h-4 w-24 text-sm" /> {/* Timezone */}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default function Error() {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import {
|
||||
SkeletonButton,
|
||||
SkeletonContainer,
|
||||
@@ -8,6 +7,8 @@ import {
|
||||
SkeletonAvatar,
|
||||
} from "@calcom/ui/components/skeleton";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export const EventTypeEditPageSkeleton = () => {
|
||||
const backButtonSkeleton = (
|
||||
<div className="bg-default sticky top-0 z-10 mb-0 flex items-center py-2 md:mb-9 md:mt-0">
|
||||
@@ -33,7 +34,7 @@ export const EventTypeEditPageSkeleton = () => {
|
||||
<div className="flex flex-col xl:flex-row xl:space-x-6">
|
||||
<div className="hidden xl:block">
|
||||
<div className="primary-navigation w-64 shrink-0">
|
||||
<div className="flex flex-col stack-y-1">
|
||||
<div className="stack-y-1 flex flex-col">
|
||||
{/* Tab navigation items */}
|
||||
{Array.from({ length: 8 }).map((_, index) => (
|
||||
<div
|
||||
@@ -58,14 +59,14 @@ export const EventTypeEditPageSkeleton = () => {
|
||||
<SkeletonText className="h-8 w-full max-w-md" />
|
||||
</div>
|
||||
|
||||
<div className="mb-6 stack-y-6">
|
||||
<div className="stack-y-6 mb-6">
|
||||
{/* Form fields */}
|
||||
<div className="flex flex-col stack-y-2">
|
||||
<div className="stack-y-2 flex flex-col">
|
||||
<SkeletonText className="h-4 w-32" />
|
||||
<SkeletonText className="h-10 w-full" />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col stack-y-2">
|
||||
<div className="stack-y-2 flex flex-col">
|
||||
<SkeletonText className="h-4 w-40" />
|
||||
<div className="flex items-center">
|
||||
<SkeletonText className="h-10 w-full" />
|
||||
@@ -73,12 +74,12 @@ export const EventTypeEditPageSkeleton = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col stack-y-2">
|
||||
<div className="stack-y-2 flex flex-col">
|
||||
<SkeletonText className="h-4 w-36" />
|
||||
<SkeletonText className="h-24 w-full" />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col stack-y-2">
|
||||
<div className="stack-y-2 flex flex-col">
|
||||
<SkeletonText className="h-4 w-28" />
|
||||
<div className="flex items-center">
|
||||
<SkeletonText className="h-10 w-full" />
|
||||
@@ -86,7 +87,7 @@ export const EventTypeEditPageSkeleton = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col stack-y-2">
|
||||
<div className="stack-y-2 flex flex-col">
|
||||
<SkeletonText className="h-4 w-32" />
|
||||
<SkeletonText className="h-10 w-full" />
|
||||
</div>
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
|
||||
import { UpgradeTip } from "@calcom/features/tips";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
|
||||
import { UpgradeTip } from "~/shell/UpgradeTip";
|
||||
|
||||
export default function UpgradeTipWrapper({ children }: { children: React.ReactNode }) {
|
||||
const { t } = useLocale();
|
||||
const session = useSession();
|
||||
|
||||
@@ -2,7 +2,8 @@ import { ShellMainAppDir } from "app/(use-page-wrapper)/(main-nav)/ShellMainAppD
|
||||
import { getTranslate } from "app/_utils";
|
||||
|
||||
import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
import UpgradeTipWrapper from "./UpgradeTipWrapper";
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getTranslate } from "app/_utils";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
import { DubReferralsPage } from "./DubReferralsPage";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
|
||||
@@ -4,10 +4,11 @@ import { usePathname } from "next/navigation";
|
||||
import type { ComponentProps } from "react";
|
||||
import React from "react";
|
||||
|
||||
import type Shell from "@calcom/features/shell/Shell";
|
||||
import type { UserPermissionRole } from "@calcom/prisma/enums";
|
||||
import { ErrorBoundary } from "@calcom/ui/components/errorBoundary";
|
||||
|
||||
import type Shell from "~/shell/Shell";
|
||||
|
||||
export type AdminLayoutProps = {
|
||||
children: React.ReactNode;
|
||||
userRole: UserPermissionRole | "INACTIVE_ADMIN" | undefined;
|
||||
@@ -18,7 +19,7 @@ export default function AdminLayoutAppDirClient({ children }: AdminLayoutProps)
|
||||
const isAppsPage = pathname?.startsWith("/settings/admin/apps");
|
||||
return (
|
||||
<div className="divide-subtle bg-default mx-auto flex max-w-4xl flex-row divide-y">
|
||||
<div className={isAppsPage ? "min-w-0" : "flex flex-1 *:flex-1"}>
|
||||
<div className={isAppsPage ? "min-w-0" : "*:flex-1 flex flex-1"}>
|
||||
<ErrorBoundary>{children}</ErrorBoundary>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
import { z } from "zod";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { OrgForm } from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgEditPage";
|
||||
import { OrgForm } from "~/ee/organizations/admin/AdminOrgEditPage";
|
||||
import { getOrganizationRepository } from "@calcom/features/ee/organizations/di/OrganizationRepository.container";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { _generateMetadata } from "app/_utils";
|
||||
import { getTranslate } from "app/_utils";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import AdminOrgTable from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgPage";
|
||||
import AdminOrgTable from "~/ee/organizations/admin/AdminOrgPage";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import WorkspacePlatformsPage from "@calcom/features/ee/organizations/pages/settings/admin/WorkspacePlatformPage";
|
||||
import WorkspacePlatformsPage from "~/ee/organizations/admin/WorkspacePlatformPage";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
|
||||
+2
-1
@@ -13,7 +13,6 @@ import { useOrgBranding } from "@calcom/features/ee/organizations/context/provid
|
||||
import type { OrganizationBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import type { TeamFeatures } from "@calcom/features/flags/config";
|
||||
import { useIsFeatureEnabledForTeam } from "@calcom/features/flags/hooks/useIsFeatureEnabledForTeam";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { HOSTED_CAL_FEATURES, IS_CALCOM, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
@@ -30,6 +29,8 @@ import type { VerticalTabItemProps } from "@calcom/ui/components/navigation";
|
||||
import { VerticalTabItem } from "@calcom/ui/components/navigation";
|
||||
import { Skeleton } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
const getTabs = (orgBranding: OrganizationBranding | null) => {
|
||||
const tabs: VerticalTabItemProps[] = [
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SkeletonLoader } from "@calcom/features/webhooks/pages/webhooks-skeleton";
|
||||
import { SkeletonLoader } from "~/webhooks/views/webhooks-skeleton";
|
||||
|
||||
export default function Loading() {
|
||||
return <SkeletonLoader />;
|
||||
|
||||
+2
-1
@@ -4,12 +4,13 @@ import { cookies, headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import WebhooksView from "@calcom/features/webhooks/pages/webhooks-view";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { webhookRouter } from "@calcom/trpc/server/routers/viewer/webhook/_router";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
import WebhooksView from "~/webhooks/views/webhooks-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
(t) => t("webhooks"),
|
||||
|
||||
+2
-1
@@ -2,9 +2,10 @@ import type { PageProps } from "app/_types";
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import { WebhookRepository } from "@calcom/features/webhooks/lib/repository/WebhookRepository";
|
||||
import { EditWebhookView } from "@calcom/features/webhooks/pages/webhook-edit-view";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
|
||||
import { EditWebhookView } from "~/webhooks/views/webhook-edit-view";
|
||||
|
||||
export const generateMetadata = async ({ params }: { params: Promise<{ id: string }> }) =>
|
||||
await _generateMetadata(
|
||||
(t) => t("webhooks"),
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SkeletonLoader } from "@calcom/features/webhooks/pages/webhook-new-skeleton";
|
||||
import { SkeletonLoader } from "~/webhooks/views/webhook-new-skeleton";
|
||||
|
||||
export default function Loading() {
|
||||
return <SkeletonLoader />;
|
||||
|
||||
+2
-1
@@ -1,11 +1,12 @@
|
||||
import { createRouterCaller } from "app/_trpc/context";
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import { NewWebhookView } from "@calcom/features/webhooks/pages/webhook-new-view";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { appsRouter } from "@calcom/trpc/server/routers/viewer/apps/_router";
|
||||
import { webhookRouter } from "@calcom/trpc/server/routers/viewer/webhook/_router";
|
||||
|
||||
import { NewWebhookView } from "~/webhooks/views/webhook-new-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
(t) => t("webhooks"),
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import OrgAttributesEditPage from "@calcom/ee/organizations/pages/settings/attributes/attributes-edit-view";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import OrgAttributesEditPage from "@calcom/web/modules/ee/organizations/attributes/attributes-edit-view";
|
||||
|
||||
import { validateUserHasOrgPerms } from "../../../../actions/validateUserHasOrgPerms";
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import OrgAttributesCreatePage from "@calcom/ee/organizations/pages/settings/attributes/attributes-create-view";
|
||||
import OrgAttributesCreatePage from "@calcom/web/modules/ee/organizations/attributes/attributes-create-view";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
import { validateUserHasOrgPerms } from "../../../actions/validateUserHasOrgPerms";
|
||||
|
||||
+2
-1
@@ -1,12 +1,13 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import OrgSettingsAttributesPage from "@calcom/ee/organizations/pages/settings/attributes/attributes-list-view";
|
||||
import { Resource } from "@calcom/features/pbac/domain/types/permission-registry";
|
||||
import { getResourcePermissions } from "@calcom/features/pbac/lib/resource-permissions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
import OrgSettingsAttributesPage from "~/ee/organizations/attributes/attributes-list-view";
|
||||
|
||||
import { validateUserHasOrg } from "../../actions/validateUserHasOrg";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import DelegationCredentialList from "@calcom/features/ee/organizations/pages/settings/delegationCredential";
|
||||
import DelegationCredentialList from "~/ee/organizations/delegationCredential";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import GuestNotificationsView from "@calcom/features/ee/organizations/pages/settings/guest-notifications";
|
||||
import GuestNotificationsView from "~/ee/organizations/guest-notifications";
|
||||
import { Resource } from "@calcom/features/pbac/domain/types/permission-registry";
|
||||
import { getResourcePermissions } from "@calcom/features/pbac/lib/resource-permissions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import PrivacyView from "@calcom/features/ee/organizations/pages/settings/privacy";
|
||||
import PrivacyView from "~/ee/organizations/privacy";
|
||||
import { Resource } from "@calcom/features/pbac/domain/types/permission-registry";
|
||||
import { getResourcePermissions } from "@calcom/features/pbac/lib/resource-permissions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
import { getTranslate, _generateMetadata } from "app/_utils";
|
||||
|
||||
import { AdminAPIView } from "@calcom/features/ee/organizations/pages/settings/admin-api";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import { AdminAPIView } from "~/ee/organizations/admin-api";
|
||||
|
||||
import { validateUserHasOrg } from "../actions/validateUserHasOrg";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LegacyPage from "@calcom/features/ee/organizations/pages/settings/general";
|
||||
import LegacyPage from "~/ee/organizations/general";
|
||||
import { Resource } from "@calcom/features/pbac/domain/types/permission-registry";
|
||||
import { getResourcePermissions } from "@calcom/features/pbac/lib/resource-permissions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import LegacyPage from "@calcom/features/ee/organizations/pages/settings/profile";
|
||||
import LegacyPage from "~/ee/organizations/profile";
|
||||
import { Resource } from "@calcom/features/pbac/domain/types/permission-registry";
|
||||
import { getResourcePermissions } from "@calcom/features/pbac/lib/resource-permissions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import SkeletonLoaderTeamList from "@calcom/features/ee/teams/components/SkeletonloaderTeamList";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import SkeletonLoaderTeamList from "~/ee/teams/components/SkeletonloaderTeamList";
|
||||
|
||||
export function SkeletonLoader() {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LegacyPage from "@calcom/features/ee/teams/pages/team-appearance-view";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import LegacyPage from "~/ee/teams/views/team-appearance-view";
|
||||
|
||||
import { validateUserHasOrg } from "../../../../actions/validateUserHasOrg";
|
||||
|
||||
export const generateMetadata = async ({ params }: { params: Promise<{ id: string }> }) =>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LegacyPage, {
|
||||
TeamMembersCTA,
|
||||
} from "@calcom/features/ee/organizations/pages/settings/other-team-members-view";
|
||||
} from "~/ee/organizations/other-team-members-view";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import { validateUserHasOrg } from "../../../../actions/validateUserHasOrg";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LegacyPage from "@calcom/features/ee/organizations/pages/settings/other-team-profile-view";
|
||||
import LegacyPage from "~/ee/organizations/other-team-profile-view";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import { validateUserHasOrg } from "../../../../actions/validateUserHasOrg";
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LegacyPage from "@calcom/features/ee/teams/pages/team-appearance-view";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import LegacyPage from "~/ee/teams/views/team-appearance-view";
|
||||
|
||||
export const generateMetadata = async ({ params }: { params: Promise<{ id: string }> }) =>
|
||||
await _generateMetadata(
|
||||
(t) => t("booking_appearance"),
|
||||
|
||||
+1
-2
@@ -11,11 +11,10 @@ import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { PrismaAttributeRepository } from "@calcom/lib/server/repository/PrismaAttributeRepository";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { viewerTeamsRouter } from "@calcom/trpc/server/routers/viewer/teams/_router";
|
||||
import { TeamMembersView } from "@calcom/web/modules/ee/teams/views/team-members-view";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
import { TeamMembersView } from "~/teams/team-members-view";
|
||||
|
||||
export const generateMetadata = async ({ params }: { params: Promise<{ id: string }> }) =>
|
||||
await _generateMetadata(
|
||||
(t) => t("team_members"),
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import LegacyPage from "@calcom/features/ee/teams/pages/team-profile-view";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import LegacyPage from "@calcom/web/modules/ee/teams/views/team-profile-view";
|
||||
|
||||
export const generateMetadata = async ({ params }: { params: Promise<{ id: string }> }) =>
|
||||
await _generateMetadata(
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { _generateMetadata, getTranslate } from "app/_utils";
|
||||
|
||||
import TeamSettingsView from "@calcom/features/ee/teams/pages/team-settings-view";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import TeamSettingsView from "@calcom/web/modules/ee/teams/views/team-settings-view";
|
||||
|
||||
export const generateMetadata = async ({ params }: { params: Promise<{ id: string }> }) =>
|
||||
await _generateMetadata(
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import Page from "@calcom/features/ee/organizations/pages/settings/appearance";
|
||||
import Page from "~/ee/organizations/appearance";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
import { getTranslate } from "app/_utils";
|
||||
|
||||
import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default async function Layout({ children }: { children: React.ReactNode }) {
|
||||
const t = await getTranslate();
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { UserListTableSkeleton } from "@calcom/features/users/components/UserTable/UserListTableSkeleton";
|
||||
import { UserListTableSkeleton } from "@calcom/web/modules/users/components/UserTable/UserListTableSkeleton";
|
||||
|
||||
export default function Loading() {
|
||||
return <UserListTableSkeleton />;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { UserListTableSkeleton } from "@calcom/features/users/components/UserTable/UserListTableSkeleton";
|
||||
import { UserListTableSkeleton } from "@calcom/web/modules/users/components/UserTable/UserListTableSkeleton";
|
||||
|
||||
export default function Loading() {
|
||||
return <UserListTableSkeleton />;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/about-view";
|
||||
import LegacyPage, { LayoutWrapper } from "~/ee/organizations/new/about-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/add-teams-view";
|
||||
import LegacyPage, { LayoutWrapper } from "~/ee/organizations/new/add-teams-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/onboarding-handover";
|
||||
import LegacyPage, { LayoutWrapper } from "~/ee/organizations/new/onboarding-handover";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/onboard-members-view";
|
||||
import LegacyPage, { LayoutWrapper } from "~/ee/organizations/new/onboard-members-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
|
||||
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/create-new-view";
|
||||
import LegacyPage, { LayoutWrapper } from "~/ee/organizations/new/create-new-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import ResumeOnboardingPage, { LayoutWrapper } from "~/settings/organizations/new/resume-view";
|
||||
import ResumeOnboardingPage, { LayoutWrapper } from "~/ee/organizations/new/resume-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { _generateMetadata } from "app/_utils";
|
||||
|
||||
import LegacyPage, { LayoutWrapper } from "~/settings/organizations/new/payment-status-view";
|
||||
import LegacyPage, { LayoutWrapper } from "~/ee/organizations/new/payment-status-view";
|
||||
|
||||
export const generateMetadata = async () =>
|
||||
await _generateMetadata(
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getTranslate } from "app/_utils";
|
||||
|
||||
import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default async function Layout({ children }: { children: React.ReactNode }) {
|
||||
const t = await getTranslate();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserListTableSkeleton } from "@calcom/features/users/components/UserTable/UserListTableSkeleton";
|
||||
import { UserListTableSkeleton } from "@calcom/web/modules/users/components/UserTable/UserListTableSkeleton";
|
||||
|
||||
export default function Loading() {
|
||||
return <UserListTableSkeleton />;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { z } from "zod";
|
||||
// import { cookies, headers } from "next/headers";
|
||||
// import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
// import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
import LegacyPage from "@calcom/features/ee/workflows/pages/workflow";
|
||||
import LegacyPage from "@calcom/web/modules/ee/workflows/views/WorkflowPage";
|
||||
|
||||
const querySchema = z.object({
|
||||
workflow: z
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
// import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
|
||||
// import { WorkflowRepository } from "@calcom/features/ee/workflows/repositories/WorkflowRepository";
|
||||
import LegacyPage from "@calcom/features/ee/workflows/pages/index";
|
||||
import LegacyPage from "@calcom/web/modules/ee/workflows/views/WorkflowsPage";
|
||||
|
||||
const Page = async () => {
|
||||
// const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
|
||||
|
||||
@@ -4,14 +4,14 @@ import { NextResponse } from "next/server";
|
||||
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
import { BillingPlanService } from "@calcom/features/ee/billing/domain/billing-plans";
|
||||
import type { Contact } from "@calcom/features/ee/support/lib/intercom/intercom";
|
||||
import { intercom } from "@calcom/features/ee/support/lib/intercom/intercom";
|
||||
import { MembershipRepository } from "@calcom/features/membership/repositories/MembershipRepository";
|
||||
import { UserRepository } from "@calcom/features/users/repositories/UserRepository";
|
||||
import { WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import type { Contact } from "@calcom/web/modules/ee/support/lib/intercom/intercom";
|
||||
import { intercom } from "@calcom/web/modules/ee/support/lib/intercom/intercom";
|
||||
|
||||
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { UpgradeTip } from "@calcom/features/tips";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
import { UpgradeTip } from "~/shell/UpgradeTip";
|
||||
|
||||
export default function EnterprisePage() {
|
||||
const { t } = useLocale();
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
import type { AppPageProps } from "./AppPage";
|
||||
import { AppPage } from "./AppPage";
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@ import { useMemo } from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import type { UseFormGetValues, UseFormSetValue, Control, FormState } from "react-hook-form";
|
||||
|
||||
import type {
|
||||
TLocationOptions,
|
||||
TEventTypeLocation,
|
||||
} from "@calcom/features/eventtypes/components/locations/Locations";
|
||||
import Locations from "@calcom/features/eventtypes/components/locations/Locations";
|
||||
import type { LocationFormValues } from "@calcom/features/eventtypes/lib/types";
|
||||
import type { SingleValueLocationOption } from "@calcom/features/form/components/LocationSelect";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -20,6 +15,8 @@ import { QueryCell } from "@lib/QueryCell";
|
||||
import type { TFormType } from "@components/apps/installation/ConfigureStepCard";
|
||||
|
||||
import type { TEventType } from "~/apps/installation/[[...step]]/step-view";
|
||||
import Locations from "~/event-types/components/locations/Locations";
|
||||
import type { TLocationOptions, TEventTypeLocation } from "~/event-types/components/locations/Locations";
|
||||
|
||||
const LocationsWrapper = ({
|
||||
eventType,
|
||||
|
||||
@@ -2,10 +2,11 @@ import { useRouter } from "next/navigation";
|
||||
import type { ComponentProps } from "react";
|
||||
import React from "react";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
type AppsLayoutProps = {
|
||||
children: React.ReactNode;
|
||||
isAdmin: boolean;
|
||||
|
||||
@@ -2,7 +2,8 @@ import type { ComponentProps } from "react";
|
||||
import React from "react";
|
||||
|
||||
import AppCategoryNavigation from "@calcom/app-store/_components/AppCategoryNavigation";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default function InstalledAppsLayout({
|
||||
children,
|
||||
|
||||
@@ -60,7 +60,7 @@ function mockEventTypeRedirectUrlMatchingRoute() {
|
||||
/**
|
||||
* fixes the error due to Formbricks
|
||||
*/
|
||||
vi.mock("@calcom/features/shell/Shell", () => ({
|
||||
vi.mock("@calcom/web/modules/shell/Shell", () => ({
|
||||
ShellMain: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ beforeAll(() => {
|
||||
Element.prototype.scrollIntoView = vi.fn();
|
||||
});
|
||||
|
||||
vi.mock("@calcom/trpc", () => ({
|
||||
vi.mock("@calcom/trpc/react", () => ({
|
||||
trpc: {
|
||||
viewer: {
|
||||
bookings: {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { MeetingSessionDetailsDialog } from "@calcom/features/ee/video/MeetingSessionDetailsDialog";
|
||||
import ViewRecordingsDialog from "@calcom/features/ee/video/ViewRecordingsDialog";
|
||||
import ViewRecordingsDialog from "~/ee/video/ViewRecordingsDialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
@@ -10,10 +10,10 @@ import { NuqsAdapter } from "nuqs/adapters/next/app";
|
||||
import DynamicPostHogProvider from "@calcom/features/ee/event-tracking/lib/posthog/providerDynamic";
|
||||
import DynamicPostHogPageView from "@calcom/features/ee/event-tracking/lib/posthog/web/pageViewDynamic";
|
||||
import { OrgBrandingProvider } from "@calcom/features/ee/organizations/context/provider";
|
||||
import DynamicHelpscoutProvider from "@calcom/features/ee/support/lib/helpscout/providerDynamic";
|
||||
import DynamicIntercomProvider from "@calcom/features/ee/support/lib/intercom/providerDynamic";
|
||||
import { FeatureProvider } from "@calcom/features/flags/context/provider";
|
||||
import { useFlags } from "@calcom/features/flags/hooks";
|
||||
import DynamicHelpscoutProvider from "@calcom/web/modules/ee/support/lib/helpscout/providerDynamic";
|
||||
import DynamicIntercomProvider from "@calcom/web/modules/ee/support/lib/intercom/providerDynamic";
|
||||
|
||||
import useIsBookingPage from "@lib/hooks/useIsBookingPage";
|
||||
import useIsThemeSupported from "@lib/hooks/useIsThemeSupported";
|
||||
|
||||
@@ -20,10 +20,10 @@ import type { PropsWithChildren, ReactNode } from "react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { OrgBrandingProvider } from "@calcom/features/ee/organizations/context/provider";
|
||||
import DynamicHelpscoutProvider from "@calcom/features/ee/support/lib/helpscout/providerDynamic";
|
||||
import DynamicIntercomProvider from "@calcom/features/ee/support/lib/intercom/providerDynamic";
|
||||
import { FeatureProvider } from "@calcom/features/flags/context/provider";
|
||||
import { useFlags } from "@calcom/features/flags/hooks";
|
||||
import DynamicHelpscoutProvider from "@calcom/web/modules/ee/support/lib/helpscout/providerDynamic";
|
||||
import DynamicIntercomProvider from "@calcom/web/modules/ee/support/lib/intercom/providerDynamic";
|
||||
|
||||
import useIsBookingPage from "@lib/hooks/useIsBookingPage";
|
||||
import { useNuqsParams } from "@lib/hooks/useNuqsParams";
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { AppCard } from "@calcom/features/apps/components/AppCard";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import type { CategoryDataProps } from "@lib/apps/categories/[category]/getStaticProps";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default function Apps({ apps, category }: CategoryDataProps) {
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
@@ -10,6 +9,8 @@ import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import type { getServerSideProps } from "@lib/apps/categories/getServerSideProps";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
|
||||
export default function Apps({ categories }: PageProps) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { UpgradeTeamsBadge as UpgradeTeamsBadgeBase } from "@calcom/ui/components/badge";
|
||||
import { useHasPaidPlan, useHasActiveTeamPlan } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
|
||||
|
||||
export function UpgradeTeamsBadgeWebWrapper({ checkForActiveStatus }: { checkForActiveStatus?: boolean }) {
|
||||
const { hasPaidPlan } = useHasPaidPlan();
|
||||
const { hasActiveTeamPlan, isTrial } = useHasActiveTeamPlan();
|
||||
|
||||
return (
|
||||
<UpgradeTeamsBadgeBase
|
||||
checkForActiveStatus={checkForActiveStatus}
|
||||
hasPaidPlan={hasPaidPlan}
|
||||
hasActiveTeamPlan={hasActiveTeamPlan}
|
||||
isTrial={isTrial}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { IS_SELF_HOSTED } from "@calcom/lib/constants";
|
||||
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
export function useHasPaidPlan() {
|
||||
if (IS_SELF_HOSTED) return { isPending: false, hasPaidPlan: true };
|
||||
|
||||
const { data, isPending: isPendingTeamQuery } = trpc.viewer.teams.hasTeamPlan.useQuery();
|
||||
|
||||
const { data: user, isPending: isPendingUserQuery } = trpc.viewer.me.get.useQuery();
|
||||
|
||||
const isPending = isPendingTeamQuery || isPendingUserQuery;
|
||||
|
||||
const isCurrentUsernamePremium =
|
||||
user && hasKeyInMetadata(user, "isPremium") ? !!user.metadata.isPremium : false;
|
||||
|
||||
const hasPaidPlan = data?.hasTeamPlan || isCurrentUsernamePremium;
|
||||
|
||||
return { isPending, hasPaidPlan, plan: data?.plan };
|
||||
}
|
||||
|
||||
export function useTeamInvites() {
|
||||
const listInvites = trpc.viewer.teams.listInvites.useQuery();
|
||||
|
||||
return { isPending: listInvites.isPending, listInvites: listInvites.data };
|
||||
}
|
||||
|
||||
export function useHasTeamPlan() {
|
||||
const { data: hasTeamPlan, isPending } = trpc.viewer.teams.hasTeamPlan.useQuery();
|
||||
|
||||
return { isPending, hasTeamPlan: hasTeamPlan?.hasTeamPlan };
|
||||
}
|
||||
|
||||
export function useHasEnterprisePlan() {
|
||||
// TODO: figure out how to get "has Enterprise / has Org" from the backend
|
||||
const { data: hasTeamPlan, isPending } = trpc.viewer.teams.hasTeamPlan.useQuery();
|
||||
|
||||
return { isPending, hasTeamPlan: hasTeamPlan?.hasTeamPlan };
|
||||
}
|
||||
|
||||
export function useHasActiveTeamPlan() {
|
||||
if (IS_SELF_HOSTED) return { isPending: false, hasActiveTeamPlan: true, isTrial: false };
|
||||
|
||||
const { data, isPending } = trpc.viewer.teams.hasActiveTeamPlan.useQuery();
|
||||
|
||||
return { isPending, hasActiveTeamPlan: !!data?.isActive, isTrial: !!data?.isTrial };
|
||||
}
|
||||
export function useHasActiveTeamPlanAsOwner() {
|
||||
if (IS_SELF_HOSTED) return { isPending: false, hasActiveTeamPlan: true, isTrial: false };
|
||||
|
||||
const { data, isPending } = trpc.viewer.teams.hasActiveTeamPlan.useQuery({ ownerOnly: true });
|
||||
|
||||
return { isPending, hasActiveTeamPlan: !!data?.isActive, isTrial: !!data?.isTrial };
|
||||
}
|
||||
|
||||
export default useHasPaidPlan;
|
||||
@@ -6,8 +6,8 @@ import dayjs from "@calcom/dayjs";
|
||||
import { useTimePreferences } from "@calcom/features/bookings/lib";
|
||||
import { Calendar } from "@calcom/features/calendars/weeklyview";
|
||||
import type { CalendarEvent } from "@calcom/features/calendars/weeklyview/types/events";
|
||||
import { useBanners } from "@calcom/features/shell/banners/useBanners";
|
||||
import { useGetTheme } from "@calcom/lib/hooks/useTheme";
|
||||
import { useBanners } from "@calcom/web/modules/shell/banners/useBanners";
|
||||
|
||||
import { useBookingDetailsSheetStore } from "../store/bookingDetailsSheetStore";
|
||||
import type { BookingOutput } from "../types";
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
|
||||
export default function UnconfirmedBookingBadge() {
|
||||
const { t } = useLocale();
|
||||
const { data: unconfirmedBookingCount } = trpc.viewer.me.bookingUnconfirmedCount.useQuery();
|
||||
if (!unconfirmedBookingCount) return null;
|
||||
return (
|
||||
<Link href="/bookings/unconfirmed">
|
||||
<Badge
|
||||
rounded
|
||||
title={t("unconfirmed_bookings_tooltip")}
|
||||
variant="orange"
|
||||
className="cursor-pointer hover:bg-orange-800 hover:text-orange-100">
|
||||
{unconfirmedBookingCount}
|
||||
</Badge>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
The Cal.com Commercial License (the “Commercial License”)
|
||||
Copyright (c) 2020-present Cal.com, Inc
|
||||
|
||||
With regard to the Cal.com Software:
|
||||
|
||||
This software and associated documentation files (the "Software") may only be
|
||||
used in production, if you (and any entity that you represent) have agreed to,
|
||||
and are in compliance with, the Cal.com Subscription Terms available
|
||||
at https://cal.com/terms, or other agreements governing
|
||||
the use of the Software, as mutually agreed by you and Cal.com, Inc ("Cal.com"),
|
||||
and otherwise have a valid Cal.com Enterprise Edition subscription ("Commercial Subscription")
|
||||
for the correct number of hosts as defined in the "Commercial Terms ("Hosts"). Subject to the foregoing sentence,
|
||||
you are free to modify this Software and publish patches to the Software. You agree
|
||||
that Cal.com and/or its licensors (as applicable) retain all right, title and interest in
|
||||
and to all such modifications and/or patches, and all such modifications and/or
|
||||
patches may only be used, copied, modified, displayed, distributed, or otherwise
|
||||
exploited with a valid Commercial Subscription for the correct number of hosts.
|
||||
Notwithstanding the foregoing, you may copy and modify the Software for development
|
||||
and testing purposes, without requiring a subscription. You agree that Cal.com and/or
|
||||
its licensors (as applicable) retain all right, title and interest in and to all such
|
||||
modifications. You are not granted any other rights beyond what is expressly stated herein.
|
||||
Subject to the foregoing, it is forbidden to copy, merge, publish, distribute, sublicense,
|
||||
and/or sell the Software.
|
||||
|
||||
This Commercial License applies only to the part of this Software that is not distributed under
|
||||
the AGPLv3 license. Any part of this Software distributed under the MIT license or which
|
||||
is served client-side as an image, font, cascading stylesheet (CSS), file which produces
|
||||
or is compiled, arranged, augmented, or combined into client-side JavaScript, in whole or
|
||||
in part, is copyrighted under the AGPLv3 license. The full text of this Commercial License shall
|
||||
be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
For all third party components incorporated into the Cal.com Software, those
|
||||
components are licensed under the original license provided by the owner of the
|
||||
applicable component.
|
||||
@@ -0,0 +1,59 @@
|
||||
"use client";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
|
||||
import { UpgradeTip } from "~/shell/UpgradeTip";
|
||||
|
||||
export const AdminAPIView = () => {
|
||||
const { t } = useLocale();
|
||||
|
||||
const features = [
|
||||
{
|
||||
icon: <Icon name="terminal" className="h-5 w-5 text-pink-500" />,
|
||||
title: t("admin_api"),
|
||||
description: t("leverage_our_api"),
|
||||
},
|
||||
{
|
||||
icon: <Icon name="folder" className="h-5 w-5 text-red-500" />,
|
||||
title: `SCIM & ${t("directory_sync")}`,
|
||||
description: t("directory_sync_description"),
|
||||
},
|
||||
{
|
||||
icon: <Icon name="sparkles" className="h-5 w-5 text-blue-500" />,
|
||||
title: "Cal.ai",
|
||||
description: t("use_cal_ai_to_make_call_description"),
|
||||
},
|
||||
];
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<div className="mt-8">
|
||||
<UpgradeTip
|
||||
plan="enterprise"
|
||||
title={t("enterprise_license")}
|
||||
description={t("create_your_enterprise_description")}
|
||||
features={features}
|
||||
background="/tips/enterprise"
|
||||
buttons={
|
||||
<div className="stack-y-2 rtl:space-x-reverse sm:space-x-2">
|
||||
<ButtonGroup>
|
||||
<Button color="primary" href="https://cal.com/sales" target="_blank">
|
||||
{t("contact_sales")}
|
||||
</Button>
|
||||
<Button color="minimal" href="https://cal.com/enterprise" target="_blank">
|
||||
{t("learn_more")}
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
}>
|
||||
<>Create Org</>
|
||||
</UpgradeTip>
|
||||
</div>
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminAPIView;
|
||||
@@ -0,0 +1,84 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { Team } from "@calcom/prisma/client";
|
||||
import type { orgSettingsSchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
type FormValues = {
|
||||
name: Team["name"];
|
||||
slug: Team["slug"];
|
||||
organizationSettings: z.infer<typeof orgSettingsSchema>;
|
||||
};
|
||||
|
||||
export const OrgForm = ({
|
||||
org,
|
||||
}: {
|
||||
org: FormValues & {
|
||||
id: Team["id"];
|
||||
};
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const utils = trpc.useUtils();
|
||||
const mutation = trpc.viewer.organizations.adminUpdate.useMutation({
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
utils.viewer.organizations.adminGetAll.invalidate(),
|
||||
utils.viewer.organizations.adminGet.invalidate({
|
||||
id: org.id,
|
||||
}),
|
||||
]);
|
||||
showToast(t("org_has_been_processed"), "success");
|
||||
router.replace(`/settings/admin/organizations`);
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
defaultValues: org,
|
||||
});
|
||||
|
||||
const onSubmit = (values: FormValues) => {
|
||||
mutation.mutate({
|
||||
id: org.id,
|
||||
...values,
|
||||
organizationSettings: {
|
||||
...org.organizationSettings,
|
||||
orgAutoAcceptEmail: values.organizationSettings?.orgAutoAcceptEmail,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Form form={form} className="stack-y-4" handleSubmit={onSubmit}>
|
||||
<TextField label="Name" placeholder="example" required {...form.register("name")} />
|
||||
<TextField label="Slug" placeholder="example" required {...form.register("slug")} />
|
||||
<p className="text-default mt-2 text-sm">
|
||||
Changing the slug would delete the previous organization domain and DNS and setup new domain and DNS
|
||||
for the organization.
|
||||
</p>
|
||||
<TextField
|
||||
label="Domain for which invitations are auto-accepted"
|
||||
placeholder="abc.com"
|
||||
required
|
||||
{...form.register("organizationSettings.orgAutoAcceptEmail")}
|
||||
/>
|
||||
<Button type="submit" color="primary" loading={mutation.isPending}>
|
||||
{t("save")}
|
||||
</Button>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgForm;
|
||||
@@ -0,0 +1,273 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
|
||||
import { DropdownActions, Table } from "@calcom/ui/components/table";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
const { Body, Cell, ColumnTitle, Header, Row } = Table;
|
||||
|
||||
export function AdminOrgTable() {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
const [data] = trpc.viewer.organizations.adminGetAll.useSuspenseQuery();
|
||||
const updateMutation = trpc.viewer.organizations.adminUpdate.useMutation({
|
||||
onSuccess: async (_data, variables) => {
|
||||
showToast(t("org_has_been_processed"), "success");
|
||||
await invalidateQueries(utils, {
|
||||
orgId: variables.id,
|
||||
});
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const deleteMutation = trpc.viewer.organizations.adminDelete.useMutation({
|
||||
onSuccess: async (res, variables) => {
|
||||
showToast(res.message, "success");
|
||||
await invalidateQueries(utils, variables);
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error(err.message);
|
||||
showToast(t("org_error_processing"), "error");
|
||||
},
|
||||
});
|
||||
|
||||
const publishOrg = async (org: (typeof data)[number]) => {
|
||||
if (!org.metadata?.requestedSlug) {
|
||||
showToast(t("could_not_find_slug_to_publish_org"), "error");
|
||||
console.error("metadata.requestedSlug isn't set", org.metadata?.requestedSlug);
|
||||
return;
|
||||
}
|
||||
updateMutation.mutate({
|
||||
id: org.id,
|
||||
slug: org.metadata.requestedSlug,
|
||||
});
|
||||
};
|
||||
|
||||
const [orgToDelete, setOrgToDelete] = useState<(typeof data)[number] | null>(null);
|
||||
return (
|
||||
<div>
|
||||
<Table>
|
||||
<Header>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("organization")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("owner")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("reviewed")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("dns_configured")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("published")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("admin_api")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">
|
||||
<span className="sr-only">{t("edit")}</span>
|
||||
</ColumnTitle>
|
||||
</Header>
|
||||
<Body>
|
||||
{data.map((org) => (
|
||||
<Row key={org.id}>
|
||||
<Cell widthClassNames="w-auto">
|
||||
<div className="text-subtle font-medium">
|
||||
<span className="text-default">{org.name}</span>
|
||||
<br />
|
||||
<span className="text-muted">
|
||||
{org.slug}.{subdomainSuffix()}
|
||||
</span>
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell widthClassNames="w-auto">
|
||||
<span className="break-all">
|
||||
{org.members.length ? org.members[0].user.email : "No members"}
|
||||
</span>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="space-x-2">
|
||||
{!org.organizationSettings?.isAdminReviewed ? (
|
||||
<Badge variant="red">{t("unreviewed")}</Badge>
|
||||
) : (
|
||||
<Badge variant="green">{t("reviewed")}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="space-x-2">
|
||||
{org.organizationSettings?.isOrganizationConfigured ? (
|
||||
<Badge variant="blue">{t("dns_configured")}</Badge>
|
||||
) : (
|
||||
<Badge variant="red">{t("dns_missing")}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="space-x-2">
|
||||
{!org.slug ? (
|
||||
<Badge variant="red">{t("unpublished")}</Badge>
|
||||
) : (
|
||||
<Badge variant="green">{t("published")}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="space-x-2">
|
||||
{!org.organizationSettings?.isAdminAPIEnabled ? (
|
||||
<Badge variant="red">{t("disabled")}</Badge>
|
||||
) : (
|
||||
<Badge variant="green">{t("enabled")}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell widthClassNames="w-auto">
|
||||
<div className="flex w-full justify-end">
|
||||
<DropdownActions
|
||||
actions={[
|
||||
...(!org.organizationSettings?.isAdminReviewed
|
||||
? [
|
||||
{
|
||||
id: "review",
|
||||
label: t("review"),
|
||||
onClick: () => {
|
||||
updateMutation.mutate({
|
||||
id: org.id,
|
||||
organizationSettings: {
|
||||
isAdminReviewed: true,
|
||||
},
|
||||
});
|
||||
},
|
||||
icon: "check" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(!org.organizationSettings?.isOrganizationConfigured
|
||||
? [
|
||||
{
|
||||
id: "dns",
|
||||
label: t("mark_dns_configured"),
|
||||
onClick: () => {
|
||||
updateMutation.mutate({
|
||||
id: org.id,
|
||||
organizationSettings: {
|
||||
isOrganizationConfigured: true,
|
||||
},
|
||||
});
|
||||
},
|
||||
icon: "check-check" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: "edit",
|
||||
label: t("edit"),
|
||||
href: `/settings/admin/organizations/${org.id}/edit`,
|
||||
icon: "pencil" as const,
|
||||
},
|
||||
...(!org.slug
|
||||
? [
|
||||
{
|
||||
id: "publish",
|
||||
label: t("publish"),
|
||||
onClick: () => {
|
||||
publishOrg(org);
|
||||
},
|
||||
icon: "book-open-check" as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: "api",
|
||||
label: org.organizationSettings?.isAdminAPIEnabled
|
||||
? t("revoke_admin_api")
|
||||
: t("grant_admin_api"),
|
||||
onClick: () => {
|
||||
updateMutation.mutate({
|
||||
id: org.id,
|
||||
organizationSettings: {
|
||||
isAdminAPIEnabled: !org.organizationSettings?.isAdminAPIEnabled,
|
||||
},
|
||||
});
|
||||
},
|
||||
icon: "terminal" as const,
|
||||
},
|
||||
{
|
||||
id: "delete",
|
||||
label: t("delete"),
|
||||
onClick: () => {
|
||||
setOrgToDelete(org);
|
||||
},
|
||||
icon: "trash" as const,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</Cell>
|
||||
</Row>
|
||||
))}
|
||||
</Body>
|
||||
</Table>
|
||||
<DeleteOrgDialog
|
||||
org={orgToDelete}
|
||||
onClose={() => setOrgToDelete(null)}
|
||||
onConfirm={() => {
|
||||
if (!orgToDelete) return;
|
||||
deleteMutation.mutate({
|
||||
orgId: orgToDelete.id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AdminOrgTable;
|
||||
|
||||
const DeleteOrgDialog = ({
|
||||
org,
|
||||
onConfirm,
|
||||
onClose,
|
||||
}: {
|
||||
org: {
|
||||
id: number;
|
||||
name: string;
|
||||
} | null;
|
||||
onConfirm: () => void;
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
if (!org) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function -- noop
|
||||
<Dialog name="delete-user" open={!!org.id} onOpenChange={(open) => (open ? () => {} : onClose())}>
|
||||
<ConfirmationDialogContent
|
||||
title={t("admin_delete_organization_title", {
|
||||
organizationName: org.name,
|
||||
})}
|
||||
confirmBtnText={t("delete")}
|
||||
cancelBtnText={t("cancel")}
|
||||
variety="danger"
|
||||
onConfirm={onConfirm}>
|
||||
<ul className="stack-y-2 ml-4 mt-5 list-disc">
|
||||
<li>{t("admin_delete_organization_description_1")}</li>
|
||||
<li>{t("admin_delete_organization_description_2")}</li>
|
||||
<li>{t("admin_delete_organization_description_3")}</li>
|
||||
<li>{t("admin_delete_organization_description_4")}</li>
|
||||
</ul>
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
async function invalidateQueries(utils: ReturnType<typeof trpc.useUtils>, data: { orgId: number }) {
|
||||
await utils.viewer.organizations.adminGetAll.invalidate();
|
||||
await utils.viewer.organizations.adminGet.invalidate({
|
||||
id: data.orgId,
|
||||
});
|
||||
// Due to some super weird reason, just invalidate doesn't work, so do refetch as well.
|
||||
await utils.viewer.organizations.adminGet.refetch({
|
||||
id: data.orgId,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
"use client";
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useState } from "react";
|
||||
import type { SubmitHandler } from "react-hook-form";
|
||||
import { useForm, useFormContext } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { serviceAccountKeySchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc, type RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { DialogContent, DialogFooter, DialogClose } from "@calcom/ui/components/dialog";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { TextAreaField } from "@calcom/ui/components/form";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { Switch } from "@calcom/ui/components/form";
|
||||
import { DropdownActions, Table } from "@calcom/ui/components/table";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
const { Body, Cell, ColumnTitle, Header, Row } = Table;
|
||||
|
||||
type WorkspacePlatform = RouterOutputs["viewer"]["admin"]["workspacePlatform"]["list"][number];
|
||||
type EditType = "meta" | "serviceAccount";
|
||||
|
||||
type Props = {
|
||||
workspacePlatforms: WorkspacePlatform[];
|
||||
onAdd: () => void;
|
||||
onEdit: (platform: WorkspacePlatform, editType: EditType) => void;
|
||||
onToggle: (platform: WorkspacePlatform, checked: boolean) => void;
|
||||
isOpen: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
editingPlatform: WorkspacePlatform;
|
||||
isCreate: boolean;
|
||||
platform: WorkspacePlatform;
|
||||
platformId?: number;
|
||||
platforms: WorkspacePlatform[];
|
||||
};
|
||||
|
||||
const WorkspacePlatformsPage = () => {
|
||||
const { t } = useLocale();
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
|
||||
const [editing, setEditing] = useState<
|
||||
{ platform: WorkspacePlatform; editType: EditType } | { platform: null; editType: EditType }
|
||||
>({ platform: null, editType: "meta" });
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
const { data: workspacePlatforms, isPending, error } = trpc.viewer.admin.workspacePlatform.list.useQuery();
|
||||
const toggleEnabledMutation = trpc.viewer.admin.workspacePlatform.toggleEnabled.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("workspace_platform_updated_successfully"), "success");
|
||||
utils.viewer.admin.workspacePlatform.list.invalidate();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
showToast(t("something_went_wrong"), "error");
|
||||
},
|
||||
});
|
||||
|
||||
if (error) {
|
||||
return <ErrorState />;
|
||||
}
|
||||
|
||||
if (isPending || !workspacePlatforms) return <LoadingState />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageContent
|
||||
workspacePlatforms={workspacePlatforms}
|
||||
onAdd={handleAdd}
|
||||
onEdit={handleEdit}
|
||||
onToggle={handleToggle}
|
||||
/>
|
||||
{editing.editType === "meta" && (
|
||||
<CreateUpdatePlatformDialog
|
||||
isOpen={isDialogOpen}
|
||||
onOpenChange={setIsDialogOpen}
|
||||
editingPlatform={editing.platform || undefined}
|
||||
key={editing.platform?.id}
|
||||
/>
|
||||
)}
|
||||
{editing.editType === "serviceAccount" && (
|
||||
<UpdateServiceAccountFieldsDialog
|
||||
isOpen={isDialogOpen}
|
||||
onOpenChange={setIsDialogOpen}
|
||||
platformId={editing.platform?.id}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
function handleAdd() {
|
||||
setEditing({ platform: null, editType: "meta" });
|
||||
setIsDialogOpen(true);
|
||||
}
|
||||
|
||||
function handleEdit(platform: Props["platform"], editType: "meta" | "serviceAccount" = "meta") {
|
||||
setEditing({ platform, editType });
|
||||
setIsDialogOpen(true);
|
||||
}
|
||||
|
||||
function handleToggle(platform: Props["platform"], checked: boolean) {
|
||||
toggleEnabledMutation.mutate({ ...platform, enabled: checked });
|
||||
}
|
||||
};
|
||||
|
||||
function LoadingState() {
|
||||
const { t } = useLocale();
|
||||
return <div>{t("loading")}...</div>;
|
||||
}
|
||||
|
||||
function ErrorState() {
|
||||
const { t } = useLocale();
|
||||
return <div>{t("something_went_wrong")}</div>;
|
||||
}
|
||||
|
||||
function PageContent({
|
||||
workspacePlatforms,
|
||||
onAdd,
|
||||
onEdit,
|
||||
onToggle,
|
||||
}: Pick<Props, "workspacePlatforms" | "onAdd" | "onEdit" | "onToggle">) {
|
||||
return (
|
||||
<div>
|
||||
{workspacePlatforms.length === 0 ? (
|
||||
<EmptyState onAdd={onAdd} />
|
||||
) : (
|
||||
<PlatformList platforms={workspacePlatforms} onEdit={onEdit} onToggle={onToggle} onAdd={onAdd} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EmptyState({ onAdd }: Pick<Props, "onAdd">) {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<div className="stack-y-4 flex flex-col items-center justify-center py-10">
|
||||
<p className="text-gray-500">{t("no_workspace_platforms")}</p>
|
||||
<Button color="secondary" onClick={onAdd}>
|
||||
{t("add")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PlatformList({
|
||||
platforms,
|
||||
onEdit,
|
||||
onToggle,
|
||||
onAdd,
|
||||
}: Pick<Props, "platforms" | "onEdit" | "onToggle" | "onAdd">) {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Table>
|
||||
<Header>
|
||||
<ColumnTitle widthClassNames="w-1/4">{t("platform")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-1/4">{t("slug")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-1/4">{t("status")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-1/4">
|
||||
<span className="sr-only">{t("actions")}</span>
|
||||
</ColumnTitle>
|
||||
</Header>
|
||||
<Body>
|
||||
{platforms.map((platform) => (
|
||||
<PlatformListItem key={platform.id} platform={platform} onEdit={onEdit} onToggle={onToggle} />
|
||||
))}
|
||||
</Body>
|
||||
</Table>
|
||||
<div className="mt-4 flex justify-end">
|
||||
<Button color="secondary" onClick={onAdd}>
|
||||
{t("add")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ServiceAccountFields() {
|
||||
const { t } = useLocale();
|
||||
const form = useFormContext();
|
||||
|
||||
return (
|
||||
<div className="stack-y-4">
|
||||
<TextAreaField
|
||||
required
|
||||
label={t("service_account_key")}
|
||||
{...form.register("defaultServiceAccountKey")}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function UpdateServiceAccountFieldsDialog({
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
platformId,
|
||||
}: Pick<Props, "isOpen" | "onOpenChange" | "platformId">) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
type FormValues = { defaultServiceAccountKey: string };
|
||||
const form = useForm<FormValues>({
|
||||
defaultValues: {
|
||||
defaultServiceAccountKey: "",
|
||||
},
|
||||
resolver: zodResolver(z.object({ defaultServiceAccountKey: z.string() })),
|
||||
});
|
||||
|
||||
const updateServiceAccountMutation = trpc.viewer.admin.workspacePlatform.updateServiceAccount.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("service_account_updated_successfully"), "success");
|
||||
utils.viewer.admin.workspacePlatform.list.invalidate();
|
||||
onOpenChange(false);
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message || t("something_went_wrong"), "error");
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit: SubmitHandler<FormValues> = (values) => {
|
||||
if (!platformId) return;
|
||||
|
||||
const parsedKey = JSON.parse(values.defaultServiceAccountKey);
|
||||
const validatedKey = serviceAccountKeySchema.safeParse(parsedKey);
|
||||
if (!validatedKey.success) {
|
||||
form.setError("defaultServiceAccountKey", { message: t("invalid_service_account_key") });
|
||||
return;
|
||||
}
|
||||
updateServiceAccountMutation.mutate({
|
||||
id: platformId,
|
||||
...values,
|
||||
defaultServiceAccountKey: validatedKey.data,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||
<DialogContent title={t("edit_service_account_key")}>
|
||||
<Form form={form} handleSubmit={onSubmit}>
|
||||
<ServiceAccountFields />
|
||||
<DialogFooter>
|
||||
<Button type="button" color="minimal" onClick={() => onOpenChange(false)}>
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
<Button type="submit" loading={updateServiceAccountMutation.isPending}>
|
||||
{t("update")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function PlatformListItem({ platform, onEdit, onToggle }: Pick<Props, "platform" | "onEdit" | "onToggle">) {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Cell>
|
||||
<div className="text-subtle font-medium">
|
||||
<span className="text-default">{platform.name}</span>
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="text-subtle font-medium">
|
||||
<span className="text-muted">{platform.slug}</span>
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<Switch checked={platform.enabled} onCheckedChange={(checked) => onToggle(platform, checked)} />
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="flex justify-end">
|
||||
<DropdownActions
|
||||
actions={[
|
||||
{
|
||||
id: "edit",
|
||||
label: t("edit"),
|
||||
onClick: () => onEdit(platform, "meta"),
|
||||
icon: "pencil",
|
||||
},
|
||||
// {
|
||||
// id: "edit-service-account",
|
||||
// label: t("edit_service_account"),
|
||||
// onClick: () => onEdit(platform, "serviceAccount"),
|
||||
// icon: "pencil",
|
||||
// },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</Cell>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
function CreatePlatformDialog({ isOpen, onOpenChange }: Pick<Props, "isOpen" | "onOpenChange">) {
|
||||
const { t } = useLocale();
|
||||
type FormValues = { name: string; description: string; slug: string; defaultServiceAccountKey?: string };
|
||||
const form = useForm<FormValues>({
|
||||
defaultValues: {
|
||||
name: "",
|
||||
description: "",
|
||||
slug: "",
|
||||
defaultServiceAccountKey: "",
|
||||
},
|
||||
resolver: zodResolver(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
slug: z.string(),
|
||||
defaultServiceAccountKey: z.string().optional(),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const addMutation = trpc.viewer.admin.workspacePlatform.add.useMutation({
|
||||
onSuccess: async () => {
|
||||
showToast(t("workspace_platform_added_successfully"), "success");
|
||||
onOpenChange(false);
|
||||
await utils.viewer.admin.workspacePlatform.list.invalidate();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit: SubmitHandler<FormValues> = (values) => {
|
||||
// Only validate service account key if it's provided
|
||||
if (values.defaultServiceAccountKey) {
|
||||
const parsedKey = JSON.parse(values.defaultServiceAccountKey);
|
||||
const validatedKey = serviceAccountKeySchema.safeParse(parsedKey);
|
||||
if (!validatedKey.success) {
|
||||
form.setError("defaultServiceAccountKey", { message: t("invalid_service_account_key") });
|
||||
return;
|
||||
}
|
||||
addMutation.mutate({
|
||||
...values,
|
||||
defaultServiceAccountKey: validatedKey.data,
|
||||
});
|
||||
} else {
|
||||
// Submit without service account key
|
||||
addMutation.mutate({
|
||||
name: values.name,
|
||||
description: values.description,
|
||||
slug: values.slug,
|
||||
enabled: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||
<DialogContent enableOverflow title={t("add_workspace_platform")}>
|
||||
<Form form={form} handleSubmit={onSubmit}>
|
||||
<PlatformFormFields isCreate={true} />
|
||||
<DialogFooter>
|
||||
<DialogClose />
|
||||
<Button type="submit">{t("create")}</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function UpdatePlatformDialog({
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
editingPlatform,
|
||||
}: Pick<Props, "isOpen" | "onOpenChange" | "editingPlatform">) {
|
||||
const { t } = useLocale();
|
||||
type FormValues = { name: string; description: string };
|
||||
const form = useForm<FormValues>({
|
||||
defaultValues: {
|
||||
name: editingPlatform.name,
|
||||
description: editingPlatform.description,
|
||||
},
|
||||
});
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const updateMutation = trpc.viewer.admin.workspacePlatform.update.useMutation({
|
||||
onSuccess: async () => {
|
||||
showToast(t("workspace_platform_updated_successfully"), "success");
|
||||
onOpenChange(false);
|
||||
await utils.viewer.admin.workspacePlatform.list.invalidate();
|
||||
},
|
||||
onError: function (error) {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit: SubmitHandler<FormValues> = (values) => {
|
||||
updateMutation.mutate({ ...values, id: editingPlatform.id });
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||
<DialogContent title={t("edit_workspace_platform")}>
|
||||
<Form form={form} handleSubmit={onSubmit}>
|
||||
<PlatformFormFields isCreate={false} />
|
||||
<DialogFooter>
|
||||
<DialogClose />
|
||||
<Button type="submit">{t("save")}</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function PlatformFormFields({ isCreate }: Pick<Props, "isCreate">) {
|
||||
const { t } = useLocale();
|
||||
const form = useFormContext();
|
||||
|
||||
return (
|
||||
<div className="stack-y-4">
|
||||
<TextField required label={t("name")} {...form.register("name")} />
|
||||
<TextAreaField required label={t("description")} {...form.register("description")} />
|
||||
{isCreate && <TextField required label={t("slug")} {...form.register("slug")} />}
|
||||
{isCreate && false && <ServiceAccountFields />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function CreateUpdatePlatformDialog({
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
editingPlatform,
|
||||
}: Pick<Props, "isOpen" | "onOpenChange"> & { editingPlatform?: Props["editingPlatform"] }) {
|
||||
if (editingPlatform) {
|
||||
return (
|
||||
<UpdatePlatformDialog isOpen={isOpen} onOpenChange={onOpenChange} editingPlatform={editingPlatform} />
|
||||
);
|
||||
}
|
||||
return <CreatePlatformDialog isOpen={isOpen} onOpenChange={onOpenChange} />;
|
||||
}
|
||||
|
||||
export default WorkspacePlatformsPage;
|
||||
@@ -0,0 +1,223 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import BrandColorsForm from "@calcom/features/ee/components/BrandColorsForm";
|
||||
import { AppearanceSkeletonLoader } from "@calcom/features/ee/components/CommonSkeletonLoaders";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { SettingsToggle } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
type BrandColorsFormValues = {
|
||||
brandColor: string;
|
||||
darkBrandColor: string;
|
||||
};
|
||||
|
||||
const OrgAppearanceView = ({
|
||||
currentOrg,
|
||||
}: {
|
||||
currentOrg: RouterOutputs["viewer"]["organizations"]["listCurrent"];
|
||||
isAdminOrOwner: boolean;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const themeForm = useForm<{ theme: string | null | undefined }>({
|
||||
defaultValues: {
|
||||
theme: currentOrg?.theme,
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
formState: { isSubmitting: isOrgThemeSubmitting, isDirty: isOrgThemeDirty },
|
||||
reset: resetOrgThemeReset,
|
||||
} = themeForm;
|
||||
|
||||
const [hideBrandingValue, setHideBrandingValue] = useState(currentOrg?.hideBranding ?? false);
|
||||
const [allowSEOIndexingValue, setAllowSEOIndexingValue] = useState(
|
||||
currentOrg?.organizationSettings?.allowSEOIndexing ?? false
|
||||
);
|
||||
const [orgProfileRedirectsToVerifiedDomainValue, setOrgProfileRedirectsToVerifiedDomainValue] = useState(
|
||||
currentOrg?.organizationSettings?.orgProfileRedirectsToVerifiedDomain ?? false
|
||||
);
|
||||
|
||||
const brandColorsFormMethods = useForm<BrandColorsFormValues>({
|
||||
defaultValues: {
|
||||
brandColor: currentOrg?.brandColor || DEFAULT_LIGHT_BRAND_COLOR,
|
||||
darkBrandColor: currentOrg?.darkBrandColor || DEFAULT_DARK_BRAND_COLOR,
|
||||
},
|
||||
});
|
||||
|
||||
const mutation = trpc.viewer.organizations.update.useMutation({
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
async onSuccess(res) {
|
||||
await utils.viewer.teams.get.invalidate();
|
||||
await utils.viewer.organizations.listCurrent.invalidate();
|
||||
|
||||
showToast(t("your_team_updated_successfully"), "success");
|
||||
if (res) {
|
||||
brandColorsFormMethods.reset({
|
||||
brandColor: res.data.brandColor as string,
|
||||
darkBrandColor: res.data.darkBrandColor as string,
|
||||
});
|
||||
resetOrgThemeReset({ theme: res.data.theme as string | undefined });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const onBrandColorsFormSubmit = (values: BrandColorsFormValues) => {
|
||||
mutation.mutate(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Form
|
||||
form={themeForm}
|
||||
handleSubmit={({ theme }) => {
|
||||
if (theme === "light" || theme === "dark") {
|
||||
mutation.mutate({
|
||||
theme,
|
||||
});
|
||||
return;
|
||||
}
|
||||
mutation.mutate({
|
||||
theme: null,
|
||||
});
|
||||
}}>
|
||||
<div className="border-subtle mt-6 flex items-center rounded-t-xl border p-6 text-sm">
|
||||
<div>
|
||||
<p className="text-default text-base font-semibold">{t("theme")}</p>
|
||||
<p className="text-default">{t("theme_applies_note")}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
|
||||
<ThemeLabel
|
||||
variant="system"
|
||||
value="system"
|
||||
label={t("theme_system")}
|
||||
defaultChecked={currentOrg.theme === null}
|
||||
register={themeForm.register}
|
||||
/>
|
||||
<ThemeLabel
|
||||
variant="light"
|
||||
value="light"
|
||||
label={t("light")}
|
||||
defaultChecked={currentOrg.theme === "light"}
|
||||
register={themeForm.register}
|
||||
/>
|
||||
<ThemeLabel
|
||||
variant="dark"
|
||||
value="dark"
|
||||
label={t("dark")}
|
||||
defaultChecked={currentOrg.theme === "dark"}
|
||||
register={themeForm.register}
|
||||
/>
|
||||
</div>
|
||||
<SectionBottomActions className="mb-6" align="end">
|
||||
<Button
|
||||
disabled={isOrgThemeSubmitting || !isOrgThemeDirty}
|
||||
type="submit"
|
||||
data-testid="update-org-theme-btn"
|
||||
color="primary">
|
||||
{t("update")}
|
||||
</Button>
|
||||
</SectionBottomActions>
|
||||
</Form>
|
||||
|
||||
<Form
|
||||
form={brandColorsFormMethods}
|
||||
handleSubmit={(values) => {
|
||||
onBrandColorsFormSubmit(values);
|
||||
}}>
|
||||
<BrandColorsForm
|
||||
onSubmit={onBrandColorsFormSubmit}
|
||||
brandColor={currentOrg?.brandColor ?? DEFAULT_LIGHT_BRAND_COLOR}
|
||||
darkBrandColor={currentOrg?.darkBrandColor ?? DEFAULT_DARK_BRAND_COLOR}
|
||||
/>
|
||||
</Form>
|
||||
|
||||
<SettingsToggle
|
||||
toggleSwitchAtTheEnd={true}
|
||||
title={t("disable_cal_branding", { appName: APP_NAME })}
|
||||
disabled={mutation?.isPending}
|
||||
description={t("removes_cal_branding", { appName: APP_NAME })}
|
||||
checked={hideBrandingValue}
|
||||
onCheckedChange={(checked) => {
|
||||
setHideBrandingValue(checked);
|
||||
mutation.mutate({ hideBranding: checked });
|
||||
}}
|
||||
switchContainerClassName="mt-6"
|
||||
/>
|
||||
|
||||
<SettingsToggle
|
||||
data-testid={`${currentOrg?.id}-seo-indexing-switch`}
|
||||
toggleSwitchAtTheEnd={true}
|
||||
title={t("seo_indexing")}
|
||||
description={t("allow_seo_indexing")}
|
||||
disabled={mutation.isPending}
|
||||
checked={allowSEOIndexingValue}
|
||||
onCheckedChange={(checked) => {
|
||||
setAllowSEOIndexingValue(checked);
|
||||
mutation.mutate({ allowSEOIndexing: checked });
|
||||
}}
|
||||
switchContainerClassName="mt-6"
|
||||
/>
|
||||
|
||||
<SettingsToggle
|
||||
toggleSwitchAtTheEnd={true}
|
||||
title={t("disable_org_url_label")}
|
||||
description={t("disable_org_url_description", {
|
||||
orgSlug: currentOrg?.slug,
|
||||
destination: currentOrg?.organizationSettings?.orgAutoAcceptEmail,
|
||||
})}
|
||||
disabled={mutation.isPending}
|
||||
checked={orgProfileRedirectsToVerifiedDomainValue}
|
||||
onCheckedChange={(checked) => {
|
||||
setOrgProfileRedirectsToVerifiedDomainValue(checked);
|
||||
mutation.mutate({ orgProfileRedirectsToVerifiedDomain: checked });
|
||||
}}
|
||||
switchContainerClassName="mt-6"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const OrgAppearanceViewWrapper = () => {
|
||||
const router = useRouter();
|
||||
const { data: currentOrg, isPending, error } = trpc.viewer.organizations.listCurrent.useQuery();
|
||||
const session = useSession();
|
||||
const isAdminOrOwner = checkAdminOrOwner(session.data?.user?.org?.role);
|
||||
|
||||
useEffect(
|
||||
function refactorMeWithoutEffect() {
|
||||
if (error) {
|
||||
router.replace("/enterprise");
|
||||
}
|
||||
},
|
||||
[error]
|
||||
);
|
||||
|
||||
if (isPending) {
|
||||
return <AppearanceSkeletonLoader />;
|
||||
}
|
||||
|
||||
if (!currentOrg) return null;
|
||||
|
||||
return <OrgAppearanceView currentOrg={currentOrg} isAdminOrOwner={isAdminOrOwner} />;
|
||||
};
|
||||
|
||||
export default OrgAppearanceViewWrapper;
|
||||
@@ -0,0 +1,489 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import React, { useState } from "react";
|
||||
import type { UseFormReturn, FieldArrayWithId } from "react-hook-form";
|
||||
import { Controller, useForm, useFieldArray } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { InfoBadge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
|
||||
import { SettingsToggle, SelectField, Input, InputField, Form, Label } from "@calcom/ui/components/form";
|
||||
|
||||
const attributeFormSchema = z.object({
|
||||
attrName: z.string().min(1),
|
||||
isLocked: z.boolean().optional(),
|
||||
isWeightsEnabled: z.boolean().optional(),
|
||||
type: z.enum(["TEXT", "NUMBER", "SINGLE_SELECT", "MULTI_SELECT"]),
|
||||
options: z.array(
|
||||
z.object({
|
||||
value: z.string(),
|
||||
id: z.string().optional(),
|
||||
assignedUsers: z.number().optional(),
|
||||
isGroup: z.boolean().optional(),
|
||||
contains: z.array(z.string()).optional(),
|
||||
attributeOptionId: z.string().optional(),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
||||
type AttributeFormValues = z.infer<typeof attributeFormSchema>;
|
||||
|
||||
const AttributeTypeOptions = [
|
||||
{ value: "TEXT", label: "Text" },
|
||||
{ value: "NUMBER", label: "Number" },
|
||||
{ value: "SINGLE_SELECT", label: "Single Select" },
|
||||
{ value: "MULTI_SELECT", label: "Multi Select" },
|
||||
];
|
||||
|
||||
interface AttributeFormProps {
|
||||
initialValues?: AttributeFormValues;
|
||||
onSubmit: (values: AttributeFormValues) => void;
|
||||
header: React.ReactNode;
|
||||
}
|
||||
|
||||
export function getGroupOptionUpdate({
|
||||
newGroupOptions,
|
||||
previousGroupOptions,
|
||||
subOption,
|
||||
allOptions,
|
||||
}: {
|
||||
newGroupOptions: { label: string; value: string | undefined }[];
|
||||
previousGroupOptions: { label: string; value: string | undefined }[];
|
||||
subOption: { attributeOptionId?: string };
|
||||
allOptions: { attributeOptionId?: string; contains?: string[] }[];
|
||||
}) {
|
||||
const nonGroupOptionId = subOption.attributeOptionId;
|
||||
if (!nonGroupOptionId) return {};
|
||||
// Find diff b/w previouslyChosenGroupOptions and chosenGroupOptions
|
||||
const removedGroupOptions = previousGroupOptions.filter(
|
||||
(option) => !newGroupOptions.map((o) => o.value).includes(option.value)
|
||||
);
|
||||
|
||||
const optionsUpdate: { [key: number]: string[] } = {};
|
||||
|
||||
// Update all groupOptions' contains as per the final state.
|
||||
newGroupOptions
|
||||
.filter((option): option is { label: string; value: string } => !!option.value)
|
||||
.forEach((newGroupOption) => {
|
||||
const { groupOption, index: indexOfGroupOptionInWatchedOptions } = getGroupOptionMatching({
|
||||
allOptions,
|
||||
toMatchWith: newGroupOption,
|
||||
});
|
||||
if (!groupOption) return;
|
||||
const existingContains = groupOption.contains;
|
||||
const newContains = [...(existingContains || []), nonGroupOptionId].filter(
|
||||
(value, index, self) => self.indexOf(value) === index
|
||||
);
|
||||
optionsUpdate[indexOfGroupOptionInWatchedOptions] = newContains;
|
||||
});
|
||||
|
||||
// Because certain groupOptions might have been removed, we need to update such groupOptions' contains as well.
|
||||
removedGroupOptions
|
||||
.filter((option): option is { label: string; value: string } => !!option.value)
|
||||
.forEach((removedGroupOption) => {
|
||||
const { groupOption, index: indexOfGroupOptionInWatchedOptions } = getGroupOptionMatching({
|
||||
allOptions,
|
||||
toMatchWith: removedGroupOption,
|
||||
});
|
||||
if (!groupOption) return;
|
||||
const existingContains = groupOption.contains || [];
|
||||
const newContains = existingContains.filter((value) => value !== nonGroupOptionId);
|
||||
optionsUpdate[indexOfGroupOptionInWatchedOptions] = newContains;
|
||||
});
|
||||
return optionsUpdate;
|
||||
|
||||
function getGroupOptionMatching({
|
||||
allOptions,
|
||||
toMatchWith,
|
||||
}: {
|
||||
allOptions: { attributeOptionId?: string; contains?: string[] }[];
|
||||
toMatchWith: { value: string };
|
||||
}) {
|
||||
const indexOfGroupOptionInWatchedOptions = allOptions.findIndex(
|
||||
(option) => option.attributeOptionId === toMatchWith.value
|
||||
);
|
||||
return {
|
||||
index: indexOfGroupOptionInWatchedOptions,
|
||||
groupOption:
|
||||
(allOptions[indexOfGroupOptionInWatchedOptions] as (typeof allOptions)[number] | undefined) ?? null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
type AttributeOption = {
|
||||
value: string;
|
||||
id?: string;
|
||||
assignedUsers?: number;
|
||||
isGroup?: boolean;
|
||||
contains?: string[];
|
||||
attributeOptionId?: string;
|
||||
};
|
||||
|
||||
const NonGroupOption = ({
|
||||
option,
|
||||
index,
|
||||
form,
|
||||
removeOption,
|
||||
setDeleteOptionDialog,
|
||||
}: {
|
||||
option: AttributeOption;
|
||||
index: number;
|
||||
form: UseFormReturn<AttributeFormValues>;
|
||||
removeOption: (index: number) => void;
|
||||
setDeleteOptionDialog: (value: { id: number; open: boolean }) => void;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<div key={option.id}>
|
||||
<div className="flex items-center gap-2" key={option.id}>
|
||||
<div className="flex w-full">
|
||||
<Input {...form.register(`options.${index}.value`)} placeholder={t("enter_option_value")} />
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="icon"
|
||||
StartIcon="x"
|
||||
color="minimal"
|
||||
className="mb-2"
|
||||
disabled={index === 0 && form.getValues("options").length === 1}
|
||||
onClick={() => {
|
||||
if (option.assignedUsers && option.assignedUsers > 0) {
|
||||
setDeleteOptionDialog({ id: index, open: true });
|
||||
} else {
|
||||
removeOption(index);
|
||||
}
|
||||
}}
|
||||
title={t("remove_option")}
|
||||
/>
|
||||
</div>
|
||||
<Input {...form.register(`options.${index}.id`)} className="hidden" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const getNonGroupOptionsForSelect = (nonGroupOptions: AttributeOption[]) => {
|
||||
return nonGroupOptions
|
||||
.map((f) => ({
|
||||
label: f.value,
|
||||
value: f.attributeOptionId,
|
||||
}))
|
||||
.filter((option): option is { label: string; value: string } => !!option.value);
|
||||
};
|
||||
|
||||
const getSelectedNonGroupOptions = (option: AttributeOption, nonGroupOptions: AttributeOption[]) => {
|
||||
return option.contains
|
||||
?.map((containedId: string) => {
|
||||
const nonGroupOption = nonGroupOptions.find((opt) => opt.attributeOptionId === containedId);
|
||||
if (!nonGroupOption?.value || !nonGroupOption?.attributeOptionId) return null;
|
||||
return {
|
||||
label: nonGroupOption.value,
|
||||
value: nonGroupOption.attributeOptionId,
|
||||
};
|
||||
})
|
||||
.filter((val): val is { label: string; value: string } => val !== null);
|
||||
};
|
||||
|
||||
const GroupOption = ({
|
||||
option,
|
||||
index,
|
||||
form,
|
||||
removeOption,
|
||||
setDeleteOptionDialog,
|
||||
}: {
|
||||
option: AttributeOption;
|
||||
index: number;
|
||||
form: UseFormReturn<AttributeFormValues>;
|
||||
removeOption: (index: number) => void;
|
||||
setDeleteOptionDialog: (value: { id: number; open: boolean }) => void;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const watchedOptions = form.getValues("options") as AttributeOption[];
|
||||
if (!watchedOptions) return null;
|
||||
|
||||
const watchedNonGroupOptions = watchedOptions.filter((field): field is AttributeOption => !field.isGroup);
|
||||
if (!watchedNonGroupOptions.length) return null;
|
||||
|
||||
const nonGroupOptionsSelectFieldOptions = getNonGroupOptionsForSelect(watchedNonGroupOptions);
|
||||
const nonGroupOptionsSelectFieldSelectedValue = getSelectedNonGroupOptions(option, watchedNonGroupOptions);
|
||||
|
||||
return (
|
||||
<div key={option.id}>
|
||||
<div className="mb-2 flex items-center gap-2" key={option.id}>
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<Input {...form.register(`options.${index}.value`)} className="mb-0! w-36" />
|
||||
<SelectField
|
||||
isMulti
|
||||
placeholder={t("choose_an_option")}
|
||||
options={nonGroupOptionsSelectFieldOptions}
|
||||
value={nonGroupOptionsSelectFieldSelectedValue}
|
||||
onChange={(chosenNonGroupOptions) => {
|
||||
const newContains = chosenNonGroupOptions.map((opt) => opt.value);
|
||||
form.setValue(`options.${index}.contains`, newContains);
|
||||
}}
|
||||
containerClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="icon"
|
||||
StartIcon="x"
|
||||
color="minimal"
|
||||
className="mb-2"
|
||||
disabled={index === 0 && form.getValues("options").length === 1}
|
||||
onClick={() => {
|
||||
if (option.assignedUsers && option.assignedUsers > 0) {
|
||||
setDeleteOptionDialog({ id: index, open: true });
|
||||
} else {
|
||||
removeOption(index);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Input {...form.register(`options.${index}.id`)} className="hidden" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const GroupOptions = ({
|
||||
fields,
|
||||
watchedOptions,
|
||||
form,
|
||||
removeOption,
|
||||
setDeleteOptionDialog,
|
||||
}: {
|
||||
fields: FieldArrayWithId<AttributeFormValues, "options", "id">[];
|
||||
watchedOptions: AttributeOption[];
|
||||
form: UseFormReturn<AttributeFormValues>;
|
||||
removeOption: (index: number) => void;
|
||||
setDeleteOptionDialog: (value: { id: number; open: boolean }) => void;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<>
|
||||
<Label className="flex items-center">
|
||||
{t("group_options")}
|
||||
<InfoBadge content={t("group_options_description")} />
|
||||
</Label>
|
||||
<div>
|
||||
{fields.map((option, index) => {
|
||||
const isAGroupOption = option.isGroup;
|
||||
if (!isAGroupOption) return null;
|
||||
return (
|
||||
<GroupOption
|
||||
key={option.id}
|
||||
option={watchedOptions[index]}
|
||||
index={index}
|
||||
form={form}
|
||||
removeOption={removeOption}
|
||||
setDeleteOptionDialog={setDeleteOptionDialog}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export function AttributeForm({ initialValues, onSubmit, header }: AttributeFormProps) {
|
||||
const { t } = useLocale();
|
||||
const [deleteOptionDialog, setDeleteOptionDialog] = useState<{
|
||||
id: number | undefined;
|
||||
open: boolean;
|
||||
}>({
|
||||
id: undefined,
|
||||
open: false,
|
||||
});
|
||||
|
||||
// Needed because fields returned by useFieldArray have their own id field overriding the id field of the option object.
|
||||
const initialValuesEnsuringThatOptionIdIsNotInId = initialValues
|
||||
? {
|
||||
...initialValues,
|
||||
options: initialValues.options.map((option) => ({
|
||||
...option,
|
||||
// Set attributeOptionId equal to id field because 'id' property is used by useFieldArray
|
||||
attributeOptionId: option.id,
|
||||
// Also, set id to undefined to make it clear that this id is not used by us.
|
||||
id: undefined,
|
||||
})),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const form = useForm<AttributeFormValues>({
|
||||
resolver: zodResolver(attributeFormSchema),
|
||||
defaultValues: initialValuesEnsuringThatOptionIdIsNotInId || {
|
||||
attrName: "",
|
||||
options: [{ value: "", isGroup: false }],
|
||||
type: "TEXT",
|
||||
},
|
||||
});
|
||||
|
||||
const { fields, append, remove } = useFieldArray({
|
||||
control: form.control,
|
||||
name: "options",
|
||||
});
|
||||
|
||||
const removeOption = (index: number) => {
|
||||
// Update contains array of any group that has this option
|
||||
const optionToRemove = watchedOptions[index];
|
||||
if (!optionToRemove.isGroup && optionToRemove.attributeOptionId) {
|
||||
const updatedOptions = getUpdatedOptionsAfterRemovingNonGroupOption({
|
||||
optionToRemove,
|
||||
watchedOptions,
|
||||
});
|
||||
form.setValue("options", updatedOptions);
|
||||
}
|
||||
remove(index);
|
||||
};
|
||||
|
||||
const getUpdatedOptionsAfterRemovingNonGroupOption = ({
|
||||
optionToRemove,
|
||||
watchedOptions,
|
||||
}: {
|
||||
optionToRemove: AttributeOption;
|
||||
watchedOptions: AttributeOption[];
|
||||
}) => {
|
||||
const attributeOptionIdToRemove = optionToRemove.attributeOptionId;
|
||||
if (!attributeOptionIdToRemove) return watchedOptions;
|
||||
return watchedOptions.map((option) => {
|
||||
if (option.isGroup && option.contains) {
|
||||
return {
|
||||
...option,
|
||||
contains: option.contains.filter((id) => id !== attributeOptionIdToRemove),
|
||||
};
|
||||
}
|
||||
return option;
|
||||
});
|
||||
};
|
||||
|
||||
const watchedOptions = form.watch("options") as AttributeOption[];
|
||||
const watchedType = form.watch("type");
|
||||
return (
|
||||
<Form
|
||||
form={form}
|
||||
className="flex flex-col stack-y-4 lg:stack-y-6"
|
||||
handleSubmit={(values) => {
|
||||
onSubmit({
|
||||
...values,
|
||||
options: values.options.map(({ attributeOptionId, ...option }) => ({
|
||||
...option,
|
||||
// Set back attributeOptionId in id field
|
||||
id: attributeOptionId,
|
||||
})),
|
||||
});
|
||||
}}>
|
||||
{header}
|
||||
<Controller
|
||||
name="isLocked"
|
||||
render={({ field: { value, onChange } }) => {
|
||||
return (
|
||||
<SettingsToggle
|
||||
title={t("lock_attribute_for_assignment")}
|
||||
description={t("lock_attribute_for_assignment_description")}
|
||||
checked={value}
|
||||
onCheckedChange={(checked) => {
|
||||
onChange(checked);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{["SINGLE_SELECT", "MULTI_SELECT"].includes(watchedType) && (
|
||||
<Controller
|
||||
name="isWeightsEnabled"
|
||||
render={({ field: { value, onChange } }) => {
|
||||
return (
|
||||
<SettingsToggle
|
||||
title={t("attribute_weight_enabled")}
|
||||
description={t("attribute_weight_enabled_description")}
|
||||
checked={value}
|
||||
onCheckedChange={(checked) => {
|
||||
onChange(checked);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<InputField label={t("name")} required {...form.register("attrName")} />
|
||||
<Controller
|
||||
name="type"
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<SelectField
|
||||
label="Type"
|
||||
options={AttributeTypeOptions}
|
||||
onChange={(option) => {
|
||||
if (!option) return;
|
||||
onChange(option.value);
|
||||
}}
|
||||
value={AttributeTypeOptions.find((attr) => attr.value === value)}
|
||||
required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{["SINGLE_SELECT", "MULTI_SELECT"].includes(watchedType) && (
|
||||
<div className="bg-cal-muted border-muted mt-6 rounded-lg border p-6">
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>
|
||||
<Label>{t("options")}</Label>
|
||||
<div>
|
||||
{fields.map((option, index) => {
|
||||
const isAGroupOption = option.isGroup;
|
||||
if (isAGroupOption) return null;
|
||||
return (
|
||||
<NonGroupOption
|
||||
key={option.id}
|
||||
option={watchedOptions[index]}
|
||||
index={index}
|
||||
form={form}
|
||||
removeOption={removeOption}
|
||||
setDeleteOptionDialog={setDeleteOptionDialog}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<Button type="button" StartIcon="plus" color="secondary" onClick={() => append({ value: "" })}>
|
||||
{t("new_option")}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<GroupOptions
|
||||
fields={fields}
|
||||
watchedOptions={watchedOptions}
|
||||
form={form}
|
||||
removeOption={removeOption}
|
||||
setDeleteOptionDialog={setDeleteOptionDialog}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
StartIcon="plus"
|
||||
color="secondary"
|
||||
onClick={() => append({ value: "", isGroup: true })}>
|
||||
{t("new_group_option")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<Dialog
|
||||
open={deleteOptionDialog.open}
|
||||
onOpenChange={() => setDeleteOptionDialog({ id: undefined, open: false })}>
|
||||
<ConfirmationDialogContent
|
||||
title={t("delete_attribute")}
|
||||
confirmBtnText={t("delete")}
|
||||
onConfirm={() => {
|
||||
removeOption(deleteOptionDialog.id as number);
|
||||
setDeleteOptionDialog({ id: undefined, open: false });
|
||||
}}
|
||||
loadingText={t("deleting_attribute")}>
|
||||
<>
|
||||
{t("delete_attribute_description", {
|
||||
numberOfUsers: watchedOptions[deleteOptionDialog.id as number]?.assignedUsers || 0,
|
||||
})}
|
||||
</>
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { revalidateAttributesList } from "@calcom/web/app/(use-page-wrapper)/settings/organizations/(org-user-only)/members/actions";
|
||||
|
||||
type AttributeItemProps = RouterOutputs["viewer"]["attributes"]["list"][number];
|
||||
|
||||
export function DeleteAttributeModal({
|
||||
attributeToDelete,
|
||||
setAttributeToDelete,
|
||||
}: {
|
||||
attributeToDelete: AttributeItemProps;
|
||||
setAttributeToDelete: Dispatch<SetStateAction<AttributeItemProps | undefined>>;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const deleteMutation = trpc.viewer.attributes.delete.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("attribute_deleted_successfully"), "success");
|
||||
utils.viewer.attributes.list.invalidate();
|
||||
revalidateAttributesList();
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={true} onOpenChange={() => setAttributeToDelete(undefined)}>
|
||||
<ConfirmationDialogContent
|
||||
variety="danger"
|
||||
title={t("remove_attribute")}
|
||||
confirmBtnText={t("confirm_remove_attribute")}
|
||||
onConfirm={() => {
|
||||
deleteMutation.mutate({
|
||||
id: attributeToDelete.id,
|
||||
});
|
||||
}}>
|
||||
{t("remove_attribute_confirmation_message", {
|
||||
name: attributeToDelete.name,
|
||||
})}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
export function ListSkeleton() {
|
||||
return (
|
||||
<ul className="focus-within:border-emphasis flex justify-between p-4">
|
||||
{Array.from({ length: 3 }).map((_, idx) => (
|
||||
<li key={idx}>
|
||||
<AttributeSkeleton />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function AttributeSkeleton() {
|
||||
return (
|
||||
<div>
|
||||
<SkeletonText className="text-sm font-semibold leading-none" />
|
||||
<SkeletonText className="text-default inline-flex items-center gap-1 text-sm font-normal leading-none" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
import { getGroupOptionUpdate } from "../AttributesForm";
|
||||
|
||||
describe("getGroupOptionUpdate", () => {
|
||||
it("should add non-group option to new group's contains array", () => {
|
||||
const result = getGroupOptionUpdate({
|
||||
newGroupOptions: [{ label: "Group 1", value: "group1" }],
|
||||
previousGroupOptions: [],
|
||||
subOption: { attributeOptionId: "option1" },
|
||||
allOptions: [{ attributeOptionId: "group1", contains: [] }],
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
0: ["option1"],
|
||||
});
|
||||
});
|
||||
|
||||
it("should remove non-group option from removed group's contains array", () => {
|
||||
const result = getGroupOptionUpdate({
|
||||
newGroupOptions: [],
|
||||
previousGroupOptions: [{ label: "Group 1", value: "group1" }],
|
||||
subOption: { attributeOptionId: "option1" },
|
||||
allOptions: [{ attributeOptionId: "group1", contains: ["option1", "option2"] }],
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
0: ["option2"],
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle multiple group updates simultaneously", () => {
|
||||
const result = getGroupOptionUpdate({
|
||||
newGroupOptions: [
|
||||
{ label: "Group 1", value: "group1" },
|
||||
{ label: "Group 2", value: "group2" },
|
||||
],
|
||||
previousGroupOptions: [{ label: "Group 3", value: "group3" }],
|
||||
subOption: { attributeOptionId: "option1" },
|
||||
allOptions: [
|
||||
{ attributeOptionId: "group1", contains: ["option2"] },
|
||||
{ attributeOptionId: "group2", contains: [] },
|
||||
{ attributeOptionId: "group3", contains: ["option1", "option3"] },
|
||||
],
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
0: ["option2", "option1"],
|
||||
1: ["option1"],
|
||||
2: ["option3"],
|
||||
});
|
||||
});
|
||||
|
||||
it("should prevent duplicate entries in contains array", () => {
|
||||
const result = getGroupOptionUpdate({
|
||||
newGroupOptions: [{ label: "Group 1", value: "group1" }],
|
||||
previousGroupOptions: [],
|
||||
subOption: { attributeOptionId: "option1" },
|
||||
allOptions: [{ attributeOptionId: "group1", contains: ["option1"] }],
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
0: ["option1"], // Should not have duplicate "option1"
|
||||
});
|
||||
});
|
||||
|
||||
it("should not consider a group option with undefined value", () => {
|
||||
const result = getGroupOptionUpdate({
|
||||
newGroupOptions: [{ label: "Group 1", value: undefined }],
|
||||
previousGroupOptions: [],
|
||||
subOption: { attributeOptionId: "option1" },
|
||||
allOptions: [{ attributeOptionId: "1", contains: ["option1"] }],
|
||||
});
|
||||
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,205 @@
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import * as Tooltip from "@radix-ui/react-tooltip";
|
||||
import React from "react";
|
||||
import type { Mock } from "vitest";
|
||||
import { vi } from "vitest";
|
||||
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
import { AttributeForm } from "../AttributesForm";
|
||||
|
||||
vi.mock("@calcom/lib/hooks/useLocale", () => ({
|
||||
useLocale: () => ({
|
||||
t: (key: string) => key,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("@calcom/lib/hooks/useCompatSearchParams", () => ({
|
||||
useCompatSearchParams: () => new URLSearchParams(),
|
||||
}));
|
||||
|
||||
vi.mock("next/navigation", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("next/navigation")>();
|
||||
return {
|
||||
...actual,
|
||||
useRouter: () => ({
|
||||
push: vi.fn(),
|
||||
}),
|
||||
usePathname: () => "/settings/organizations/attributes",
|
||||
};
|
||||
});
|
||||
|
||||
type InitialOption = {
|
||||
id?: string;
|
||||
value: string;
|
||||
isGroup?: boolean;
|
||||
contains?: string[];
|
||||
attributeOptionId?: string;
|
||||
assignedUsers?: number;
|
||||
};
|
||||
|
||||
// Page Object Functions
|
||||
const AttributeFormActions = {
|
||||
setup: () => {
|
||||
const user = userEvent.setup();
|
||||
const mockOnSubmit = vi.fn();
|
||||
return { user, mockOnSubmit };
|
||||
},
|
||||
|
||||
render: (initialOptions: InitialOption[], mockOnSubmit: Mock) => {
|
||||
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||
<Tooltip.Provider>{children}</Tooltip.Provider>
|
||||
);
|
||||
|
||||
return render(
|
||||
<AttributeForm
|
||||
onSubmit={mockOnSubmit}
|
||||
initialValues={{
|
||||
attrName: "Teams",
|
||||
type: "MULTI_SELECT",
|
||||
options: initialOptions,
|
||||
}}
|
||||
header={<Button type="submit">Save</Button>}
|
||||
/>,
|
||||
{ wrapper }
|
||||
);
|
||||
},
|
||||
|
||||
addOptionToGroup: async (user: ReturnType<typeof userEvent.setup>) => {
|
||||
const selects = await screen.findAllByText("choose_an_option");
|
||||
await user.click(selects[0]);
|
||||
},
|
||||
|
||||
selectOption: async (user: ReturnType<typeof userEvent.setup>, optionText: string) => {
|
||||
const option = await screen.findByText(optionText);
|
||||
await user.click(option);
|
||||
},
|
||||
|
||||
submitForm: async (user: ReturnType<typeof userEvent.setup>) => {
|
||||
const submitButton = screen.getByRole("button", { name: "Save" });
|
||||
await user.click(submitButton);
|
||||
},
|
||||
|
||||
deleteOption: async (user: ReturnType<typeof userEvent.setup>, index: number) => {
|
||||
const deleteButtons = screen.getAllByTitle("remove_option");
|
||||
await user.click(deleteButtons[index]);
|
||||
},
|
||||
|
||||
expectGroupContainsOptions: async (mockOnSubmit: Mock, groupValue: string, containsIds: string[]) => {
|
||||
await waitFor(() => {
|
||||
expect(mockOnSubmit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
options: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
value: groupValue,
|
||||
isGroup: true,
|
||||
contains: expect.arrayContaining(containsIds),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
expectGroupNotContainsOptions: async (mockOnSubmit: Mock, groupValue: string, notContainsIds: string[]) => {
|
||||
await waitFor(() => {
|
||||
expect(mockOnSubmit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
options: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
value: groupValue,
|
||||
isGroup: true,
|
||||
contains: expect.not.arrayContaining(notContainsIds),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
expectDeleteConfirmationDialog: () => {
|
||||
expect(screen.getByText("delete_attribute")).toBeInTheDocument();
|
||||
expect(screen.getByText("delete_attribute_description")).toBeInTheDocument();
|
||||
},
|
||||
|
||||
expectOptionToBeDeleted: async (mockOnSubmit: Mock, optionValue: string) => {
|
||||
await waitFor(() => {
|
||||
expect(mockOnSubmit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
options: expect.not.arrayContaining([
|
||||
expect.objectContaining({
|
||||
value: optionValue,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const initialOptionsWithAGroupHavingOptions: InitialOption[] = [
|
||||
{ id: "1", value: "Engineering", isGroup: false, attributeOptionId: "1" },
|
||||
{ id: "2", value: "Design", isGroup: false, attributeOptionId: "2" },
|
||||
{ id: "3", value: "Product", isGroup: false, attributeOptionId: "3" },
|
||||
{
|
||||
id: "4",
|
||||
value: "Tech Teams",
|
||||
isGroup: true,
|
||||
contains: ["1", "3"],
|
||||
attributeOptionId: "4",
|
||||
},
|
||||
];
|
||||
|
||||
const initialOptionsWithAGroupHavingNoOptions: InitialOption[] = [
|
||||
{ id: "1", value: "Engineering", isGroup: false, attributeOptionId: "1" },
|
||||
{ id: "2", value: "Design", isGroup: false, attributeOptionId: "2" },
|
||||
{ id: "3", value: "Product", isGroup: false, attributeOptionId: "3" },
|
||||
{
|
||||
id: "4",
|
||||
value: "Tech Teams",
|
||||
isGroup: true,
|
||||
contains: [],
|
||||
attributeOptionId: "4",
|
||||
},
|
||||
];
|
||||
|
||||
describe("AttributeForm", () => {
|
||||
describe("Group Options Handling", () => {
|
||||
it("should handle adding non-group options to existing group", async () => {
|
||||
const { user, mockOnSubmit } = AttributeFormActions.setup();
|
||||
AttributeFormActions.render(initialOptionsWithAGroupHavingNoOptions, mockOnSubmit);
|
||||
|
||||
await AttributeFormActions.addOptionToGroup(user);
|
||||
await AttributeFormActions.selectOption(user, "Design");
|
||||
await AttributeFormActions.submitForm(user);
|
||||
|
||||
await AttributeFormActions.expectGroupContainsOptions(mockOnSubmit, "Tech Teams", ["2"]);
|
||||
});
|
||||
|
||||
it("should handle removing options from group when the option is deleted", async () => {
|
||||
const { user, mockOnSubmit } = AttributeFormActions.setup();
|
||||
AttributeFormActions.render(initialOptionsWithAGroupHavingOptions, mockOnSubmit);
|
||||
|
||||
await AttributeFormActions.deleteOption(user, 0);
|
||||
await AttributeFormActions.submitForm(user);
|
||||
await AttributeFormActions.expectGroupNotContainsOptions(mockOnSubmit, "Tech Teams", ["1"]);
|
||||
await AttributeFormActions.expectOptionToBeDeleted(mockOnSubmit, "Engineering");
|
||||
});
|
||||
|
||||
it("should take confirmation before deleting option with assigned users", async () => {
|
||||
const { user, mockOnSubmit } = AttributeFormActions.setup();
|
||||
const optionsWithAssignedUsers = initialOptionsWithAGroupHavingOptions.map((opt) =>
|
||||
opt.value === "Engineering" ? { ...opt, assignedUsers: 5 } : opt
|
||||
);
|
||||
|
||||
AttributeFormActions.render(optionsWithAssignedUsers, mockOnSubmit);
|
||||
await AttributeFormActions.deleteOption(user, 0);
|
||||
AttributeFormActions.expectDeleteConfirmationDialog();
|
||||
const confirmationButton = screen.getByTestId("dialog-confirmation");
|
||||
await user.click(confirmationButton);
|
||||
await AttributeFormActions.submitForm(user);
|
||||
await AttributeFormActions.expectGroupNotContainsOptions(mockOnSubmit, "Tech Teams", ["1"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { revalidateAttributesList } from "@calcom/web/app/(use-page-wrapper)/settings/organizations/(org-user-only)/members/actions";
|
||||
|
||||
import { AttributeForm } from "./AttributesForm";
|
||||
|
||||
const CreateAttributeSchema = z.object({
|
||||
// Calling this name would make sense but conflicts with rhf "watch" "name" field
|
||||
attrName: z.string().min(1),
|
||||
type: z.enum(["TEXT", "NUMBER", "SINGLE_SELECT", "MULTI_SELECT"]),
|
||||
options: z.array(z.object({ value: z.string(), id: z.string() })),
|
||||
});
|
||||
|
||||
type FormValues = z.infer<typeof CreateAttributeSchema>;
|
||||
|
||||
function CreateAttributesPage() {
|
||||
const router = useRouter();
|
||||
const mutation = trpc.viewer.attributes.create.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast("Attribute created successfully", "success");
|
||||
revalidateAttributesList();
|
||||
router.push("/settings/organizations/attributes");
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<LicenseRequired>
|
||||
<AttributeForm
|
||||
header={<CreateAttributeHeader isPending={mutation.isPending} />}
|
||||
onSubmit={(values) => {
|
||||
const { attrName, ...rest } = values;
|
||||
mutation.mutate({
|
||||
...rest,
|
||||
name: attrName,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</LicenseRequired>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function CreateAttributeHeader(props: { isPending: boolean }) {
|
||||
const { t } = useLocale();
|
||||
const formContext = useFormContext<FormValues>();
|
||||
|
||||
const watchedTitle = formContext.watch("attrName");
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-6 mt-6 flex grow items-center justify-between lg:mt-12">
|
||||
<div className="-ml-12 flex items-center gap-4">
|
||||
<Button
|
||||
variant="icon"
|
||||
StartIcon="arrow-left"
|
||||
color="minimal"
|
||||
href="/settings/organizations/attributes">
|
||||
<span className="sr-only">{t("back_to_attributes")}</span>
|
||||
</Button>
|
||||
<div className="font-cal text-cal flex space-x-1 text-xl font-semibold leading-none">
|
||||
<h1 className="text-emphasis">{t("attribute")}</h1>
|
||||
{watchedTitle && (
|
||||
<>
|
||||
<span className="text-subtle">/</span> <span className="text-emphasis">{watchedTitle}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Button type="submit" data-testid="create-attribute-button" loading={props.isPending}>
|
||||
{t("save")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default CreateAttributesPage;
|
||||
@@ -0,0 +1,112 @@
|
||||
"use client";
|
||||
|
||||
import { useParams } from "next/navigation";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { revalidateAttributesList } from "@calcom/web/app/(use-page-wrapper)/settings/organizations/(org-user-only)/members/actions";
|
||||
|
||||
import { AttributeForm } from "./AttributesForm";
|
||||
|
||||
const CreateAttributeSchema = z.object({
|
||||
// Calling this name would make sense but conflicts with rhf "watch" "name" field
|
||||
attrName: z.string().min(1),
|
||||
type: z.enum(["TEXT", "NUMBER", "SINGLE_SELECT", "MULTI_SELECT"]),
|
||||
options: z.array(z.object({ value: z.string(), id: z.string() })),
|
||||
});
|
||||
|
||||
type FormValues = z.infer<typeof CreateAttributeSchema>;
|
||||
|
||||
function CreateAttributesPage() {
|
||||
const utils = trpc.useUtils();
|
||||
const { t } = useLocale();
|
||||
// Get the attribute id from the url
|
||||
const params = useParams<{ id: string }>();
|
||||
const id = params?.id || "";
|
||||
// ensure string with zod
|
||||
const attribute = trpc.viewer.attributes.get.useQuery({ id });
|
||||
|
||||
const mutation = trpc.viewer.attributes.edit.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("attribute_edited_successfully"), "success");
|
||||
utils.viewer.attributes.get.invalidate({
|
||||
id,
|
||||
});
|
||||
utils.viewer.attributes.list.invalidate();
|
||||
revalidateAttributesList();
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<LicenseRequired>
|
||||
{!attribute.isLoading && attribute.data ? (
|
||||
<AttributeForm
|
||||
initialValues={{
|
||||
attrName: attribute.data.name,
|
||||
type: attribute.data.type,
|
||||
options: attribute.data.options,
|
||||
isLocked: attribute.data.isLocked,
|
||||
isWeightsEnabled: attribute.data.isWeightsEnabled,
|
||||
}}
|
||||
header={<EditAttributeHeader isPending={mutation.isPending} />}
|
||||
onSubmit={(values) => {
|
||||
const { attrName, ...rest } = values;
|
||||
mutation.mutate({
|
||||
...rest,
|
||||
name: attrName,
|
||||
attributeId: id,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<>Loading</>
|
||||
)}
|
||||
</LicenseRequired>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function EditAttributeHeader(props: { isPending: boolean }) {
|
||||
const { t } = useLocale();
|
||||
const formContext = useFormContext<FormValues>();
|
||||
|
||||
const watchedTitle = formContext.watch("attrName");
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-6 mt-6 flex grow items-center justify-between lg:mt-12">
|
||||
<div className="-ml-12 flex items-center gap-4">
|
||||
<Button
|
||||
variant="icon"
|
||||
StartIcon="arrow-left"
|
||||
color="minimal"
|
||||
href="/settings/organizations/attributes">
|
||||
<span className="sr-only">{t("back_to_attributes")}</span>
|
||||
</Button>
|
||||
<div className="font-cal text-cal flex space-x-1 text-xl font-semibold leading-none">
|
||||
<h1 className="text-emphasis">{t("attribute")}</h1>
|
||||
{watchedTitle && (
|
||||
<>
|
||||
<span className="text-subtle">/</span> <span className="text-emphasis">{watchedTitle}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Button type="submit" data-testid="create-attribute-button" loading={props.isPending}>
|
||||
{t("save")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default CreateAttributesPage;
|
||||
@@ -0,0 +1,213 @@
|
||||
"use client";
|
||||
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useState } from "react";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownItem,
|
||||
DropdownMenuItem,
|
||||
} from "@calcom/ui/components/dropdown";
|
||||
import { Switch } from "@calcom/ui/components/form";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { revalidateAttributesList } from "@calcom/web/app/(use-page-wrapper)/settings/organizations/(org-user-only)/members/actions";
|
||||
|
||||
import { DeleteAttributeModal } from "./DeleteAttributeModal";
|
||||
import { ListSkeleton } from "./ListSkeleton";
|
||||
|
||||
type AttributeItemProps = RouterOutputs["viewer"]["attributes"]["list"][number];
|
||||
|
||||
const TypeToLabelMap = {
|
||||
TEXT: "Text",
|
||||
NUMBER: "Number",
|
||||
SINGLE_SELECT: "Single-select",
|
||||
MULTI_SELECT: "Multi-select",
|
||||
};
|
||||
|
||||
function AttributeItem({
|
||||
attribute,
|
||||
setAttributeToDelete,
|
||||
permissions,
|
||||
}: {
|
||||
attribute: AttributeItemProps;
|
||||
setAttributeToDelete: Dispatch<SetStateAction<AttributeItemProps | undefined>>;
|
||||
permissions: { canEdit: boolean; canDelete: boolean };
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const [isEnabled, setIsEnabled] = useState(attribute.enabled);
|
||||
const mutation = trpc.viewer.attributes.toggleActive.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("attribute_updated_successfully"), "success");
|
||||
revalidateAttributesList();
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const handleToggle = (checked: boolean) => {
|
||||
// Optimistically update the local state
|
||||
setIsEnabled(checked);
|
||||
mutation.mutate(
|
||||
{ attributeId: attribute.id },
|
||||
{
|
||||
onError: (err) => {
|
||||
setIsEnabled(!checked);
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<ul className="focus-within:border-emphasis flex justify-between p-4" key={attribute.id}>
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold leading-none">{attribute.name}</h3>
|
||||
<p className="text-default inline-flex items-center gap-1 text-sm font-normal leading-none">
|
||||
{TypeToLabelMap[attribute.type]}
|
||||
{attribute.options?.length > 0 && (
|
||||
<>
|
||||
<span className="text-muted">•</span>
|
||||
<span>{t("number_of_options", { count: attribute.options.length })}</span>
|
||||
</>
|
||||
)}
|
||||
{attribute.isWeightsEnabled && (
|
||||
<>
|
||||
<span className="text-muted">•</span>
|
||||
<Badge>{t("attribute_weight_enabled")}</Badge>
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
{permissions.canEdit && <Switch checked={isEnabled} onCheckedChange={handleToggle} />}
|
||||
{(permissions.canEdit || permissions.canDelete) && (
|
||||
<Dropdown modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="icon"
|
||||
color="secondary"
|
||||
StartIcon="ellipsis"
|
||||
className="ltr:radix-state-open:rounded-r-md rtl:radix-state-open:rounded-l-md"
|
||||
/>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="min-w-[200px]">
|
||||
{permissions.canEdit && (
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
StartIcon="pencil"
|
||||
href={`/settings/organizations/attributes/${attribute.id}/edit`}>
|
||||
{t("edit")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{permissions.canDelete && (
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
StartIcon="trash-2"
|
||||
color="destructive"
|
||||
className="rounded-t-none"
|
||||
onClick={() => setAttributeToDelete(attribute)}>
|
||||
{t("delete")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
)}
|
||||
</div>
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function OrganizationAttributesPage({
|
||||
permissions,
|
||||
}: {
|
||||
permissions: { canEdit: boolean; canDelete: boolean; canCreate: boolean };
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const { data, isLoading } = trpc.viewer.attributes.list.useQuery();
|
||||
const [attributeToDelete, setAttributeToDelete] = useState<AttributeItemProps>();
|
||||
if (isLoading) {
|
||||
return (
|
||||
<>
|
||||
<div className="border-subtle bg-default flex flex-col gap-4 rounded-lg border p-6">
|
||||
<ListSkeleton />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<div className="border-subtle bg-default flex flex-col gap-4 rounded-lg border p-6">
|
||||
{data && data?.length > 0 ? (
|
||||
<>
|
||||
<h2 className="text-emphasis text-base font-semibold leading-none">{t("custom")}</h2>
|
||||
<li className="border-subtle bg-default divide-subtle flex flex-col divide-y rounded-lg border">
|
||||
{data?.map((attribute) => (
|
||||
<AttributeItem
|
||||
setAttributeToDelete={setAttributeToDelete}
|
||||
attribute={attribute}
|
||||
permissions={{ canEdit: permissions.canEdit, canDelete: permissions.canDelete }}
|
||||
key={attribute.id}
|
||||
/>
|
||||
))}
|
||||
</li>
|
||||
{permissions.canCreate && (
|
||||
<Button
|
||||
className="w-fit"
|
||||
StartIcon="plus"
|
||||
color="minimal"
|
||||
href="/settings/organizations/attributes/create">
|
||||
{t("add")}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-center justify-center p-14">
|
||||
<div className="bg-emphasis text-emphasis flex h-16 w-16 items-center justify-center rounded-full p-2">
|
||||
<Icon name="tags" />
|
||||
</div>
|
||||
<h2 className="font-cal text-emphasis mt-6 text-xl font-semibold leading-none">
|
||||
{t("add_attributes")}
|
||||
</h2>
|
||||
|
||||
<p className="text-emphasis mt-3 text-sm font-normal leading-none">
|
||||
{t("add_attributes_description")}
|
||||
</p>
|
||||
{permissions.canCreate && (
|
||||
<Button
|
||||
className="mt-8"
|
||||
StartIcon="plus"
|
||||
color="secondary"
|
||||
href="/settings/organizations/attributes/create">
|
||||
{t("new_attribute")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{attributeToDelete && (
|
||||
<DeleteAttributeModal
|
||||
attributeToDelete={attributeToDelete}
|
||||
setAttributeToDelete={setAttributeToDelete}
|
||||
/>
|
||||
)}
|
||||
</LicenseRequired>
|
||||
);
|
||||
}
|
||||
|
||||
export default OrganizationAttributesPage;
|
||||
@@ -0,0 +1,541 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useForm, Controller, useFormContext } from "react-hook-form";
|
||||
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { ServiceAccountKey } from "@calcom/lib/server/serviceAccountKey";
|
||||
import { serviceAccountKeySchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { InfoBadge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { DialogContent, DialogFooter, ConfirmationDialogContent } from "@calcom/ui/components/dialog";
|
||||
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { TextAreaField } from "@calcom/ui/components/form";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { SelectField } from "@calcom/ui/components/form";
|
||||
import { Switch } from "@calcom/ui/components/form";
|
||||
import { SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { DropdownActions } from "@calcom/ui/components/table";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
interface DelegationItemProps {
|
||||
delegation: {
|
||||
id: string;
|
||||
domain: string;
|
||||
enabled: boolean;
|
||||
serviceAccountClientId: string | null;
|
||||
workspacePlatform: {
|
||||
name: string;
|
||||
slug: string;
|
||||
};
|
||||
};
|
||||
toggleDelegation: (delegation: DelegationItemProps["delegation"]) => void;
|
||||
onEdit: (delegation: DelegationItemProps["delegation"]) => void;
|
||||
onDelete: (id: string) => void;
|
||||
}
|
||||
|
||||
type WorkspacePlatform = {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string;
|
||||
};
|
||||
|
||||
function getWorkspacePlatformOptions(workspacePlatforms: WorkspacePlatform[]) {
|
||||
return workspacePlatforms.map((platform) => ({
|
||||
value: platform.slug,
|
||||
label: platform.name,
|
||||
}));
|
||||
}
|
||||
|
||||
const SkeletonLoader = () => {
|
||||
return (
|
||||
<SkeletonContainer>
|
||||
<div className="divide-subtle border-subtle stack-y-6 rounded-b-lg border border-t-0 px-6 py-4">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
</div>
|
||||
</SkeletonContainer>
|
||||
);
|
||||
};
|
||||
|
||||
function DelegationListItemActions({
|
||||
delegation,
|
||||
toggleDelegation,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: {
|
||||
delegation: DelegationItemProps["delegation"];
|
||||
toggleDelegation: DelegationItemProps["toggleDelegation"];
|
||||
onEdit: (delegation: DelegationItemProps["delegation"]) => void;
|
||||
onDelete: (id: string) => void;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Switch checked={delegation.enabled} onCheckedChange={() => toggleDelegation(delegation)} />
|
||||
<DropdownActions
|
||||
actions={[
|
||||
{
|
||||
id: "edit",
|
||||
label: t("edit"),
|
||||
onClick: () => onEdit(delegation),
|
||||
icon: "pencil",
|
||||
},
|
||||
{
|
||||
id: "delete",
|
||||
label: t("delete"),
|
||||
disabled: true,
|
||||
onClick: () => onDelete(delegation.id),
|
||||
icon: "trash",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DelegationListItem({ delegation, toggleDelegation, onEdit, onDelete }: DelegationItemProps) {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<li className="border-subtle bg-default divide-subtle flex flex-col divide-y border">
|
||||
<div className="flex items-center justify-between space-x-2 p-4">
|
||||
<div className="flex flex-col items-start">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span>{delegation.serviceAccountClientId}</span>
|
||||
<InfoBadge content={t("add_client_id_in_google_workspace_with_below_scope")} />
|
||||
</div>
|
||||
<span className="text-muted mt-2">https://www.googleapis.com/auth/calendar</span>
|
||||
<div className="mt-2 flex items-center space-x-2">
|
||||
<Badge variant="default">{delegation.workspacePlatform.name}</Badge>
|
||||
<Badge variant="gray">{delegation.domain}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<DelegationListItemActions
|
||||
delegation={delegation}
|
||||
toggleDelegation={toggleDelegation}
|
||||
onEdit={onEdit}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
type CreateDelegationData = {
|
||||
domain: string;
|
||||
workspacePlatformSlug: string;
|
||||
enabled: boolean;
|
||||
serviceAccountKey: ServiceAccountKey;
|
||||
};
|
||||
|
||||
type CreateDelegationFormData = Omit<CreateDelegationData, "serviceAccountKey"> & {
|
||||
serviceAccountKey: string;
|
||||
};
|
||||
|
||||
type EditDelegationData = {
|
||||
id: string;
|
||||
domain: string;
|
||||
workspacePlatformSlug: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
function CreateDelegationDialog({
|
||||
isOpen,
|
||||
onClose,
|
||||
workspacePlatforms,
|
||||
handleCreate,
|
||||
}: {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
workspacePlatforms: WorkspacePlatform[];
|
||||
handleCreate: (data: CreateDelegationData) => void;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
|
||||
const form = useForm<CreateDelegationFormData>();
|
||||
|
||||
const handleSubmit = (values: CreateDelegationFormData) => {
|
||||
try {
|
||||
const parsedKey = JSON.parse(values.serviceAccountKey);
|
||||
const validatedKey = serviceAccountKeySchema.safeParse(parsedKey);
|
||||
|
||||
if (!validatedKey.success) {
|
||||
form.setError("serviceAccountKey", { message: t("invalid_service_account_key") });
|
||||
return;
|
||||
}
|
||||
|
||||
handleCreate({
|
||||
...values,
|
||||
serviceAccountKey: validatedKey.data,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
form.setError("serviceAccountKey", { message: t("invalid_service_account_key") });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent enableOverflow title={t("add_delegation_credential")}>
|
||||
<Form form={form} handleSubmit={handleSubmit}>
|
||||
<DelegationFormFields workspacePlatforms={workspacePlatforms} isCreate={true} />
|
||||
<DialogFooter>
|
||||
<Button type="button" color="secondary" onClick={onClose}>
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
<Button type="submit">{t("create")}</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function EditDelegationDialog({
|
||||
isOpen,
|
||||
onClose,
|
||||
delegation,
|
||||
workspacePlatforms,
|
||||
handleEdit,
|
||||
}: {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
delegation: DelegationItemProps["delegation"];
|
||||
workspacePlatforms: WorkspacePlatform[];
|
||||
handleEdit: (data: EditDelegationData) => void;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
|
||||
const form = useForm<EditDelegationData>({
|
||||
defaultValues: {
|
||||
id: delegation.id,
|
||||
domain: delegation.domain,
|
||||
workspacePlatformSlug: delegation.workspacePlatform.slug,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent title={t("edit_delegation_credential")}>
|
||||
<Form form={form} handleSubmit={handleEdit}>
|
||||
<DelegationFormFields workspacePlatforms={workspacePlatforms} isCreate={false} />
|
||||
<DialogFooter>
|
||||
<Button type="button" color="secondary" onClick={onClose}>
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
<Button type="submit">{t("update")}</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function DelegationFormFields({
|
||||
workspacePlatforms,
|
||||
isCreate,
|
||||
}: {
|
||||
workspacePlatforms: WorkspacePlatform[];
|
||||
isCreate: boolean;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const form = useFormContext();
|
||||
return (
|
||||
<div className="stack-y-4">
|
||||
<TextField label={t("domain")} {...form.register("domain")} />
|
||||
<Controller
|
||||
name="workspacePlatformSlug"
|
||||
control={form.control}
|
||||
render={({ field: { value, onChange } }) => {
|
||||
const platformOptions = getWorkspacePlatformOptions(workspacePlatforms);
|
||||
const selectedPlatform = platformOptions.find((opt) => opt.value === value);
|
||||
return (
|
||||
<SelectField
|
||||
required
|
||||
label={t("workspace_platform")}
|
||||
onChange={(option) => onChange(option?.value)}
|
||||
value={selectedPlatform}
|
||||
options={platformOptions}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{isCreate && (
|
||||
<TextAreaField
|
||||
required
|
||||
label={t("service_account_key")}
|
||||
placeholder="{...}"
|
||||
{...form.register("serviceAccountKey")}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DelegationCredentialList() {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useContext();
|
||||
const { data: delegations, isLoading, error } = trpc.viewer.delegationCredential.list.useQuery();
|
||||
|
||||
const updateMutation = trpc.viewer.delegationCredential.update.useMutation({
|
||||
onSuccess: () => utils.viewer.delegationCredential.list.invalidate(),
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const toggleEnabledMutation = trpc.viewer.delegationCredential.toggleEnabled.useMutation({
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
showToast(
|
||||
data.enabled ? t("delegation_credential_enabled") : t("delegation_credential_disabled"),
|
||||
"success"
|
||||
);
|
||||
utils.viewer.delegationCredential.list.invalidate();
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const createMutation = trpc.viewer.delegationCredential.add.useMutation({
|
||||
onSuccess: () => utils.viewer.delegationCredential.list.invalidate(),
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const deleteMutation = trpc.viewer.delegationCredential.delete.useMutation({
|
||||
onSuccess: () => utils.viewer.delegationCredential.list.invalidate(),
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const onDelete = (id: string) => {
|
||||
deleteMutation.mutate({ id });
|
||||
};
|
||||
|
||||
const [delegationToToggle, setDelegationToToggle] = useState<DelegationItemProps["delegation"] | null>(
|
||||
null
|
||||
);
|
||||
|
||||
const toggleDelegation = (delegation: DelegationItemProps["delegation"]) => {
|
||||
setDelegationToToggle(delegation);
|
||||
};
|
||||
|
||||
const handleToggleConfirm = () => {
|
||||
if (delegationToToggle) {
|
||||
toggleEnabledMutation.mutate({
|
||||
id: delegationToToggle.id,
|
||||
enabled: !delegationToToggle.enabled,
|
||||
});
|
||||
setDelegationToToggle(null);
|
||||
}
|
||||
};
|
||||
|
||||
const [createEditDialog, setCreateEditDialog] = useState<{
|
||||
isOpen: boolean;
|
||||
delegation: DelegationItemProps["delegation"] | null;
|
||||
}>({
|
||||
isOpen: false,
|
||||
delegation: null,
|
||||
});
|
||||
|
||||
const { data: workspacePlatforms, isLoading: isLoadingWorkspacePlatforms } =
|
||||
trpc.viewer.delegationCredential.listWorkspacePlatforms.useQuery();
|
||||
|
||||
const enabledWorkspacePlatforms = workspacePlatforms?.filter((platform) => platform.enabled) || [];
|
||||
|
||||
const onEditClick = (delegation: DelegationItemProps["delegation"]) => {
|
||||
setCreateEditDialog({ isOpen: true, delegation });
|
||||
};
|
||||
|
||||
const onCreateClick = () => setCreateEditDialog({ isOpen: true, delegation: null });
|
||||
|
||||
const handleCreate = (data: CreateDelegationData) => {
|
||||
createMutation.mutate({
|
||||
domain: data.domain,
|
||||
workspacePlatformSlug: data.workspacePlatformSlug,
|
||||
serviceAccountKey: data.serviceAccountKey,
|
||||
});
|
||||
setCreateEditDialog({ isOpen: false, delegation: null });
|
||||
};
|
||||
|
||||
const handleEdit = (data: EditDelegationData) => {
|
||||
if (!createEditDialog.delegation) {
|
||||
return;
|
||||
}
|
||||
updateMutation.mutate({
|
||||
id: createEditDialog.delegation.id,
|
||||
domain: data.domain,
|
||||
workspacePlatformSlug: data.workspacePlatformSlug,
|
||||
});
|
||||
setCreateEditDialog({ isOpen: false, delegation: null });
|
||||
};
|
||||
|
||||
const AddDwDButton = () => {
|
||||
return (
|
||||
<Button type="button" color="secondary" StartIcon="plus" className="mt-6" onClick={onCreateClick}>
|
||||
{t("add_delegation_credential")}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
if (isLoading || isLoadingWorkspacePlatforms) {
|
||||
return <SkeletonLoader />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <div>{t(error.message)}</div>;
|
||||
}
|
||||
|
||||
if (!delegations || !workspacePlatforms) {
|
||||
return <div>{t("something_went_wrong")}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{delegations?.length ? (
|
||||
<>
|
||||
<ul className="stack-y-2 [&>*:last-child]:rounded-b-xl">
|
||||
{delegations.map(
|
||||
(delegation) =>
|
||||
delegation && (
|
||||
<DelegationListItem
|
||||
key={delegation.id}
|
||||
delegation={delegation}
|
||||
toggleDelegation={toggleDelegation}
|
||||
onEdit={onEditClick}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</ul>
|
||||
{/* Disable till we thoroughly test multiple delegation credentials support */}
|
||||
{/* <AddDwDButton /> */}
|
||||
</>
|
||||
) : (
|
||||
<EmptyScreen
|
||||
Icon="link"
|
||||
headline={t("add_delegation_credential")}
|
||||
description={t("delegation_credential_description")}
|
||||
className="rounded-b-lg rounded-t-none border-t-0"
|
||||
buttonRaw={<AddDwDButton />}
|
||||
/>
|
||||
)}
|
||||
|
||||
{createEditDialog.delegation ? (
|
||||
<EditDelegationDialog
|
||||
isOpen={createEditDialog.isOpen}
|
||||
onClose={() => setCreateEditDialog({ isOpen: false, delegation: null })}
|
||||
delegation={createEditDialog.delegation}
|
||||
workspacePlatforms={enabledWorkspacePlatforms}
|
||||
handleEdit={handleEdit}
|
||||
/>
|
||||
) : (
|
||||
<CreateDelegationDialog
|
||||
isOpen={createEditDialog.isOpen}
|
||||
onClose={() => setCreateEditDialog({ isOpen: false, delegation: null })}
|
||||
workspacePlatforms={enabledWorkspacePlatforms}
|
||||
handleCreate={handleCreate}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ToggleDelegationDialog
|
||||
delegation={delegationToToggle}
|
||||
onClose={() => setDelegationToToggle(null)}
|
||||
onConfirm={handleToggleConfirm}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MembersThatWillBeAffectedOnDisablingDelegationCredential({
|
||||
delegationCredentialId,
|
||||
}: {
|
||||
delegationCredentialId: string;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const { data: affectedMembers, isLoading: isLoadingAffectedMembers } =
|
||||
trpc.viewer.delegationCredential.getAffectedMembersForDisable.useQuery({ id: delegationCredentialId });
|
||||
|
||||
return (
|
||||
<div className="mt-4">
|
||||
<strong>{t("members_affected_by_disabling_delegation_credential")}</strong>
|
||||
{isLoadingAffectedMembers ? (
|
||||
<div>{t("loading")}</div>
|
||||
) : affectedMembers?.length ? (
|
||||
<>
|
||||
<ul className="stack-y-1 list-disc p-1 pl-5 sm:w-80">
|
||||
{affectedMembers.slice(0, 5).map((m) => (
|
||||
<li className="text-muted text-sm" key={m.email}>
|
||||
{m.name ? `${m.name} (${m.email})` : m.email}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{affectedMembers.length > 5 && (
|
||||
<p className="mt-2 text-sm text-gray-500">
|
||||
{t("and_count_more", { count: affectedMembers.length - 5 })}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="mt-2">{t("no_members_affected_by_disabling_delegation_credential")}</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const ToggleDelegationDialog = ({
|
||||
delegation,
|
||||
onConfirm,
|
||||
onClose,
|
||||
}: {
|
||||
delegation: DelegationItemProps["delegation"] | null;
|
||||
onConfirm: () => void;
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
|
||||
if (!delegation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isDisablingDelegation = delegation.enabled;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
name="toggle-delegation"
|
||||
open={!!delegation}
|
||||
onOpenChange={(open) => (!open ? onClose() : undefined)}>
|
||||
<ConfirmationDialogContent
|
||||
title={t(isDisablingDelegation ? "disable_delegation_credential" : "enable_delegation_credential")}
|
||||
confirmBtnText={t(isDisablingDelegation ? "disable" : "enable")}
|
||||
cancelBtnText={t("cancel")}
|
||||
variety={isDisablingDelegation ? "danger" : "success"}
|
||||
onConfirm={onConfirm}>
|
||||
<p className="mt-5">
|
||||
{t(
|
||||
isDisablingDelegation
|
||||
? "disable_delegation_credential_description"
|
||||
: "enable_delegation_credential_description"
|
||||
)}
|
||||
</p>
|
||||
{isDisablingDelegation && (
|
||||
<MembersThatWillBeAffectedOnDisablingDelegationCredential delegationCredentialId={delegation.id} />
|
||||
)}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default function DelegationCredentialListPage() {
|
||||
return <DelegationCredentialList />;
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { TimezoneSelect } from "@calcom/features/components/timezone-select";
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { DisableAutofillOnBookingPageSwitch } from "@calcom/features/ee/organizations/pages/components/DisableAutofillOnBookingPageSwitch";
|
||||
import { DisablePhoneOnlySMSNotificationsSwitch } from "@calcom/features/ee/organizations/pages/components/DisablePhoneOnlySMSNotificationsSwitch";
|
||||
import { LockEventTypeSwitch } from "@calcom/features/ee/organizations/pages/components/LockEventTypeSwitch";
|
||||
import { NoSlotsNotificationSwitch } from "@calcom/features/ee/organizations/pages/components/NoSlotsNotificationSwitch";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { nameOfDay } from "@calcom/lib/weekday";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { Label } from "@calcom/ui/components/form";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
const SkeletonLoader = () => {
|
||||
return (
|
||||
<SkeletonContainer>
|
||||
<div className="stack-y-6 mb-8 mt-6">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
|
||||
<SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
|
||||
</div>
|
||||
</SkeletonContainer>
|
||||
);
|
||||
};
|
||||
|
||||
interface GeneralViewProps {
|
||||
currentOrg: RouterOutputs["viewer"]["organizations"]["listCurrent"];
|
||||
localeProp: string;
|
||||
|
||||
permissions: {
|
||||
canRead: boolean;
|
||||
canEdit: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
const OrgGeneralView = ({
|
||||
permissions,
|
||||
}: {
|
||||
permissions: {
|
||||
canRead: boolean;
|
||||
canEdit: boolean;
|
||||
};
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const session = useSession();
|
||||
|
||||
const {
|
||||
data: currentOrg,
|
||||
isPending,
|
||||
error,
|
||||
} = trpc.viewer.organizations.listCurrent.useQuery(undefined, {});
|
||||
|
||||
useEffect(
|
||||
function refactorMeWithoutEffect() {
|
||||
if (error) {
|
||||
router.replace("/enterprise");
|
||||
}
|
||||
},
|
||||
[error]
|
||||
);
|
||||
|
||||
if (isPending) return <SkeletonLoader />;
|
||||
if (!currentOrg) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<GeneralView
|
||||
currentOrg={currentOrg}
|
||||
localeProp={session.data?.user.locale ?? "en"}
|
||||
permissions={permissions}
|
||||
/>
|
||||
|
||||
{permissions.canEdit && (
|
||||
<>
|
||||
<LockEventTypeSwitch currentOrg={currentOrg} />
|
||||
<NoSlotsNotificationSwitch currentOrg={currentOrg} />
|
||||
<DisablePhoneOnlySMSNotificationsSwitch currentOrg={currentOrg} />
|
||||
<DisableAutofillOnBookingPageSwitch currentOrg={currentOrg} />
|
||||
</>
|
||||
)}
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
|
||||
const GeneralView = ({ currentOrg, permissions, localeProp }: GeneralViewProps) => {
|
||||
const { t } = useLocale();
|
||||
|
||||
const mutation = trpc.viewer.organizations.update.useMutation({
|
||||
onSuccess: async () => {
|
||||
reset(getValues());
|
||||
showToast(t("settings_updated_successfully"), "success");
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_updating_settings"), "error");
|
||||
},
|
||||
});
|
||||
|
||||
const timeFormatOptions = [
|
||||
{ value: 12, label: t("12_hour") },
|
||||
{ value: 24, label: t("24_hour") },
|
||||
];
|
||||
|
||||
const weekStartOptions = [
|
||||
{ value: "Sunday", label: nameOfDay(localeProp, 0) },
|
||||
{ value: "Monday", label: nameOfDay(localeProp, 1) },
|
||||
{ value: "Tuesday", label: nameOfDay(localeProp, 2) },
|
||||
{ value: "Wednesday", label: nameOfDay(localeProp, 3) },
|
||||
{ value: "Thursday", label: nameOfDay(localeProp, 4) },
|
||||
{ value: "Friday", label: nameOfDay(localeProp, 5) },
|
||||
{ value: "Saturday", label: nameOfDay(localeProp, 6) },
|
||||
];
|
||||
|
||||
const formMethods = useForm({
|
||||
defaultValues: {
|
||||
timeZone: currentOrg.timeZone || "",
|
||||
timeFormat: {
|
||||
value: currentOrg.timeFormat || 12,
|
||||
label: timeFormatOptions.find((option) => option.value === currentOrg.timeFormat)?.label || 12,
|
||||
},
|
||||
weekStart: {
|
||||
value: currentOrg.weekStart,
|
||||
label:
|
||||
weekStartOptions.find((option) => option.value === currentOrg.weekStart)?.label ||
|
||||
nameOfDay(localeProp, 0),
|
||||
},
|
||||
},
|
||||
});
|
||||
const {
|
||||
formState: { isDirty, isSubmitting },
|
||||
reset,
|
||||
getValues,
|
||||
} = formMethods;
|
||||
const isDisabled = isSubmitting || !isDirty || !permissions.canEdit;
|
||||
return (
|
||||
<Form
|
||||
form={formMethods}
|
||||
handleSubmit={(values) => {
|
||||
mutation.mutate({
|
||||
...values,
|
||||
timeFormat: values.timeFormat.value,
|
||||
weekStart: values.weekStart.value,
|
||||
});
|
||||
}}>
|
||||
<div
|
||||
className={classNames(
|
||||
"border-subtle border-x border-y-0 px-4 py-8 sm:px-6",
|
||||
!permissions.canEdit && "rounded-b-lg border-y"
|
||||
)}>
|
||||
<Controller
|
||||
name="timeZone"
|
||||
control={formMethods.control}
|
||||
render={({ field: { value } }) => (
|
||||
<>
|
||||
<Label className="text-emphasis">
|
||||
<>{t("timezone")}</>
|
||||
</Label>
|
||||
<TimezoneSelect
|
||||
id="timezone"
|
||||
value={value}
|
||||
onChange={(event) => {
|
||||
if (event) formMethods.setValue("timeZone", event.value, { shouldDirty: true });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="timeFormat"
|
||||
control={formMethods.control}
|
||||
render={({ field: { value } }) => (
|
||||
<>
|
||||
<Label className="text-emphasis mt-6">
|
||||
<>{t("time_format")}</>
|
||||
</Label>
|
||||
<Select
|
||||
value={value}
|
||||
options={timeFormatOptions}
|
||||
onChange={(event) => {
|
||||
if (event) formMethods.setValue("timeFormat", { ...event }, { shouldDirty: true });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<div className="text-gray text-default mt-2 flex items-center text-sm">
|
||||
{t("timeformat_profile_hint")}
|
||||
</div>
|
||||
<Controller
|
||||
name="weekStart"
|
||||
control={formMethods.control}
|
||||
render={({ field: { value } }) => (
|
||||
<>
|
||||
<Label className="text-emphasis mt-6">
|
||||
<>{t("start_of_week")}</>
|
||||
</Label>
|
||||
<Select
|
||||
value={value}
|
||||
options={weekStartOptions}
|
||||
onChange={(event) => {
|
||||
if (event) formMethods.setValue("weekStart", { ...event }, { shouldDirty: true });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{permissions?.canEdit && (
|
||||
<SectionBottomActions align="end">
|
||||
<Button disabled={isDisabled} color="primary" type="submit">
|
||||
{t("update")}
|
||||
</Button>
|
||||
</SectionBottomActions>
|
||||
)}
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgGeneralView;
|
||||
@@ -0,0 +1,65 @@
|
||||
"use client";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { SkeletonContainer, SkeletonText, SkeletonButton } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import DisableGuestBookingEmailsSetting from "@calcom/features/ee/organizations/pages/components/DisableGuestBookingEmailsSetting";
|
||||
|
||||
const SkeletonLoader = () => {
|
||||
return (
|
||||
<SkeletonContainer>
|
||||
<div className="mb-8 mt-6 space-y-6">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
|
||||
</div>
|
||||
</SkeletonContainer>
|
||||
);
|
||||
};
|
||||
|
||||
const GuestNotificationsView = ({ permissions }: { permissions: { canRead: boolean; canEdit: boolean } }) => {
|
||||
const { data: currentOrg, isPending } = trpc.viewer.organizations.listCurrent.useQuery();
|
||||
const isInviteOpen = !currentOrg?.user.accepted;
|
||||
const isDisabled = !permissions.canEdit || isInviteOpen;
|
||||
|
||||
if (isPending) return <SkeletonLoader />;
|
||||
|
||||
if (!currentOrg) return null;
|
||||
|
||||
if (!currentOrg.organizationSettings) return null;
|
||||
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<div className="space-y-8">
|
||||
<DisableGuestBookingEmailsSetting
|
||||
orgId={currentOrg.id}
|
||||
settings={{
|
||||
disableAttendeeConfirmationEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeConfirmationEmail ?? false,
|
||||
disableAttendeeCancellationEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeCancellationEmail ?? false,
|
||||
disableAttendeeRescheduledEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeRescheduledEmail ?? false,
|
||||
disableAttendeeRequestEmail: currentOrg.organizationSettings.disableAttendeeRequestEmail ?? false,
|
||||
disableAttendeeReassignedEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeReassignedEmail ?? false,
|
||||
disableAttendeeAwaitingPaymentEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeAwaitingPaymentEmail ?? false,
|
||||
disableAttendeeRescheduleRequestEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeRescheduleRequestEmail ?? false,
|
||||
disableAttendeeLocationChangeEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeLocationChangeEmail ?? false,
|
||||
disableAttendeeNewEventEmail:
|
||||
currentOrg.organizationSettings.disableAttendeeNewEventEmail ?? false,
|
||||
}}
|
||||
readOnly={isDisabled}
|
||||
/>
|
||||
</div>
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
|
||||
export default GuestNotificationsView;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 374 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user