From 902de72cc080628eb768426bf359f9bde0e6c3d0 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 10 Oct 2024 12:58:28 +0800 Subject: [PATCH] new style of settings --- .../header/account-dropdown/index.tsx | 2 +- .../header/account-setting/index.tsx | 61 ++++++++++--------- .../header/account-setting/menu-dialog.tsx | 46 ++++++++++++++ web/i18n/en-US/common.ts | 1 + web/i18n/zh-Hans/common.ts | 1 + 5 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 web/app/components/header/account-setting/menu-dialog.tsx diff --git a/web/app/components/header/account-dropdown/index.tsx b/web/app/components/header/account-dropdown/index.tsx index 4c42374ffd..c29e0f159b 100644 --- a/web/app/components/header/account-dropdown/index.tsx +++ b/web/app/components/header/account-dropdown/index.tsx @@ -102,7 +102,7 @@ export default function AppSelector({ isMobile }: IAppSelector) {
-
setShowAccountSettingModal({ payload: 'account' })}> +
setShowAccountSettingModal({ payload: 'provider' })}>
{t('common.userProfile.settings')}
diff --git a/web/app/components/header/account-setting/index.tsx b/web/app/components/header/account-setting/index.tsx index c8f757de28..d56f231a55 100644 --- a/web/app/components/header/account-setting/index.tsx +++ b/web/app/components/header/account-setting/index.tsx @@ -6,8 +6,8 @@ import { RiAccountCircleLine, RiApps2AddFill, RiApps2AddLine, - RiBox3Fill, - RiBox3Line, + RiBrainFill, + RiBrainLine, RiCloseLine, RiColorFilterFill, RiColorFilterLine, @@ -31,17 +31,14 @@ import ModelProviderPage from './model-provider-page' import cn from '@/utils/classnames' import BillingPage from '@/app/components/billing/billing-page' import CustomPage from '@/app/components/custom/custom-page' -import Modal from '@/app/components/base/modal' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { useProviderContext } from '@/context/provider-context' import { useAppContext } from '@/context/app-context' +import MenuDialog from '@/app/components/header/account-setting/menu-dialog' +import Input from '@/app/components/base/input' const iconClassName = ` - w-4 h-4 ml-3 mr-2 -` - -const scrolledClassName = ` - border-b shadow-xs bg-white/[.98] + w-5 h-5 mr-2 ` type IAccountSettingProps = { @@ -59,7 +56,7 @@ type GroupItem = { export default function AccountSetting({ onCancel, - activeTab = 'account', + activeTab = 'provider', }: IAccountSettingProps) { const [activeMenu, setActiveMenu] = useState(activeTab) const { t } = useTranslation() @@ -73,8 +70,8 @@ export default function AccountSetting({ { key: 'provider', name: t('common.settings.provider'), - icon: , - activeIcon: , + icon: , + activeIcon: , }, { key: 'members', @@ -122,7 +119,7 @@ export default function AccountSetting({ }, { key: 'account-group', - name: t('common.settings.accountGroup'), + name: t('common.settings.generalGroup'), items: [ { key: 'account', @@ -161,32 +158,31 @@ export default function AccountSetting({ const activeItem = [...menuItems[0].items, ...menuItems[1].items].find(item => item.key === activeMenu) + const [searchValue, setSearchValue] = useState('') + return ( - { }} - className='my-[60px] p-0 max-w-[1024px] rounded-xl overflow-y-auto' - wrapperClassName='pt-[60px]' > -
-
-
{t('common.userProfile.settings')}
+
+
+
{t('common.userProfile.settings')}
{ menuItems.map(menuItem => ( -
+
{!isCurrentWorkspaceDatasetOperator && ( -
{menuItem.name}
+
{menuItem.name}
)}
{ menuItem.items.map(item => (
setActiveMenu(item.key)} > @@ -201,15 +197,22 @@ export default function AccountSetting({ }
-
-
-
{activeItem?.name}
+
+
+
{activeItem?.name}
{ activeItem?.description && (
{activeItem?.description}
) }
+ setSearchValue(e.target.value)} + value={searchValue} + />
@@ -228,6 +231,6 @@ export default function AccountSetting({
- + ) } diff --git a/web/app/components/header/account-setting/menu-dialog.tsx b/web/app/components/header/account-setting/menu-dialog.tsx new file mode 100644 index 0000000000..2f13311d0d --- /dev/null +++ b/web/app/components/header/account-setting/menu-dialog.tsx @@ -0,0 +1,46 @@ +import { Fragment, useCallback } from 'react' +import type { ReactNode } from 'react' +import { Dialog, Transition } from '@headlessui/react' +import cn from '@/utils/classnames' + +type DialogProps = { + className?: string + children: ReactNode + show: boolean + onClose?: () => void +} + +const MenuDialog = ({ + className, + children, + show, + onClose, +}: DialogProps) => { + const close = useCallback(() => onClose?.(), [onClose]) + return ( + + +
+
+ + +
+ {children} + + +
+
+
+
+ ) +} + +export default MenuDialog diff --git a/web/i18n/en-US/common.ts b/web/i18n/en-US/common.ts index 23e301485a..483c4788e6 100644 --- a/web/i18n/en-US/common.ts +++ b/web/i18n/en-US/common.ts @@ -142,6 +142,7 @@ const translation = { settings: { accountGroup: 'ACCOUNT', workplaceGroup: 'WORKSPACE', + generalGroup: 'GENERAL', account: 'My account', members: 'Members', billing: 'Billing', diff --git a/web/i18n/zh-Hans/common.ts b/web/i18n/zh-Hans/common.ts index 7947d32f25..7d906ed0b4 100644 --- a/web/i18n/zh-Hans/common.ts +++ b/web/i18n/zh-Hans/common.ts @@ -142,6 +142,7 @@ const translation = { settings: { accountGroup: '账户', workplaceGroup: '工作空间', + generalGroup: '通用', account: '我的账户', members: '成员', billing: '账单',