fix: add icon to user profile dropdown menu item
parent
2ff2b08739
commit
cd932519b3
@ -0,0 +1,94 @@
|
|||||||
|
import { Menu, Transition } from '@headlessui/react'
|
||||||
|
import { RiArrowRightSLine, RiArrowRightUpLine, RiDiscordLine, RiFeedbackLine, RiMailSendLine, RiVerifiedBadgeLine } from '@remixicon/react'
|
||||||
|
import { Fragment } from 'react'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { mailToSupport } from '../utils/util'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
|
import { Plan } from '@/app/components/billing/type'
|
||||||
|
import { useAppContext } from '@/context/app-context'
|
||||||
|
|
||||||
|
export default function Compliance() {
|
||||||
|
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, langeniusVersionInfo } = useAppContext()
|
||||||
|
const canEmailSupport = plan.type === Plan.professional || plan.type === Plan.team || plan.type === Plan.enterprise
|
||||||
|
|
||||||
|
return <Menu as="div" className="relative w-full h-full">
|
||||||
|
{
|
||||||
|
({ open }) => (
|
||||||
|
<>
|
||||||
|
<Menu.Button className={
|
||||||
|
cn('flex items-center pl-3 pr-2 py-2 h-9 w-full group hover:bg-state-base-hover rounded-lg gap-1',
|
||||||
|
open && 'bg-state-base-hover',
|
||||||
|
)}>
|
||||||
|
<RiVerifiedBadgeLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow text-left system-md-regular text-text-secondary'>{t('common.userProfile.compliance')}</div>
|
||||||
|
<RiArrowRightSLine className='shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</Menu.Button>
|
||||||
|
<Transition
|
||||||
|
as={Fragment}
|
||||||
|
enter="transition ease-out duration-100"
|
||||||
|
enterFrom="transform opacity-0 scale-95"
|
||||||
|
enterTo="transform opacity-100 scale-100"
|
||||||
|
leave="transition ease-in duration-75"
|
||||||
|
leaveFrom="transform opacity-100 scale-100"
|
||||||
|
leaveTo="transform opacity-0 scale-95"
|
||||||
|
>
|
||||||
|
<Menu.Items
|
||||||
|
className={cn(
|
||||||
|
`absolute top-[1px] w-[216px] max-h-[70vh] overflow-y-scroll z-10 bg-components-panel-bg-blur backdrop-blur-[5px] border-[0.5px] border-components-panel-border
|
||||||
|
divide-y divide-divider-subtle origin-top-right rounded-xl focus:outline-none shadow-lg -translate-x-full
|
||||||
|
`,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="px-1 py-1">
|
||||||
|
{!canEmailSupport && <Menu.Item>
|
||||||
|
{({ active }) => <a
|
||||||
|
className={cn(itemClassName, 'group justify-between',
|
||||||
|
active && 'bg-state-base-hover',
|
||||||
|
)}
|
||||||
|
href={mailToSupport(userProfile.email, plan.type, langeniusVersionInfo.current_version)}
|
||||||
|
target='_blank' rel='noopener noreferrer'>
|
||||||
|
<RiMailSendLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow system-md-regular text-text-secondary'>{t('common.userProfile.emailSupport')}</div>
|
||||||
|
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</a>}
|
||||||
|
</Menu.Item>}
|
||||||
|
<Menu.Item>
|
||||||
|
{({ active }) => <Link
|
||||||
|
className={cn(itemClassName, 'group justify-between',
|
||||||
|
active && 'bg-state-base-hover',
|
||||||
|
)}
|
||||||
|
href='https://github.com/langgenius/dify/discussions/categories/feedbacks'
|
||||||
|
target='_blank' rel='noopener noreferrer'>
|
||||||
|
<RiFeedbackLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow system-md-regular text-text-secondary'>{t('common.userProfile.communityFeedback')}</div>
|
||||||
|
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</Link>}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item>
|
||||||
|
{({ active }) => <Link
|
||||||
|
className={cn(itemClassName, 'group justify-between',
|
||||||
|
active && 'bg-state-base-hover',
|
||||||
|
)}
|
||||||
|
href='https://discord.gg/5AEfbxcd9k'
|
||||||
|
target='_blank' rel='noopener noreferrer'>
|
||||||
|
<RiDiscordLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow system-md-regular text-text-secondary'>{t('common.userProfile.community')}</div>
|
||||||
|
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</Link>}
|
||||||
|
</Menu.Item>
|
||||||
|
</div>
|
||||||
|
</Menu.Items>
|
||||||
|
</Transition>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
import { Menu, Transition } from '@headlessui/react'
|
||||||
|
import { RiArrowRightSLine, RiArrowRightUpLine, RiDiscordLine, RiFeedbackLine, RiMailSendLine, RiQuestionLine } from '@remixicon/react'
|
||||||
|
import { Fragment } from 'react'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { mailToSupport } from '../utils/util'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
|
import { Plan } from '@/app/components/billing/type'
|
||||||
|
import { useAppContext } from '@/context/app-context'
|
||||||
|
|
||||||
|
export default function Support() {
|
||||||
|
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, langeniusVersionInfo } = useAppContext()
|
||||||
|
const canEmailSupport = plan.type === Plan.professional || plan.type === Plan.team || plan.type === Plan.enterprise
|
||||||
|
|
||||||
|
return <Menu as="div" className="relative w-full h-full">
|
||||||
|
{
|
||||||
|
({ open }) => (
|
||||||
|
<>
|
||||||
|
<Menu.Button className={
|
||||||
|
cn('flex items-center pl-3 pr-2 py-2 h-9 w-full group hover:bg-state-base-hover rounded-lg gap-1',
|
||||||
|
open && 'bg-state-base-hover',
|
||||||
|
)}>
|
||||||
|
<RiQuestionLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow text-left system-md-regular text-text-secondary'>{t('common.userProfile.support')}</div>
|
||||||
|
<RiArrowRightSLine className='shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</Menu.Button>
|
||||||
|
<Transition
|
||||||
|
as={Fragment}
|
||||||
|
enter="transition ease-out duration-100"
|
||||||
|
enterFrom="transform opacity-0 scale-95"
|
||||||
|
enterTo="transform opacity-100 scale-100"
|
||||||
|
leave="transition ease-in duration-75"
|
||||||
|
leaveFrom="transform opacity-100 scale-100"
|
||||||
|
leaveTo="transform opacity-0 scale-95"
|
||||||
|
>
|
||||||
|
<Menu.Items
|
||||||
|
className={cn(
|
||||||
|
`absolute top-[1px] w-[216px] max-h-[70vh] overflow-y-scroll z-10 bg-components-panel-bg-blur backdrop-blur-[5px] border-[0.5px] border-components-panel-border
|
||||||
|
divide-y divide-divider-subtle origin-top-right rounded-xl focus:outline-none shadow-lg -translate-x-full
|
||||||
|
`,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="px-1 py-1">
|
||||||
|
{canEmailSupport && <Menu.Item>
|
||||||
|
{({ active }) => <a
|
||||||
|
className={cn(itemClassName, 'group justify-between',
|
||||||
|
active && 'bg-state-base-hover',
|
||||||
|
)}
|
||||||
|
href={mailToSupport(userProfile.email, plan.type, langeniusVersionInfo.current_version)}
|
||||||
|
target='_blank' rel='noopener noreferrer'>
|
||||||
|
<RiMailSendLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow system-md-regular text-text-secondary'>{t('common.userProfile.emailSupport')}</div>
|
||||||
|
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</a>}
|
||||||
|
</Menu.Item>}
|
||||||
|
<Menu.Item>
|
||||||
|
{({ active }) => <Link
|
||||||
|
className={cn(itemClassName, 'group justify-between',
|
||||||
|
active && 'bg-state-base-hover',
|
||||||
|
)}
|
||||||
|
href='https://github.com/langgenius/dify/discussions/categories/feedbacks'
|
||||||
|
target='_blank' rel='noopener noreferrer'>
|
||||||
|
<RiFeedbackLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow system-md-regular text-text-secondary'>{t('common.userProfile.communityFeedback')}</div>
|
||||||
|
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</Link>}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item>
|
||||||
|
{({ active }) => <Link
|
||||||
|
className={cn(itemClassName, 'group justify-between',
|
||||||
|
active && 'bg-state-base-hover',
|
||||||
|
)}
|
||||||
|
href='https://discord.gg/5AEfbxcd9k'
|
||||||
|
target='_blank' rel='noopener noreferrer'>
|
||||||
|
<RiDiscordLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||||
|
<div className='flex-grow system-md-regular text-text-secondary'>{t('common.userProfile.community')}</div>
|
||||||
|
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||||
|
</Link>}
|
||||||
|
</Menu.Item>
|
||||||
|
</div>
|
||||||
|
</Menu.Items>
|
||||||
|
</Transition>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
@ -1,50 +1,27 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useEffect, useState } from 'react'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { Github } from '@/app/components/base/icons/src/public/common'
|
import type { FC } from 'react'
|
||||||
import type { GithubRepo } from '@/models/common'
|
import type { GithubRepo } from '@/models/common'
|
||||||
|
|
||||||
const getStar = async () => {
|
const getStar = async () => {
|
||||||
const res = await fetch('https://api.github.com/repos/langgenius/dify')
|
const res = await fetch('https://api.github.com/repos/langgenius/dify')
|
||||||
|
|
||||||
if (!res.ok)
|
if (!res.ok)
|
||||||
throw new Error('Failed to fetch data')
|
throw new Error('Failed to fetch github star')
|
||||||
|
|
||||||
return res.json()
|
return res.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
const GithubStar = () => {
|
const GithubStar: FC<{ className: string }> = (props) => {
|
||||||
const [githubRepo, setGithubRepo] = useState<GithubRepo>({ stargazers_count: 6000 })
|
const { isFetching, data } = useQuery<GithubRepo>({
|
||||||
const [isFetched, setIsFetched] = useState(false)
|
queryKey: ['github-star'],
|
||||||
useEffect(() => {
|
queryFn: getStar,
|
||||||
(async () => {
|
enabled: process.env.NODE_ENV !== 'development',
|
||||||
try {
|
initialData: { stargazers_count: 6000 },
|
||||||
if (process.env.NODE_ENV === 'development')
|
})
|
||||||
return
|
if (isFetching)
|
||||||
|
|
||||||
await setGithubRepo(await getStar())
|
|
||||||
setIsFetched(true)
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
if (!isFetched)
|
|
||||||
return null
|
return null
|
||||||
|
return <span {...props}>{data.stargazers_count.toLocaleString()}</span>
|
||||||
return (
|
|
||||||
<a
|
|
||||||
href='https://github.com/langgenius/dify'
|
|
||||||
target='_blank' rel='noopener noreferrer'
|
|
||||||
className='flex items-center leading-[18px] border border-gray-200 rounded-md text-xs text-gray-700 font-semibold overflow-hidden'>
|
|
||||||
<div className='flex items-center px-2 py-1 bg-gray-100'>
|
|
||||||
<Github className='mr-1 w-[18px] h-[18px]' />
|
|
||||||
Star
|
|
||||||
</div>
|
|
||||||
<div className='px-2 py-1 bg-white border-l border-gray-200'>{`${githubRepo.stargazers_count}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}</div>
|
|
||||||
</a>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GithubStar
|
export default GithubStar
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue