chore: App router migration - general settings (#16312)
* added lockedSMS to future routes * add orgMigrations routes to future * correct metadata * small fix * add orgMigrations to future * Move components to client components * Remove tRPC element from edit user RSC * Get username for meta * Remove suspense query * Remove orgMigrations from app router * Type fix * Revert "Remove suspense query" This reverts commit eadd814f6e4a5d6856d9218342b7909c22fe62c6. * Handle suspenseQuery in app router * User edit page, fetch data server side * Update yarn.lock * Export getFixedT * Set PageWrapper as root layout for settings * Settings Layout accepts strings for shell heading * Add OOO to app router settings * Refactor layout for my-account pages * Remove instances of pages router from my-account * Refactor security pages * Add billing to app router * Add admin API link to layout * Add api keys page * Webhooks WIP * Refactor SettingsHeader to client component * Add webhook pages * Refactor API keys page * Add admin app page * Type fix * fix types * fix developer/webhooks/[id] param value type error * remove unnecessary code * do not pass t prop to CreateNewWebhookButton * fix type errors in webhook-edit-view * fix the remaining type errors * do not use prisma directly in generateMetadata * remove use client if unnecessary * Remove unused shell heading from SettingsLayoutAppDir * improve metadata * fix billing page * fix import in settings/teams * Use next `notFound()` * fix type check * fix type check * remove unused code * Fix calendar setting page * Separate settings pages into route groups * Refactor admin settings pages * Remove meta instance from billing page route * Update settings layoutAppDir * Refactor developer settings pages * Refactor out of office * Refactor my account settings * Refactor admin api page * Refactor security pages * Type fix * fix styling in settings layout --------- Co-authored-by: Somay Chauhan <[email protected]> Co-authored-by: Omar López <[email protected]> Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
187 files changed
+4628
-3586
No files matched your search
@@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import type { AriaRole, ComponentType } from "react";
|
||||
import React, { Fragment, useEffect } from "react";
|
||||
@@ -70,9 +72,11 @@ export const withLicenseRequired =
|
||||
// eslint-disable-next-line react/display-name
|
||||
(hocProps: T) =>
|
||||
(
|
||||
<LicenseRequired>
|
||||
<Component {...hocProps} />
|
||||
</LicenseRequired>
|
||||
<div>
|
||||
<LicenseRequired>
|
||||
<Component {...hocProps} />
|
||||
</LicenseRequired>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default LicenseRequired;
|
||||
@@ -1,12 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
|
||||
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
|
||||
import { UpgradeTip } from "@calcom/features/tips";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button, Icon, Meta, ButtonGroup } from "@calcom/ui";
|
||||
import { Button, Icon, ButtonGroup } from "@calcom/ui";
|
||||
|
||||
const AdminAPIViewWrapper = () => {
|
||||
export const AdminAPIView = () => {
|
||||
const { t } = useLocale();
|
||||
|
||||
const features = [
|
||||
@@ -28,11 +27,6 @@ const AdminAPIViewWrapper = () => {
|
||||
];
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<Meta
|
||||
title={`${t("admin")} ${t("api_reference")}`}
|
||||
description={t("leverage_our_api")}
|
||||
borderInShellHeader={false}
|
||||
/>
|
||||
<div className="mt-8">
|
||||
<UpgradeTip
|
||||
plan="enterprise"
|
||||
@@ -59,6 +53,4 @@ const AdminAPIViewWrapper = () => {
|
||||
);
|
||||
};
|
||||
|
||||
AdminAPIViewWrapper.getLayout = getLayout;
|
||||
|
||||
export default AdminAPIViewWrapper;
|
||||
export default AdminAPIView;
|
||||
@@ -1,44 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import type { Team } from "@prisma/client";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import type { z } from "zod";
|
||||
|
||||
import NoSSR from "@calcom/core/components/NoSSR";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
|
||||
import type { orgSettingsSchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button, Form, Meta, TextField, showToast } from "@calcom/ui";
|
||||
|
||||
import { getLayout } from "../../../../../settings/layouts/SettingsLayout";
|
||||
import LicenseRequired from "../../../../common/components/LicenseRequired";
|
||||
|
||||
const paramsSchema = z.object({ id: z.coerce.number() });
|
||||
|
||||
const OrgEditPage = () => {
|
||||
const params = useParamsWithFallback();
|
||||
const parsedParams = paramsSchema.safeParse(params);
|
||||
|
||||
if (!parsedParams.success) return <div>Invalid id</div>;
|
||||
|
||||
return <OrgEditView orgId={parsedParams.data.id} />;
|
||||
};
|
||||
|
||||
const OrgEditView = ({ orgId }: { orgId: number }) => {
|
||||
const [org] = trpc.viewer.organizations.adminGet.useSuspenseQuery({ id: orgId });
|
||||
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<Meta
|
||||
title={`Editing organization: ${org.name}`}
|
||||
description="Here you can edit a current organization."
|
||||
/>
|
||||
<NoSSR>
|
||||
<OrgForm org={org} />
|
||||
</NoSSR>
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
import { Button, Form, TextField, showToast } from "@calcom/ui";
|
||||
|
||||
type FormValues = {
|
||||
name: Team["name"];
|
||||
@@ -46,7 +16,7 @@ type FormValues = {
|
||||
organizationSettings: z.infer<typeof orgSettingsSchema>;
|
||||
};
|
||||
|
||||
const OrgForm = ({
|
||||
export const OrgForm = ({
|
||||
org,
|
||||
}: {
|
||||
org: FormValues & {
|
||||
@@ -108,6 +78,4 @@ const OrgForm = ({
|
||||
);
|
||||
};
|
||||
|
||||
OrgEditPage.getLayout = getLayout;
|
||||
|
||||
export default OrgEditPage;
|
||||
export default OrgForm;
|
||||
@@ -3,39 +3,18 @@
|
||||
import { Trans } from "next-i18next";
|
||||
import { useState } from "react";
|
||||
|
||||
import NoSSR from "@calcom/core/components/NoSSR";
|
||||
import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import {
|
||||
Badge,
|
||||
ConfirmationDialogContent,
|
||||
Dialog,
|
||||
DropdownActions,
|
||||
Meta,
|
||||
showToast,
|
||||
Table,
|
||||
} from "@calcom/ui";
|
||||
import { Badge, ConfirmationDialogContent, Dialog, DropdownActions, showToast, Table } from "@calcom/ui";
|
||||
|
||||
import { getLayout } from "../../../../../settings/layouts/SettingsLayout";
|
||||
import { subdomainSuffix } from "../../../../organizations/lib/orgDomains";
|
||||
|
||||
const { Body, Cell, ColumnTitle, Header, Row } = Table;
|
||||
|
||||
function AdminOrgTable() {
|
||||
export function AdminOrgTable() {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
const [data] = trpc.viewer.organizations.adminGetAll.useSuspenseQuery();
|
||||
const verifyMutation = trpc.viewer.organizations.adminVerify.useMutation({
|
||||
onSuccess: async (_data, variables) => {
|
||||
showToast(t("org_has_been_processed"), "success");
|
||||
await invalidateQueries(utils, variables);
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error(err.message);
|
||||
showToast(t("org_error_processing"), "error");
|
||||
},
|
||||
});
|
||||
const updateMutation = trpc.viewer.organizations.adminUpdate.useMutation({
|
||||
onSuccess: async (_data, variables) => {
|
||||
showToast(t("org_has_been_processed"), "success");
|
||||
@@ -240,21 +219,7 @@ function AdminOrgTable() {
|
||||
);
|
||||
}
|
||||
|
||||
const AdminOrgList = () => {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<Meta title={t("organizations")} description={t("orgs_page_description")} />
|
||||
<NoSSR>
|
||||
<AdminOrgTable />
|
||||
</NoSSR>
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
|
||||
AdminOrgList.getLayout = getLayout;
|
||||
|
||||
export default AdminOrgList;
|
||||
export default AdminOrgTable;
|
||||
|
||||
const DeleteOrgDialog = ({
|
||||
org,
|
||||
|
||||
@@ -5,9 +5,7 @@ import { useEffect } from "react";
|
||||
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Meta } from "@calcom/ui";
|
||||
|
||||
import { getLayout } from "../../../settings/layouts/SettingsLayout";
|
||||
import SSOConfiguration from "../components/SSOConfiguration";
|
||||
|
||||
const SAMLSSO = () => {
|
||||
@@ -22,16 +20,9 @@ const SAMLSSO = () => {
|
||||
|
||||
return (
|
||||
<div className="bg-default w-full sm:mx-0">
|
||||
<Meta
|
||||
title={t("sso_configuration")}
|
||||
description={t("sso_configuration_description")}
|
||||
borderInShellHeader={true}
|
||||
/>
|
||||
<SSOConfiguration teamId={null} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
SAMLSSO.getLayout = getLayout;
|
||||
|
||||
export default SAMLSSO;
|
||||
@@ -150,7 +150,7 @@ function UsersTableBare() {
|
||||
const [userToDelete, setUserToDelete] = useState<number | null>(null);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<TextField
|
||||
placeholder="username or email"
|
||||
label="Search"
|
||||
@@ -293,7 +293,7 @@ function UsersTableBare() {
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ import { usePathname, useRouter } from "next/navigation";
|
||||
|
||||
import { getParserWithGeneric } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Meta, showToast } from "@calcom/ui";
|
||||
import { showToast } from "@calcom/ui";
|
||||
|
||||
import { getLayout } from "../../../settings/layouts/SettingsLayout";
|
||||
import LicenseRequired from "../../common/components/LicenseRequired";
|
||||
import { UserForm } from "../components/UserForm";
|
||||
import { userBodySchema } from "../schemas/userBodySchema";
|
||||
@@ -30,20 +29,19 @@ const UsersAddView = () => {
|
||||
},
|
||||
});
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<Meta title="Add new user" description="Here you can add a new user." />
|
||||
<UserForm
|
||||
submitLabel="Add user"
|
||||
onSubmit={async (values) => {
|
||||
const parser = getParserWithGeneric(userBodySchema);
|
||||
const parsedValues = parser(values);
|
||||
mutation.mutate(parsedValues);
|
||||
}}
|
||||
/>
|
||||
</LicenseRequired>
|
||||
<div>
|
||||
<LicenseRequired>
|
||||
<UserForm
|
||||
submitLabel="Add user"
|
||||
onSubmit={async (values) => {
|
||||
const parser = getParserWithGeneric(userBodySchema);
|
||||
const parsedValues = parser(values);
|
||||
mutation.mutate(parsedValues);
|
||||
}}
|
||||
/>
|
||||
</LicenseRequired>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
UsersAddView.getLayout = getLayout;
|
||||
|
||||
export default UsersAddView;
|
||||
@@ -7,13 +7,14 @@ import NoSSR from "@calcom/core/components/NoSSR";
|
||||
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
|
||||
import { getParserWithGeneric } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Meta, showToast } from "@calcom/ui";
|
||||
import { showToast } from "@calcom/ui";
|
||||
|
||||
import { getLayout } from "../../../settings/layouts/SettingsLayout";
|
||||
import LicenseRequired from "../../common/components/LicenseRequired";
|
||||
import { UserForm } from "../components/UserForm";
|
||||
import { userBodySchema } from "../schemas/userBodySchema";
|
||||
import type { UserAdminRouterOutputs } from "../server/trpc-router";
|
||||
|
||||
type User = UserAdminRouterOutputs["get"]["user"];
|
||||
const userIdSchema = z.object({ id: z.coerce.number() });
|
||||
|
||||
const UsersEditPage = () => {
|
||||
@@ -22,14 +23,22 @@ const UsersEditPage = () => {
|
||||
|
||||
if (!input.success) return <div>Invalid input</div>;
|
||||
|
||||
return <UsersEditView userId={input.data.id} />;
|
||||
const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId: input.data.id });
|
||||
const { user } = data;
|
||||
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<NoSSR>
|
||||
<UsersEditView user={user} />
|
||||
</NoSSR>
|
||||
</LicenseRequired>
|
||||
);
|
||||
};
|
||||
|
||||
const UsersEditView = ({ userId }: { userId: number }) => {
|
||||
export const UsersEditView = ({ user }: { user: User }) => {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId });
|
||||
const { user } = data;
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
const mutation = trpc.viewer.users.update.useMutation({
|
||||
onSuccess: async () => {
|
||||
@@ -43,29 +52,22 @@ const UsersEditView = ({ userId }: { userId: number }) => {
|
||||
},
|
||||
});
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<Meta title={`Editing user: ${user.username}`} description="Here you can edit a current user." />
|
||||
<NoSSR>
|
||||
<UserForm
|
||||
key={JSON.stringify(user)}
|
||||
onSubmit={(values) => {
|
||||
const parser = getParserWithGeneric(userBodySchema);
|
||||
const parsedValues = parser(values);
|
||||
const data: Partial<typeof parsedValues & { userId: number }> = {
|
||||
...parsedValues,
|
||||
userId: user.id,
|
||||
};
|
||||
// Don't send username if it's the same as the current one
|
||||
if (user.username === data.username) delete data.username;
|
||||
mutation.mutate(data);
|
||||
}}
|
||||
defaultValues={user}
|
||||
/>
|
||||
</NoSSR>
|
||||
</LicenseRequired>
|
||||
<UserForm
|
||||
key={JSON.stringify(user)}
|
||||
onSubmit={(values) => {
|
||||
const parser = getParserWithGeneric(userBodySchema);
|
||||
const parsedValues = parser(values);
|
||||
const data: Partial<typeof parsedValues & { userId: number }> = {
|
||||
...parsedValues,
|
||||
userId: user.id,
|
||||
};
|
||||
// Don't send username if it's the same as the current one
|
||||
if (user.username === data.username) delete data.username;
|
||||
mutation.mutate(data);
|
||||
}}
|
||||
defaultValues={user}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
UsersEditPage.getLayout = getLayout;
|
||||
|
||||
export default UsersEditPage;
|
||||
export default UsersEditView;
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import NoSSR from "@calcom/core/components/NoSSR";
|
||||
import { Button, Meta } from "@calcom/ui";
|
||||
|
||||
import { getLayout } from "../../../settings/layouts/SettingsLayout";
|
||||
import { UsersTable } from "../components/UsersTable";
|
||||
@@ -9,17 +8,6 @@ import { UsersTable } from "../components/UsersTable";
|
||||
const DeploymentUsersListPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Meta
|
||||
title="Users"
|
||||
description="A list of all the users in your account including their name, title, email and role."
|
||||
CTA={
|
||||
<div className="mt-4 space-x-5 sm:ml-16 sm:mt-0 sm:flex-none">
|
||||
{/* TODO: Add import users functionality */}
|
||||
{/* <Button disabled>Import users</Button> */}
|
||||
<Button href="/settings/admin/users/add">Add user</Button>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<NoSSR>
|
||||
<UsersTable />
|
||||
</NoSSR>
|
||||
|
||||
Reference in new issue
Block a user