diff --git a/web/app/components/base/ui/dropdown-menu/index.tsx b/web/app/components/base/ui/dropdown-menu/index.tsx index 57519f84fd..6534726064 100644 --- a/web/app/components/base/ui/dropdown-menu/index.tsx +++ b/web/app/components/base/ui/dropdown-menu/index.tsx @@ -15,6 +15,7 @@ function parsePlacement(placement: Placement) { export const DropdownMenu = Menu.Root export const DropdownMenuTrigger = Menu.Trigger +export const DropdownMenuSub = Menu.SubmenuRoot export const DropdownMenuGroup = Menu.Group export const DropdownMenuGroupLabel = Menu.GroupLabel export const DropdownMenuRadioGroup = Menu.RadioGroup @@ -65,6 +66,70 @@ export function DropdownMenuContent({ ) } +type DropdownMenuSubTriggerProps = React.ComponentPropsWithoutRef & { + destructive?: boolean +} + +export function DropdownMenuSubTrigger({ + className, + destructive, + ...props +}: DropdownMenuSubTriggerProps) { + return ( + + ) +} + +type DropdownMenuSubContentProps = { + children: React.ReactNode + placement?: Placement + sideOffset?: number + alignOffset?: number + className?: string + popupClassName?: string +} + +export function DropdownMenuSubContent({ + children, + placement = 'left-start', + sideOffset = 4, + alignOffset = 0, + className, + popupClassName, +}: DropdownMenuSubContentProps) { + const { side, align } = parsePlacement(placement) + + return ( + + + + {children} + + + + ) +} + type DropdownMenuItemProps = React.ComponentPropsWithoutRef & { destructive?: boolean } diff --git a/web/app/components/header/account-dropdown/compliance.tsx b/web/app/components/header/account-dropdown/compliance.tsx index 6bc5b5c3f1..8d90a659d3 100644 --- a/web/app/components/header/account-dropdown/compliance.tsx +++ b/web/app/components/header/account-dropdown/compliance.tsx @@ -1,9 +1,8 @@ -import type { FC, MouseEvent } from 'react' -import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/react' -import { RiArrowDownCircleLine, RiArrowRightSLine, RiVerifiedBadgeLine } from '@remixicon/react' +import type { FC, MouseEvent, ReactNode } from 'react' import { useMutation } from '@tanstack/react-query' -import { Fragment, useCallback } from 'react' +import { useCallback } from 'react' import { useTranslation } from 'react-i18next' +import { DropdownMenuGroup, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger } from '@/app/components/base/ui/dropdown-menu' import { Plan } from '@/app/components/billing/type' import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants' import { useModalContext } from '@/context/modal-context' @@ -20,6 +19,12 @@ import PremiumBadge from '../../base/premium-badge' import Toast from '../../base/toast' import Tooltip from '../../base/tooltip' +const submenuTriggerClassName = '!mx-0 !h-8 !rounded-lg !px-3 data-[highlighted]:!bg-state-base-hover' +const menuLabelClassName = 'grow px-1 text-text-secondary system-md-regular' +const menuLeadingIconClassName = 'size-4 shrink-0 text-text-tertiary' +const menuTrailingIconClassName = 'size-[14px] shrink-0 text-text-tertiary' +const complianceRowClassName = 'mx-0 flex h-10 w-full items-center gap-1 rounded-lg py-1 pl-1 pr-2 text-text-secondary system-md-regular' + enum DocName { SOC2_Type_I = 'SOC2_Type_I', SOC2_Type_II = 'SOC2_Type_II', @@ -27,9 +32,30 @@ enum DocName { GDPR = 'GDPR', } +type ComplianceMenuItemContentProps = { + iconClassName: string + label: ReactNode + trailing?: ReactNode +} + +function ComplianceMenuItemContent({ + iconClassName, + label, + trailing, +}: ComplianceMenuItemContentProps) { + return ( + <> + +
{label}
+ {trailing} + + ) +} + type UpgradeOrDownloadProps = { doc_name: DocName } + const UpgradeOrDownload: FC = ({ doc_name }) => { const { t } = useTranslation() const { plan } = useProviderContext() @@ -78,8 +104,8 @@ const UpgradeOrDownload: FC = ({ doc_name }) => { if (isCurrentPlanCanDownload) { return ( ) } @@ -103,85 +129,65 @@ const UpgradeOrDownload: FC = ({ doc_name }) => { ) } +type ComplianceDocRowProps = { + icon: ReactNode + label: ReactNode + docName: DocName +} + +function ComplianceDocRow({ + icon, + label, + docName, +}: ComplianceDocRowProps) { + return ( +
+ {icon} +
{label}
+ +
+ ) +} + export default function Compliance() { - const itemClassName = ` - flex items-center w-full h-10 pl-1 pr-2 py-1 text-text-secondary system-md-regular - rounded-lg hover:bg-state-base-hover gap-1 -` const { t } = useTranslation() return ( - - { - ({ open }) => ( - <> - - -
{t('userProfile.compliance', { ns: 'common' })}
- -
- - -
- -
- -
{t('compliance.soc2Type1', { ns: 'common' })}
- -
-
- -
- -
{t('compliance.soc2Type2', { ns: 'common' })}
- -
-
- -
- -
{t('compliance.iso27001', { ns: 'common' })}
- -
-
- -
- -
{t('compliance.gdpr', { ns: 'common' })}
- -
-
-
-
-
- - ) - } -
+ + + } + /> + + + + } + label={t('compliance.soc2Type1', { ns: 'common' })} + docName={DocName.SOC2_Type_I} + /> + } + label={t('compliance.soc2Type2', { ns: 'common' })} + docName={DocName.SOC2_Type_II} + /> + } + label={t('compliance.iso27001', { ns: 'common' })} + docName={DocName.ISO_27001} + /> + } + label={t('compliance.gdpr', { ns: 'common' })} + docName={DocName.GDPR} + /> + + + ) } diff --git a/web/app/components/header/account-dropdown/index.tsx b/web/app/components/header/account-dropdown/index.tsx index 983f9e434d..0109a66956 100644 --- a/web/app/components/header/account-dropdown/index.tsx +++ b/web/app/components/header/account-dropdown/index.tsx @@ -1,26 +1,15 @@ 'use client' -import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/react' -import { - RiAccountCircleLine, - RiArrowRightUpLine, - RiBookOpenLine, - RiGithubLine, - RiGraduationCapFill, - RiInformation2Line, - RiLogoutBoxRLine, - RiMap2Line, - RiSettings3Line, - RiStarLine, - RiTShirt2Line, -} from '@remixicon/react' + +import type { MouseEventHandler, ReactNode } from 'react' import Link from 'next/link' import { useRouter } from 'next/navigation' -import { Fragment, useState } from 'react' +import { useState } from 'react' import { useTranslation } from 'react-i18next' import { resetUser } from '@/app/components/base/amplitude/utils' import Avatar from '@/app/components/base/avatar' import PremiumBadge from '@/app/components/base/premium-badge' import ThemeSwitcher from '@/app/components/base/theme-switcher' +import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/app/components/base/ui/dropdown-menu' import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants' import { IS_CLOUD_EDITION } from '@/config' import { useAppContext } from '@/context/app-context' @@ -37,13 +26,117 @@ import Indicator from '../indicator' import Compliance from './compliance' import Support from './support' +const menuItemClassName = '!mx-0 !h-8 !rounded-lg !px-3 data-[highlighted]:!bg-state-base-hover' +const menuStaticRowClassName = 'flex h-8 w-full items-center rounded-lg px-3 text-text-secondary system-md-regular' +const menuLabelClassName = 'grow px-1 text-text-secondary system-md-regular' +const menuLeadingIconClassName = 'size-4 shrink-0 text-text-tertiary' +const menuTrailingIconClassName = 'size-[14px] shrink-0 text-text-tertiary' + +type AccountMenuItemContentProps = { + iconClassName: string + label: ReactNode + trailing?: ReactNode +} + +function AccountMenuItemContent({ + iconClassName, + label, + trailing, +}: AccountMenuItemContentProps) { + return ( + <> + +
{label}
+ {trailing} + + ) +} + +type AccountMenuRouteItemProps = { + href: string + iconClassName: string + label: ReactNode + trailing?: ReactNode +} + +function AccountMenuRouteItem({ + href, + iconClassName, + label, + trailing, +}: AccountMenuRouteItemProps) { + return ( + } + > + + + ) +} + +type AccountMenuExternalItemProps = { + href: string + iconClassName: string + label: ReactNode + trailing?: ReactNode +} + +function AccountMenuExternalItem({ + href, + iconClassName, + label, + trailing, +}: AccountMenuExternalItemProps) { + return ( + } + > + + + ) +} + +type AccountMenuActionItemProps = { + iconClassName: string + label: ReactNode + onClick?: MouseEventHandler + trailing?: ReactNode +} + +function AccountMenuActionItem({ + iconClassName, + label, + onClick, + trailing, +}: AccountMenuActionItemProps) { + return ( + + + + ) +} + +function ExternalLinkIndicator() { + return +} + +type AccountMenuSectionProps = { + children: ReactNode +} + +function AccountMenuSection({ children }: AccountMenuSectionProps) { + return {children} +} + export default function AppSelector() { - const itemClassName = ` - flex items-center w-full h-8 pl-3 pr-2 text-text-secondary system-md-regular - rounded-lg hover:bg-state-base-hover cursor-pointer gap-1 - ` const router = useRouter() const [aboutVisible, setAboutVisible] = useState(false) + const [isAccountMenuOpen, setIsAccountMenuOpen] = useState(false) const { systemFeatures } = useGlobalPublicStore() const { t } = useTranslation() @@ -69,160 +162,117 @@ export default function AppSelector() { return (
- - { - ({ open, close }) => ( - <> - - - - - -
- -
-
-
- {userProfile.name} - {isEducationAccount && ( - - - EDU - - )} -
-
{userProfile.email}
-
- -
-
- - - -
{t('account.account', { ns: 'common' })}
- - -
- -
setShowAccountSettingModal({ payload: ACCOUNT_SETTING_TAB.MEMBERS })} - > - -
{t('userProfile.settings', { ns: 'common' })}
-
-
-
- {!systemFeatures.branding.enabled && ( - <> -
- - - -
{t('userProfile.helpCenter', { ns: 'common' })}
- - -
- - {IS_CLOUD_EDITION && isCurrentWorkspaceOwner && } -
-
- - - -
{t('userProfile.roadmap', { ns: 'common' })}
- - -
- - - -
{t('userProfile.github', { ns: 'common' })}
-
- - -
- -
- { - env.NEXT_PUBLIC_SITE_ABOUT !== 'hide' && ( - -
setAboutVisible(true)} - > - -
{t('userProfile.about', { ns: 'common' })}
-
-
{langGeniusVersionInfo.current_version}
- -
-
-
- ) - } -
- + + + + + + +
+
+
+ {userProfile.name} + {isEducationAccount && ( + + + EDU + )} - -
-
- -
{t('theme.theme', { ns: 'common' })}
- -
+
+
{userProfile.email}
+
+ +
+ } + /> + setShowAccountSettingModal({ payload: ACCOUNT_SETTING_TAB.MEMBERS })} + /> + + + {!systemFeatures.branding.enabled && ( + <> + + } + /> + setIsAccountMenuOpen(false)} /> + {IS_CLOUD_EDITION && isCurrentWorkspaceOwner && } + + + + } + /> + + +
- - -
handleLogout()}> -
- -
{t('userProfile.logout', { ns: 'common' })}
-
-
-
-
-
+ )} + /> + { + env.NEXT_PUBLIC_SITE_ABOUT !== 'hide' && ( + { + setAboutVisible(true) + setIsAccountMenuOpen(false) + }} + trailing={( +
+
{langGeniusVersionInfo.current_version}
+ +
+ )} + /> + ) + } + + - ) - } -
+ )} + +
+ } + /> +
+
+ + + { + void handleLogout() + }} + /> + + + { aboutVisible && setAboutVisible(false)} langGeniusVersionInfo={langGeniusVersionInfo} /> } diff --git a/web/app/components/header/account-dropdown/support.tsx b/web/app/components/header/account-dropdown/support.tsx index 7873b676c3..545b4d8b4d 100644 --- a/web/app/components/header/account-dropdown/support.tsx +++ b/web/app/components/header/account-dropdown/support.tsx @@ -1,119 +1,118 @@ -import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/react' -import { RiArrowRightSLine, RiArrowRightUpLine, RiChatSmile2Line, RiDiscordLine, RiDiscussLine, RiMailSendLine, RiQuestionLine } from '@remixicon/react' -import Link from 'next/link' -import { Fragment } from 'react' +import type { ReactNode } from 'react' import { useTranslation } from 'react-i18next' +import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger } from '@/app/components/base/ui/dropdown-menu' import { toggleZendeskWindow } from '@/app/components/base/zendesk/utils' import { Plan } from '@/app/components/billing/type' -import { ZENDESK_WIDGET_KEY } from '@/config' +import * as config from '@/config' import { useAppContext } from '@/context/app-context' import { useProviderContext } from '@/context/provider-context' import { cn } from '@/utils/classnames' import { mailToSupport } from '../utils/util' +const submenuTriggerClassName = '!mx-0 !h-8 !rounded-lg !px-3 data-[highlighted]:!bg-state-base-hover' +const submenuItemClassName = '!mx-0 !h-8 !rounded-lg !px-3 data-[highlighted]:!bg-state-base-hover' +const menuLabelClassName = 'grow px-1 text-text-secondary system-md-regular' +const menuLeadingIconClassName = 'size-4 shrink-0 text-text-tertiary' +const menuTrailingIconClassName = 'size-[14px] shrink-0 text-text-tertiary' + type SupportProps = { closeAccountDropdown: () => void } +type SupportMenuItemContentProps = { + iconClassName: string + label: ReactNode + trailing?: ReactNode +} + +function SupportMenuItemContent({ + iconClassName, + label, + trailing, +}: SupportMenuItemContentProps) { + return ( + <> + +
{label}
+ {trailing} + + ) +} + +function SupportExternalLinkIndicator() { + return +} + export default function Support({ closeAccountDropdown }: SupportProps) { - const itemClassName = ` - flex items-center w-full h-9 pl-3 pr-2 text-text-secondary system-md-regular - rounded-lg hover:bg-state-base-hover cursor-pointer gap-1 -` const { t } = useTranslation() const { plan } = useProviderContext() const { userProfile, langGeniusVersionInfo } = useAppContext() const hasDedicatedChannel = plan.type !== Plan.sandbox + const zendeskWidgetKey = 'ZENDESK_WIDGET_KEY' in config ? config.ZENDESK_WIDGET_KEY : '' + const hasZendeskWidget = !!zendeskWidgetKey?.trim() return ( - - { - ({ open }) => ( - <> - + + } + /> + + + + {hasDedicatedChannel && hasZendeskWidget && ( + { + toggleZendeskWindow(true) + closeAccountDropdown() + }} > - -
{t('userProfile.support', { ns: 'common' })}
- -
- + + )} + {hasDedicatedChannel && !hasZendeskWidget && ( + } > - -
- {hasDedicatedChannel && ( - - {ZENDESK_WIDGET_KEY && ZENDESK_WIDGET_KEY.trim() !== '' - ? ( - - ) - : ( - - -
{t('userProfile.emailSupport', { ns: 'common' })}
- -
- )} -
- )} - - - -
{t('userProfile.forum', { ns: 'common' })}
- - -
- - - -
{t('userProfile.community', { ns: 'common' })}
- - -
-
-
-
- - ) - } -
+ } + /> + + )} + } + > + } + /> + + } + > + } + /> + + + + ) } diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json index 1c94fedf07..77e870f99c 100644 --- a/web/eslint-suppressions.json +++ b/web/eslint-suppressions.json @@ -3961,21 +3961,6 @@ "count": 1 } }, - "app/components/header/account-dropdown/compliance.tsx": { - "tailwindcss/enforce-consistent-class-order": { - "count": 6 - } - }, - "app/components/header/account-dropdown/index.tsx": { - "tailwindcss/enforce-consistent-class-order": { - "count": 12 - } - }, - "app/components/header/account-dropdown/support.tsx": { - "tailwindcss/enforce-consistent-class-order": { - "count": 5 - } - }, "app/components/header/account-dropdown/workplace-selector/index.tsx": { "tailwindcss/enforce-consistent-class-order": { "count": 3