Files
calendar/apps/web/modules/shell/user-dropdown/ProfileDropdown.tsx
T
Benny JooGitHubbenny@cal.com <sldisek783@gmail.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
ab21c7f805 refactor: Cal.diy (#28903)
* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com

This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main:

- Rebrand Cal.com to Cal.diy across the entire codebase
- Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions
- Switch license from AGPL-3.0 to MIT
- Remove docs/ directory (migrated to Nextra at cal.diy)
- Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc.
- Clean up .env.example for self-hosted Cal.diy
- Update Docker image references to calcom/cal.diy
- Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork
- Add PR welcome bot for Cal.diy contributors
- Fix API v2 breaking changes oasdiff ignore entries
- Replace Blacksmith CI runners with default GitHub Actions

3893 files changed, 20789 insertions(+), 411020 deletions(-)

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* rip out org related comments in api v2

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-04-15 09:52:36 -03:00

109 lines
3.9 KiB
TypeScript

import { ENABLE_PROFILE_SWITCHER } from "@calcom/lib/constants";
import { useRefreshData } from "@calcom/lib/hooks/useRefreshData";
import { trpc } from "@calcom/trpc/react";
import classNames from "@calcom/ui/classNames";
import { Avatar } from "@calcom/ui/components/avatar";
import {
Dropdown,
DropdownItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuPortal,
DropdownMenuTrigger,
} from "@calcom/ui/components/dropdown";
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "@coss/ui/icons";
import { useSession } from "next-auth/react";
import { useState } from "react";
export function ProfileDropdown() {
const { update, data: sessionData } = useSession();
const { data } = trpc.viewer.me.get.useQuery();
const [menuOpen, setMenuOpen] = useState(false);
const refreshData = useRefreshData();
if (!data || !ENABLE_PROFILE_SWITCHER || !sessionData) {
return null;
}
const options = data.profiles.map((profile) => {
let label;
if (profile.organization) {
label = profile.organization.name;
} else {
label = sessionData.user.name;
}
return {
label,
value: profile.upId,
};
});
const currentOption = options.find((option) => option.value === sessionData.upId) || options[0];
return (
<Dropdown open={menuOpen} onOpenChange={setMenuOpen}>
<DropdownMenuTrigger asChild>
<button
data-testid="user-dropdown-trigger-button"
className={classNames(
"hover:bg-emphasis todesktop:!bg-transparent group mx-0 flex w-full cursor-pointer appearance-none items-center rounded-full px-2 py-1.5 text-left outline-none transition focus:outline-none focus:ring-0 md:rounded-none lg:rounded"
)}>
<span className="flex w-full grow items-center justify-around gap-2 text-sm font-medium leading-none">
<Avatar alt={currentOption.label || ""} size="xsm" />
<span className="block w-20 overflow-hidden text-ellipsis whitespace-nowrap">
{currentOption.label}
</span>
{menuOpen ? (
<ChevronUpIcon className="group-hover:text-subtle text-muted h-4 w-4 shrink-0 transition rtl:mr-4" />
) : (
<ChevronDownIcon className="group-hover:text-subtle text-muted h-4 w-4 shrink-0 transition rtl:mr-4" />
)}
</span>
</button>
</DropdownMenuTrigger>
<DropdownMenuPortal>
<DropdownMenuContent
align="start"
onInteractOutside={() => {
setMenuOpen(false);
}}
className="min-w-56 hariom group overflow-hidden rounded-md">
<DropdownMenuItem className="p-3 uppercase">
<span>Switch to</span>
</DropdownMenuItem>
{options.map((option) => {
const isSelected = currentOption.value === option.value;
return (
<DropdownMenuItem
key={option.value}
onClick={() => {
setMenuOpen(false);
if (isSelected) return;
update({
upId: option.value,
}).then(() => {
refreshData();
});
}}
className={classNames("flex w-full", isSelected ? "bg-subtle text-emphasis" : "")}>
<DropdownItem
type="button"
childrenClassName={classNames("flex w-full justify-between items-center")}>
<span>
<Avatar alt={option.label || ""} size="xsm" />
<span className="ml-2">{option.label}</span>
</span>
{isSelected ? <CheckIcon className="ml-2 inline h-4 w-4" /> : null}
</DropdownItem>
</DropdownMenuItem>
);
})}
{/* <DropdownMenuSeparator /> */}
</DropdownMenuContent>
</DropdownMenuPortal>
</Dropdown>
);
}