Revert "Feat: compliance report download" (#13799)
This commit is contained in:
@@ -1,185 +0,0 @@
|
||||
import { Menu, Transition } from '@headlessui/react'
|
||||
import { RiArrowDownCircleLine, RiArrowRightSLine, RiVerifiedBadgeLine } from '@remixicon/react'
|
||||
import type { FC, MouseEvent } from 'react'
|
||||
import { Fragment, useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import PremiumBadge from '../../base/premium-badge'
|
||||
import SparklesSoft from '../../base/icons/src/public/common/SparklesSoft'
|
||||
import Button from '../../base/button'
|
||||
import Soc2 from '../../base/icons/src/public/common/Soc2'
|
||||
import Iso from '../../base/icons/src/public/common/Iso'
|
||||
import Gdpr from '../../base/icons/src/public/common/Gdpr'
|
||||
import Toast from '../../base/toast'
|
||||
import Tooltip from '../../base/tooltip'
|
||||
import cn from '@/utils/classnames'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { Plan } from '@/app/components/billing/type'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
import { getDocDownloadUrl } from '@/service/common'
|
||||
|
||||
enum DocName {
|
||||
'SOC2_Type_I' = 'SOC2_Type_I',
|
||||
'SOC2_Type_II' = 'SOC2_Type_II',
|
||||
'ISO_27001' = 'ISO_27001',
|
||||
'GDPR' = 'GDPR',
|
||||
}
|
||||
|
||||
type UpgradeOrDownloadProps = {
|
||||
doc_name: DocName
|
||||
}
|
||||
const UpgradeOrDownload: FC<UpgradeOrDownloadProps> = ({ doc_name }) => {
|
||||
const { t } = useTranslation()
|
||||
const { plan } = useProviderContext()
|
||||
const { setShowPricingModal, setShowAccountSettingModal } = useModalContext()
|
||||
const isFreePlan = plan.type === Plan.sandbox
|
||||
|
||||
const handlePlanClick = useCallback(() => {
|
||||
if (isFreePlan)
|
||||
setShowPricingModal()
|
||||
else
|
||||
setShowAccountSettingModal({ payload: 'billing' })
|
||||
}, [isFreePlan, setShowAccountSettingModal, setShowPricingModal])
|
||||
|
||||
const { isPending, mutate: downloadCompliance } = useMutation({
|
||||
mutationKey: ['downloadCompliance', doc_name],
|
||||
mutationFn: async () => {
|
||||
try {
|
||||
const ret = await getDocDownloadUrl(doc_name)
|
||||
const a = document.createElement('a')
|
||||
a.href = ret.url
|
||||
a.click()
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
message: t('common.operation.downloadSuccess'),
|
||||
})
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error)
|
||||
Toast.notify({
|
||||
type: 'error',
|
||||
message: t('common.operation.downloadFailed'),
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
const whichPlanCanDownloadCompliance = {
|
||||
[DocName.SOC2_Type_I]: [Plan.professional, Plan.team],
|
||||
[DocName.SOC2_Type_II]: [Plan.team],
|
||||
[DocName.ISO_27001]: [Plan.team],
|
||||
[DocName.GDPR]: [Plan.team, Plan.professional, Plan.sandbox],
|
||||
}
|
||||
|
||||
const isCurrentPlanCanDownload = whichPlanCanDownloadCompliance[doc_name].includes(plan.type)
|
||||
const handleDownloadClick = useCallback((e: MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault()
|
||||
downloadCompliance()
|
||||
}, [downloadCompliance])
|
||||
if (isCurrentPlanCanDownload) {
|
||||
return <Button loading={isPending} disabled={isPending} size='small' variant='secondary' className='flex gap-[1px] items-center' onClick={handleDownloadClick}>
|
||||
<RiArrowDownCircleLine className='size-[14px] text-components-button-secondary-text-disabled' />
|
||||
<span className='px-[3px] system-xs-medium text-components-button-secondary-text'>{t('common.operation.download')}</span>
|
||||
</Button>
|
||||
}
|
||||
const upgradeTooltip: Record<Plan, string> = {
|
||||
[Plan.sandbox]: t('common.compliance.sandboxUpgradeTooltip'),
|
||||
[Plan.professional]: t('common.compliance.professionalUpgradeTooltip'),
|
||||
[Plan.team]: '',
|
||||
[Plan.enterprise]: '',
|
||||
}
|
||||
return <Tooltip asChild={false} popupContent={upgradeTooltip[plan.type]}>
|
||||
<PremiumBadge color='blue' allowHover={true} onClick={handlePlanClick}>
|
||||
<SparklesSoft className='flex items-center py-[1px] pl-[3px] w-3.5 h-3.5 text-components-premium-badge-indigo-text-stop-0' />
|
||||
<div className='system-xs-medium'>
|
||||
<span className='p-1'>
|
||||
{t('billing.upgradeBtn.encourageShort')}
|
||||
</span>
|
||||
</div>
|
||||
</PremiumBadge>
|
||||
</Tooltip>
|
||||
}
|
||||
|
||||
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 <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 px-1'>{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-[337px] 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">
|
||||
<Menu.Item>
|
||||
{({ active }) => <div
|
||||
className={cn(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}>
|
||||
<Soc2 className='flex-shrink-0 size-7' />
|
||||
<div className='system-md-regular flex-grow text-text-secondary px-1 truncate'>{t('common.compliance.soc2Type1')}</div>
|
||||
<UpgradeOrDownload doc_name={DocName.SOC2_Type_I} />
|
||||
</div>}
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => <div
|
||||
className={cn(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}>
|
||||
<Soc2 className='flex-shrink-0 size-7' />
|
||||
<div className='system-md-regular flex-grow text-text-secondary px-1 truncate'>{t('common.compliance.soc2Type2')}</div>
|
||||
<UpgradeOrDownload doc_name={DocName.SOC2_Type_II} />
|
||||
</div>}
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => <div
|
||||
className={cn(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}>
|
||||
<Iso className='flex-shrink-0 size-7' />
|
||||
<div className='system-md-regular flex-grow text-text-secondary px-1 truncate'>{t('common.compliance.iso27001')}</div>
|
||||
<UpgradeOrDownload doc_name={DocName.ISO_27001} />
|
||||
</div>}
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => <div
|
||||
className={cn(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}>
|
||||
<Gdpr className='flex-shrink-0 size-7' />
|
||||
<div className='system-md-regular flex-grow text-text-secondary px-1 truncate'>{t('common.compliance.gdpr')}</div>
|
||||
<UpgradeOrDownload doc_name={DocName.GDPR} />
|
||||
</div>}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
</>
|
||||
)
|
||||
}
|
||||
</Menu>
|
||||
}
|
@@ -2,25 +2,24 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Fragment, useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useContext, useContextSelector } from 'use-context-selector'
|
||||
import { RiAccountCircleLine, RiArrowDownSLine, RiArrowRightUpLine, RiBookOpenLine, RiGithubLine, RiInformation2Line, RiLogoutBoxRLine, RiMap2Line, RiSettings3Line, RiStarLine } from '@remixicon/react'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import { RiArrowDownSLine, RiLogoutBoxRLine } from '@remixicon/react'
|
||||
import Link from 'next/link'
|
||||
import { Menu, Transition } from '@headlessui/react'
|
||||
import Indicator from '../indicator'
|
||||
import AccountAbout from '../account-about'
|
||||
import GithubStar from '../github-star'
|
||||
import { mailToSupport } from '../utils/util'
|
||||
import WorkplaceSelector from './workplace-selector'
|
||||
import Support from './support'
|
||||
import Compliance from './compliance'
|
||||
import classNames from '@/utils/classnames'
|
||||
import I18n from '@/context/i18n'
|
||||
import Avatar from '@/app/components/base/avatar'
|
||||
import { logout } from '@/service/common'
|
||||
import AppContext, { useAppContext } from '@/context/app-context'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
import { ArrowUpRight } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
import { LicenseStatus } from '@/types/feature'
|
||||
import { IS_CLOUD_EDITION } from '@/config'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { Plan } from '@/app/components/billing/type'
|
||||
|
||||
export type IAppSelector = {
|
||||
isMobile: boolean
|
||||
@@ -28,17 +27,18 @@ export type IAppSelector = {
|
||||
|
||||
export default function AppSelector({ isMobile }: IAppSelector) {
|
||||
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
|
||||
flex items-center w-full h-9 px-3 text-text-secondary system-md-regular
|
||||
rounded-lg hover:bg-state-base-hover cursor-pointer
|
||||
`
|
||||
const router = useRouter()
|
||||
const [aboutVisible, setAboutVisible] = useState(false)
|
||||
const systemFeatures = useContextSelector(AppContext, v => v.systemFeatures)
|
||||
|
||||
const { locale } = useContext(I18n)
|
||||
const { t } = useTranslation()
|
||||
const { userProfile, langeniusVersionInfo, isCurrentWorkspaceOwner } = useAppContext()
|
||||
const { userProfile, langeniusVersionInfo } = useAppContext()
|
||||
const { setShowAccountSettingModal } = useModalContext()
|
||||
const { plan } = useProviderContext()
|
||||
const canEmailSupport = plan.type === Plan.professional || plan.type === Plan.team || plan.type === Plan.enterprise
|
||||
|
||||
const handleLogout = async () => {
|
||||
await logout({
|
||||
@@ -63,15 +63,15 @@ export default function AppSelector({ isMobile }: IAppSelector) {
|
||||
className={`
|
||||
inline-flex items-center
|
||||
rounded-[20px] py-1 pr-2.5 pl-1 text-sm
|
||||
text-text-secondary hover:bg-state-base-hover
|
||||
text-gray-700 hover:bg-gray-200
|
||||
mobile:px-1
|
||||
${open && 'bg-state-base-hover'}
|
||||
${open && 'bg-gray-200'}
|
||||
`}
|
||||
>
|
||||
<Avatar avatar={userProfile.avatar_url} name={userProfile.name} className='sm:mr-2 mr-0' size={32} />
|
||||
{!isMobile && <>
|
||||
{userProfile.name}
|
||||
<RiArrowDownSLine className="w-3 h-3 ml-1 text-text-tertiary" />
|
||||
<RiArrowDownSLine className="w-3 h-3 ml-1 text-gray-700" />
|
||||
</>}
|
||||
</Menu.Button>
|
||||
<Transition
|
||||
@@ -91,41 +91,70 @@ export default function AppSelector({ isMobile }: IAppSelector) {
|
||||
"
|
||||
>
|
||||
<Menu.Item disabled>
|
||||
<div className='flex flex-nowrap items-center pl-3 pr-2 py-[13px]'>
|
||||
<div className='flex flex-nowrap items-center px-4 py-[13px]'>
|
||||
<Avatar avatar={userProfile.avatar_url} name={userProfile.name} size={36} className='mr-3' />
|
||||
<div className='grow'>
|
||||
<div className='system-md-medium text-text-primary break-all'>{userProfile.name}</div>
|
||||
<div className='system-xs-regular text-text-tertiary break-all'>{userProfile.email}</div>
|
||||
</div>
|
||||
<Avatar avatar={userProfile.avatar_url} name={userProfile.name} size={36} className='mr-3' />
|
||||
</div>
|
||||
</Menu.Item>
|
||||
<div className='p-1'>
|
||||
<div className='px-1 py-1'>
|
||||
<div className='mt-2 px-3 text-xs font-medium text-text-tertiary'>{t('common.userProfile.workspace')}</div>
|
||||
<WorkplaceSelector />
|
||||
</div>
|
||||
<div className="p-1">
|
||||
<div className="px-1 py-1">
|
||||
<Menu.Item>
|
||||
{({ active }) => <Link
|
||||
className={classNames(itemClassName, 'group',
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}
|
||||
href='/account'
|
||||
target='_self' rel='noopener noreferrer'>
|
||||
<RiAccountCircleLine className='size-4 flex-shrink-0 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.account.account')}</div>
|
||||
<RiArrowRightUpLine className='size-[14px] flex-shrink-0 text-text-tertiary' />
|
||||
<div>{t('common.account.account')}</div>
|
||||
<ArrowUpRight className='hidden w-[14px] h-[14px] text-text-tertiary group-hover:flex' />
|
||||
</Link>}
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => <div className={classNames(itemClassName,
|
||||
active && 'bg-state-base-hover',
|
||||
)} onClick={() => setShowAccountSettingModal({ payload: 'members' })}>
|
||||
<RiSettings3Line className='size-4 flex-shrink-0 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.settings')}</div>
|
||||
<div>{t('common.userProfile.settings')}</div>
|
||||
</div>}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
<div className='p-1'>
|
||||
{canEmailSupport && <Menu.Item>
|
||||
{({ active }) => <a
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}
|
||||
href={mailToSupport(userProfile.email, plan.type, langeniusVersionInfo.current_version)}
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<div>{t('common.userProfile.emailSupport')}</div>
|
||||
<ArrowUpRight className='hidden w-[14px] h-[14px] text-text-tertiary group-hover:flex' />
|
||||
</a>}
|
||||
</Menu.Item>}
|
||||
<Menu.Item>
|
||||
{({ active }) => <Link
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}
|
||||
href='https://github.com/langgenius/dify/discussions/categories/feedbacks'
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<div>{t('common.userProfile.communityFeedback')}</div>
|
||||
<ArrowUpRight className='hidden w-[14px] h-[14px] text-text-tertiary group-hover:flex' />
|
||||
</Link>}
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => <Link
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}
|
||||
href='https://discord.gg/5AEfbxcd9k'
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<div>{t('common.userProfile.community')}</div>
|
||||
<ArrowUpRight className='hidden w-[14px] h-[14px] text-text-tertiary group-hover:flex' />
|
||||
</Link>}
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => <Link
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
@@ -135,15 +164,10 @@ export default function AppSelector({ isMobile }: IAppSelector) {
|
||||
locale !== LanguagesSupported[1] ? 'https://docs.dify.ai/' : `https://docs.dify.ai/v/${locale.toLowerCase()}/`
|
||||
}
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<RiBookOpenLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.helpCenter')}</div>
|
||||
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||
<div>{t('common.userProfile.helpCenter')}</div>
|
||||
<ArrowUpRight className='hidden w-[14px] h-[14px] text-text-tertiary group-hover:flex' />
|
||||
</Link>}
|
||||
</Menu.Item>
|
||||
<Support />
|
||||
{IS_CLOUD_EDITION && isCurrentWorkspaceOwner && <Compliance />}
|
||||
</div>
|
||||
<div className='p-1'>
|
||||
<Menu.Item>
|
||||
{({ active }) => <Link
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
@@ -151,35 +175,18 @@ export default function AppSelector({ isMobile }: IAppSelector) {
|
||||
)}
|
||||
href='https://roadmap.dify.ai'
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<RiMap2Line className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.roadmap')}</div>
|
||||
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||
<div>{t('common.userProfile.roadmap')}</div>
|
||||
<ArrowUpRight className='hidden w-[14px] h-[14px] text-text-tertiary group-hover:flex' />
|
||||
</Link>}
|
||||
</Menu.Item>
|
||||
{systemFeatures.license.status === LicenseStatus.NONE && <Menu.Item>
|
||||
{({ active }) => <Link
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}
|
||||
href='https://github.com/langgenius/dify/stargazers'
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<RiGithubLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.github')}</div>
|
||||
<div className='flex items-center gap-0.5 px-[5px] py-[3px] border border-divider-deep rounded-[5px] bg-components-badge-bg-dimm'>
|
||||
<RiStarLine className='flex-shrink-0 size-3 text-text-tertiary' />
|
||||
<GithubStar className='system-2xs-medium-uppercase text-text-tertiary' />
|
||||
</div>
|
||||
</Link>}
|
||||
</Menu.Item>}
|
||||
{
|
||||
document?.body?.getAttribute('data-public-site-about') !== 'hide' && (
|
||||
<Menu.Item>
|
||||
{({ active }) => <div className={classNames(itemClassName, 'justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)} onClick={() => setAboutVisible(true)}>
|
||||
<RiInformation2Line className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.about')}</div>
|
||||
<div className='flex-shrink-0 flex items-center'>
|
||||
<div>{t('common.userProfile.about')}</div>
|
||||
<div className='flex items-center'>
|
||||
<div className='mr-2 system-xs-regular text-text-tertiary'>{langeniusVersionInfo.current_version}</div>
|
||||
<Indicator color={langeniusVersionInfo.current_version === langeniusVersionInfo.latest_version ? 'green' : 'orange'} />
|
||||
</div>
|
||||
@@ -191,12 +198,12 @@ export default function AppSelector({ isMobile }: IAppSelector) {
|
||||
<Menu.Item>
|
||||
{({ active }) => <div className='p-1' onClick={() => handleLogout()}>
|
||||
<div
|
||||
className={classNames(itemClassName, 'group justify-between',
|
||||
active && 'bg-state-base-hover',
|
||||
)}
|
||||
className={
|
||||
classNames('flex items-center justify-between h-9 px-3 rounded-lg cursor-pointer group hover:bg-state-base-hover',
|
||||
active && 'bg-state-base-hover')}
|
||||
>
|
||||
<RiLogoutBoxRLine className='flex-shrink-0 size-4 text-text-tertiary' />
|
||||
<div className='flex-grow system-md-regular text-text-secondary px-1'>{t('common.userProfile.logout')}</div>
|
||||
<div className='system-md-regular text-text-secondary'>{t('common.userProfile.logout')}</div>
|
||||
<RiLogoutBoxRLine className='hidden w-4 h-4 text-text-tertiary group-hover:flex' />
|
||||
</div>
|
||||
</div>}
|
||||
</Menu.Item>
|
||||
|
@@ -1,94 +0,0 @@
|
||||
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 px-1'>{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 px-1'>{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 px-1'>{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 px-1'>{t('common.userProfile.community')}</div>
|
||||
<RiArrowRightUpLine className='flex-shrink-0 size-[14px] text-text-tertiary' />
|
||||
</Link>}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
</>
|
||||
)
|
||||
}
|
||||
</Menu>
|
||||
}
|
@@ -9,18 +9,19 @@ import { useWorkspacesContext } from '@/context/workspace-context'
|
||||
import { ChevronRight } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||
import { Check } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
import classNames from '@/utils/classnames'
|
||||
|
||||
const itemClassName = `
|
||||
flex items-center px-3 py-2 h-9 cursor-pointer rounded-lg
|
||||
flex items-center px-3 py-2 h-10 cursor-pointer
|
||||
`
|
||||
const itemIconClassName = `
|
||||
shrink-0 mr-2 flex items-center justify-center w-6 h-6 bg-[#EFF4FF] rounded-md text-xs font-medium text-text-accent
|
||||
shrink-0 mr-2 flex items-center justify-center w-6 h-6 bg-[#EFF4FF] rounded-md text-xs font-medium text-primary-600
|
||||
`
|
||||
const itemNameClassName = `
|
||||
grow mr-2 text-sm text-text-secondary text-left
|
||||
grow mr-2 text-sm text-gray-700 text-left
|
||||
`
|
||||
const itemCheckClassName = `
|
||||
shrink-0 w-4 h-4 text-text-accent
|
||||
shrink-0 w-4 h-4 text-primary-600
|
||||
`
|
||||
|
||||
const WorkplaceSelector = () => {
|
||||
@@ -47,15 +48,15 @@ const WorkplaceSelector = () => {
|
||||
{
|
||||
({ open }) => (
|
||||
<>
|
||||
<Menu.Button className={cn(itemClassName,
|
||||
<Menu.Button className={cn(
|
||||
`
|
||||
w-full group hover:bg-state-base-hover pl-3 pr-2
|
||||
${itemClassName} w-full
|
||||
group hover:bg-state-base-hover cursor-pointer ${open && 'bg-state-base-hover'} rounded-lg
|
||||
`,
|
||||
open && 'bg-state-base-hover',
|
||||
)}>
|
||||
<div className={itemIconClassName}>{currentWorkspace?.name[0].toLocaleUpperCase()}</div>
|
||||
<div className={`${itemNameClassName} truncate px-1`}>{currentWorkspace?.name}</div>
|
||||
<ChevronRight className='shrink-0 size-[14px] text-text-tertiary' />
|
||||
<div className={`${itemNameClassName} truncate`}>{currentWorkspace?.name}</div>
|
||||
<ChevronRight className='shrink-0 w-[14px] h-[14px] text-gray-500' />
|
||||
</Menu.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
@@ -69,8 +70,8 @@ const WorkplaceSelector = () => {
|
||||
<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
|
||||
absolute top-[1px] min-w-[200px] max-h-[70vh] overflow-y-scroll z-10 bg-white border-[0.5px] border-gray-200
|
||||
divide-y divide-gray-100 origin-top-right rounded-xl focus:outline-none
|
||||
`,
|
||||
s.popup,
|
||||
)}
|
||||
@@ -79,7 +80,7 @@ const WorkplaceSelector = () => {
|
||||
{
|
||||
workspaces.map(workspace => (
|
||||
<Menu.Item key={workspace.id}>
|
||||
{({ active }) => <div className={cn(itemClassName,
|
||||
{({ active }) => <div className={classNames(itemClassName,
|
||||
active && 'bg-state-base-hover',
|
||||
)} key={workspace.id} onClick={() => handleSwitchWorkspace(workspace.id)}>
|
||||
<div className={itemIconClassName}>{workspace.name[0].toLocaleUpperCase()}</div>
|
||||
|
Reference in New Issue
Block a user