From 0872fd61330c7a2b1a12909f5826b996d235381a Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:31:08 +0530 Subject: [PATCH] chore: remove personal branding if in an org and use org branding (#14872) * chore: remove personal branding if in an org and use org branding * fix: minor fix * Update SettingsLayout.tsx * Update SettingsLayout.tsx * Update profile.tsx --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> --- .../pages/settings/my-account/appearance.tsx | 8 +- .../pages/settings/appearance.tsx | 203 ++++++------------ .../organizations/pages/settings/profile.tsx | 46 +++- .../settings/layouts/SettingsLayout.tsx | 9 +- 4 files changed, 127 insertions(+), 139 deletions(-) diff --git a/apps/web/pages/settings/my-account/appearance.tsx b/apps/web/pages/settings/my-account/appearance.tsx index 53bde759cfcf37..8cacf45526cc2d 100644 --- a/apps/web/pages/settings/my-account/appearance.tsx +++ b/apps/web/pages/settings/my-account/appearance.tsx @@ -1,5 +1,7 @@ "use client"; +import { useSession } from "next-auth/react"; +import { useRouter } from "next/navigation"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; import type { z } from "zod"; @@ -430,7 +432,11 @@ const AppearanceView = ({ const AppearanceViewWrapper = () => { const { data: user, isPending } = trpc.viewer.me.useQuery(); const { isPending: isTeamPlanStatusLoading, hasPaidPlan } = useHasPaidPlan(); - + const session = useSession(); + const router = useRouter(); + if (!!session.data?.user?.org?.id) { + router.replace("/settings/organizations/profile"); + } const { t } = useLocale(); if (isPending || isTeamPlanStatusLoading || !user) diff --git a/packages/features/ee/organizations/pages/settings/appearance.tsx b/packages/features/ee/organizations/pages/settings/appearance.tsx index ec1d536e934095..93ec42807d265f 100644 --- a/packages/features/ee/organizations/pages/settings/appearance.tsx +++ b/packages/features/ee/organizations/pages/settings/appearance.tsx @@ -5,20 +5,17 @@ import { useRouter } from "next/navigation"; import { useState, useEffect } from "react"; import { useForm } from "react-hook-form"; -import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; 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 { getLayout } from "@calcom/features/settings/layouts/SettingsLayout"; 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 { MembershipRole } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; import type { RouterOutputs } from "@calcom/trpc/react"; -import { Button, Form, Meta, showToast, SettingsToggle, Avatar, ImageUploader } from "@calcom/ui"; -import { Icon } from "@calcom/ui"; +import { Button, Form, showToast, SettingsToggle } from "@calcom/ui"; type BrandColorsFormValues = { brandColor: string; @@ -27,7 +24,6 @@ type BrandColorsFormValues = { const OrgAppearanceView = ({ currentOrg, - isAdminOrOwner, }: { currentOrg: RouterOutputs["viewer"]["organizations"]["listCurrent"]; isAdminOrOwner: boolean; @@ -79,134 +75,79 @@ const OrgAppearanceView = ({ }; return ( - - - {isAdminOrOwner ? ( -
-
-
- } - size="lg" - /> -
-
- { - mutation.mutate({ - calVideoLogo: newLogo, - }); - }} - disabled={mutation.isPending} - imageSrc={currentOrg?.calVideoLogo ?? undefined} - uploadInstruction={t("cal_video_logo_upload_instruction")} - triggerButtonColor={currentOrg?.calVideoLogo ? "secondary" : "primary"} - /> - {currentOrg?.calVideoLogo && ( - - )} -
-
-
+
+
{ + mutation.mutate({ + theme: value.theme ?? null, + }); + }}> +
+
+

{t("theme")}

+

{t("theme_applies_note")}

- { - mutation.mutate({ - theme: value.theme ?? null, - }); - }}> -
-
-

{t("theme")}

-

{t("theme_applies_note")}

-
-
-
- - - -
- - - - - -
{ - onBrandColorsFormSubmit(values); - }}> - - - - { - setHideBrandingValue(checked); - mutation.mutate({ hideBranding: checked }); - }} - switchContainerClassName="mt-6" - />
- ) : ( -
- {t("only_owner_change")} +
+ + +
- )} - + + + + + +
{ + onBrandColorsFormSubmit(values); + }}> + + + + { + setHideBrandingValue(checked); + mutation.mutate({ hideBranding: checked }); + }} + switchContainerClassName="mt-6" + /> +
); }; @@ -237,6 +178,4 @@ const OrgAppearanceViewWrapper = () => { return ; }; -OrgAppearanceViewWrapper.getLayout = getLayout; - export default OrgAppearanceViewWrapper; diff --git a/packages/features/ee/organizations/pages/settings/profile.tsx b/packages/features/ee/organizations/pages/settings/profile.tsx index 1a24b25b231227..e5cfa322c1a19e 100644 --- a/packages/features/ee/organizations/pages/settings/profile.tsx +++ b/packages/features/ee/organizations/pages/settings/profile.tsx @@ -9,6 +9,7 @@ import { z } from "zod"; import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; import { subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains"; +import OrgAppearanceViewWrapper from "@calcom/features/ee/organizations/pages/settings/appearance"; import SectionBottomActions from "@calcom/features/settings/SectionBottomActions"; import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -16,6 +17,7 @@ import { md } from "@calcom/lib/markdownIt"; import turndown from "@calcom/lib/turndownService"; import { MembershipRole } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; +import { Icon } from "@calcom/ui"; import { Avatar, BannerUploader, @@ -125,7 +127,10 @@ const OrgProfileView = () => { <> {isOrgAdminOrOwner ? ( - + <> + + + ) : (
@@ -165,6 +170,7 @@ const OrgProfileForm = ({ defaultValues }: { defaultValues: FormValues }) => { const utils = trpc.useUtils(); const { t } = useLocale(); const [firstRender, setFirstRender] = useState(true); + const { data: currentOrg } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {}); const form = useForm({ defaultValues, @@ -288,6 +294,44 @@ const OrgProfileForm = ({ defaultValues }: { defaultValues: FormValues }) => { }} />
+
+ } + size="lg" + /> +
+
+ { + mutation.mutate({ + calVideoLogo: newLogo, + }); + }} + disabled={mutation.isPending} + imageSrc={currentOrg?.calVideoLogo ?? undefined} + uploadInstruction={t("cal_video_logo_upload_instruction")} + triggerButtonColor={currentOrg?.calVideoLogo ? "secondary" : "primary"} + /> + {currentOrg?.calVideoLogo && ( + + )} +
+
+
{ // The following keys are assigned to admin only const adminRequiredKeys = ["admin"]; const organizationRequiredKeys = ["organization"]; -const organizationAdminKeys = ["privacy", "appearance", "billing", "OAuth Clients", "SSO", "directory_sync"]; +const organizationAdminKeys = ["privacy", "billing", "OAuth Clients", "SSO", "directory_sync"]; const useTabs = () => { const session = useSession(); @@ -161,6 +157,9 @@ const useTabs = () => { const processTabsMemod = useMemo(() => { const processedTabs = tabs.map((tab) => { if (tab.href === "/settings/my-account") { + if (!!session.data?.user?.org?.id) { + tab.children = tab?.children?.filter((child) => child.href !== "/settings/my-account/appearance"); + } return { ...tab, name: user?.name || "my_account",