Skip to content

Scheduling infrastructure for absolutely everyone.

fix: setting sidebar improvements (#6177)

Udit Takkar469c20503318
diff --git a/packages/ui/v2/core/layouts/SettingsLayout.tsx b/packages/ui/v2/core/layouts/SettingsLayout.tsx
index a92c386a363..a2ba848e797 100644
--- a/packages/ui/v2/core/layouts/SettingsLayout.tsx
+++ b/packages/ui/v2/core/layouts/SettingsLayout.tsx
@@ -10,6 +10,7 @@ import { HOSTED_CAL_FEATURES, WEBAPP_URL } from "@calcom/lib/constants";
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
+import { Skeleton } from "@calcom/ui";
import { Badge, Button, ErrorBoundary, Icon } from "../../..";
import { useMeta } from "../Meta";
@@ -93,6 +94,16 @@ const useTabs = () => {
const session = useSession();
const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
+
+ tabs.map((tab) => {
+ if (tab.name === "my_account") {
+ tab.name = session.data?.user?.name || "my_account";
+ tab.icon = undefined;
+ tab.avatar = WEBAPP_URL + "/" + session.data?.user?.username + "/avatar.png";
+ }
+ return tab;
+ });
+
// check if name is in adminRequiredKeys
return tabs.filter((tab) => {
if (isAdmin) return true;
@@ -100,6 +111,22 @@ const useTabs = () => {
});
};
+const BackButtonInSidebar = ({ name }: { name: string }) => {
+ return (
+ <Link href="/.">
+ <a
+ target="_self"
+ className="group my-6 flex h-6 max-h-6 w-64 flex-row items-center rounded-md py-2 px-3 text-sm font-medium leading-4 text-black hover:bg-gray-100 group-hover:text-gray-700 [&[aria-current='page']]:bg-gray-200 [&[aria-current='page']]:text-gray-900"
+ data-testid={`vertical-tab-${name}`}>
+ <Icon.FiArrowLeft className="mr-[10px] h-4 w-4 stroke-[2px] md:mt-0" />
+ <Skeleton title={name} as="p" className="max-w-36 min-h-4 truncate">
+ {name}
+ </Skeleton>
+ </a>
+ </Link>
+ );
+};
+
interface SettingsSidebarContainerProps {
className?: string;
navigationIsOpenedOnMobile?: boolean;
@@ -136,7 +163,7 @@ const SettingsSidebarContainer = ({
return (
<nav
className={classNames(
- "no-scrollbar fixed left-0 top-0 z-10 flex max-h-screen w-56 flex-col space-y-1 overflow-x-hidden overflow-y-scroll bg-gray-50 py-3 px-2 transition-transform lg:sticky lg:flex",
+ "no-scrollbar fixed left-0 top-0 z-10 flex max-h-screen w-56 flex-col space-y-1 overflow-x-hidden overflow-y-scroll bg-gray-50 px-2 pb-3 transition-transform lg:sticky lg:flex",
className,
navigationIsOpenedOnMobile
? "translate-x-0 opacity-100"
@@ -144,13 +171,7 @@ const SettingsSidebarContainer = ({
)}
aria-label="Tabs">
<>
- <div className="desktop-only pt-4" />
- <VerticalTabItem
- name={t("back")}
- href="/."
- icon={Icon.FiArrowLeft}
- textClassNames="text-md font-medium leading-none text-black"
- />
+ <BackButtonInSidebar name={t("back")} />
{tabsWithPermissions.map((tab) => {
return tab.name !== "teams" ? (
<React.Fragment key={tab.href}>
@@ -159,6 +180,9 @@ const SettingsSidebarContainer = ({
{tab && tab.icon && (
<tab.icon className="mr-[12px] h-[16px] w-[16px] stroke-[2px] md:mt-0" />
)}
+ {!tab.icon && tab?.avatar && (
+ <img className="mr-3 h-4 w-4 rounded-full" src={tab?.avatar} alt="User Avatar" />
+ )}
<p className="text-sm font-medium leading-5">{t(tab.name)}</p>
</div>
</div>
diff --git a/packages/ui/v2/core/navigation/tabs/VerticalTabItem.tsx b/packages/ui/v2/core/navigation/tabs/VerticalTabItem.tsx
index 348185df1da..9bdad65fc5f 100644
--- a/packages/ui/v2/core/navigation/tabs/VerticalTabItem.tsx
+++ b/packages/ui/v2/core/navigation/tabs/VerticalTabItem.tsx
@@ -23,6 +23,7 @@ export type VerticalTabItemProps = {
href: string;
isExternalLink?: boolean;
linkProps?: Omit<ComponentProps<typeof Link>, "href">;
+ avatar?: string;
};
const VerticalTabItem = function ({
@@ -47,7 +48,7 @@ const VerticalTabItem = function ({
target={props.isExternalLink ? "_blank" : "_self"}
className={classNames(
props.textClassNames || "text-sm font-medium leading-none text-gray-600",
- "min-h-9 group flex w-64 flex-row rounded-md px-3 py-[10px] leading-4 hover:bg-gray-100 group-hover:text-gray-700 [&[aria-current='page']]:bg-gray-200 [&[aria-current='page']]:text-gray-900",
+ "min-h-9 group flex w-64 flex-row rounded-md px-2 py-[10px] leading-4 hover:bg-gray-100 group-hover:text-gray-700 [&[aria-current='page']]:bg-gray-200 [&[aria-current='page']]:text-gray-900",
props.disabled && "pointer-events-none !opacity-30",
(isChild || !props.icon) && "ml-7 mr-5 w-auto",
!info ? "h-6" : "h-14",