From 6197ae25c6c323675624bf5c5e1bbb59e720fd8b Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Tue, 26 Apr 2022 05:20:13 +0100 Subject: [PATCH 01/53] Fix providerName (#2589) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Omar López --- apps/web/lib/emails/templates/attendee-scheduled-email.ts | 3 ++- apps/web/lib/emails/templates/organizer-scheduled-email.ts | 2 +- packages/app-store/utils.ts | 4 ++-- .../app-store/wipemycalother/lib/templates/base-template.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/web/lib/emails/templates/attendee-scheduled-email.ts b/apps/web/lib/emails/templates/attendee-scheduled-email.ts index 96586c6709..1a4c045bb8 100644 --- a/apps/web/lib/emails/templates/attendee-scheduled-email.ts +++ b/apps/web/lib/emails/templates/attendee-scheduled-email.ts @@ -320,7 +320,8 @@ ${getRichDescription(this.calEvent)} } protected getLocation(): string { - let providerName = this.calEvent.location ? getAppName(this.calEvent.location) : ""; + let providerName = this.calEvent.location && getAppName(this.calEvent.location); + if (this.calEvent.location && this.calEvent.location.includes("integrations:")) { const location = this.calEvent.location.split(":")[1]; providerName = location[0].toUpperCase() + location.slice(1); diff --git a/apps/web/lib/emails/templates/organizer-scheduled-email.ts b/apps/web/lib/emails/templates/organizer-scheduled-email.ts index d16e5462e0..5d8719243d 100644 --- a/apps/web/lib/emails/templates/organizer-scheduled-email.ts +++ b/apps/web/lib/emails/templates/organizer-scheduled-email.ts @@ -313,7 +313,7 @@ ${getRichDescription(this.calEvent)} } protected getLocation(): string { - let providerName = this.calEvent.location ? getAppName(this.calEvent.location) : ""; + let providerName = this.calEvent.location && getAppName(this.calEvent.location); // This returns null if nothing is found if (this.calEvent.location && this.calEvent.location.includes("integrations:")) { const location = this.calEvent.location.split(":")[1]; diff --git a/packages/app-store/utils.ts b/packages/app-store/utils.ts index ed61dde2f2..ae27fd659b 100644 --- a/packages/app-store/utils.ts +++ b/packages/app-store/utils.ts @@ -128,8 +128,8 @@ export function getLocationLabels(t: TFunction) { }, defaultLocationLabels); } -export function getAppName(name: string) { - return ALL_APPS_MAP[name as keyof typeof ALL_APPS_MAP]?.name || "No App Name"; +export function getAppName(name: string): string | null { + return ALL_APPS_MAP[name as keyof typeof ALL_APPS_MAP]?.name ?? null; } export function getAppType(name: string): string { diff --git a/packages/app-store/wipemycalother/lib/templates/base-template.ts b/packages/app-store/wipemycalother/lib/templates/base-template.ts index cf0479bcf8..fe48304c72 100644 --- a/packages/app-store/wipemycalother/lib/templates/base-template.ts +++ b/packages/app-store/wipemycalother/lib/templates/base-template.ts @@ -313,7 +313,7 @@ ${getRichDescription(this.calEvent)} } protected getLocation(): string { - let providerName = this.calEvent.location ? getAppName(this.calEvent.location) : ""; + let providerName = this.calEvent.location && getAppName(this.calEvent.location); if (this.calEvent.location && this.calEvent.location.includes("integrations:")) { const location = this.calEvent.location.split(":")[1]; From 1421b9c0af16acb68607427fb976fcdb87bd236c Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Tue, 26 Apr 2022 09:48:17 +0100 Subject: [PATCH 02/53] Feat/impersonate users (#2503) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: zomars --- apps/web/components/NavTabs.tsx | 57 ++++++++------- apps/web/components/SettingsShell.tsx | 12 ++- apps/web/components/Shell.tsx | 5 +- apps/web/components/ui/AdminRequired.tsx | 14 ++++ .../web/components/ui/ImpersonatingBanner.tsx | 34 +++++++++ .../impersonation/ImpersonationProvider.ts | 62 ++++++++++++++++ apps/web/pages/api/auth/[...nextauth].tsx | 13 +++- apps/web/pages/settings/admin.tsx | 73 +++++++++++++++++++ apps/web/public/static/locales/en/common.json | 6 +- packages/embeds/embed-react/tsconfig.json | 2 +- .../migration.sql | 21 ++++++ packages/prisma/schema.prisma | 17 +++++ packages/types/next-auth.d.ts | 3 + 13 files changed, 285 insertions(+), 34 deletions(-) create mode 100644 apps/web/components/ui/AdminRequired.tsx create mode 100644 apps/web/components/ui/ImpersonatingBanner.tsx create mode 100644 apps/web/ee/lib/impersonation/ImpersonationProvider.ts create mode 100644 apps/web/pages/settings/admin.tsx create mode 100644 packages/prisma/migrations/20220409155714_impersonate_users/migration.sql diff --git a/apps/web/components/NavTabs.tsx b/apps/web/components/NavTabs.tsx index b0946f0442..373f8830f9 100644 --- a/apps/web/components/NavTabs.tsx +++ b/apps/web/components/NavTabs.tsx @@ -1,49 +1,52 @@ +import { AdminRequired } from "components/ui/AdminRequired"; import Link, { LinkProps } from "next/link"; import { useRouter } from "next/router"; -import React, { ElementType, FC } from "react"; +import React, { ElementType, FC, Fragment } from "react"; import classNames from "@lib/classNames"; -interface Props { +export interface NavTabProps { tabs: { name: string; href: string; icon?: ElementType; + adminRequired?: boolean; }[]; linkProps?: Omit; } -const NavTabs: FC = ({ tabs, linkProps }) => { +const NavTabs: FC = ({ tabs, linkProps }) => { const router = useRouter(); return ( <> -