feat: add tooltip when user has no access permission

pull/18656/head
NFish 1 year ago
parent 6826860287
commit c98f18666d

@ -12,6 +12,7 @@ import type { ModelAndParameter } from '../configuration/debug/types'
import Divider from '../../base/divider' import Divider from '../../base/divider'
import AccessControl from '../app-access-control' import AccessControl from '../app-access-control'
import Loading from '../../base/loading' import Loading from '../../base/loading'
import Tooltip from '../../base/tooltip'
import SuggestedAction from './suggested-action' import SuggestedAction from './suggested-action'
import PublishWithMultipleModel from './publish-with-multiple-model' import PublishWithMultipleModel from './publish-with-multiple-model'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
@ -251,10 +252,12 @@ const AppPublisher = ({
</div> </div>
</div> </div>
</div> </div>
<div className='p-4 pt-3 border-t-[0.5px] border-t-black/5'> <div className='p-4 pt-3 border-t-[0.5px] border-t-black/5 flex flex-col gap-y-1'>
<Tooltip triggerClassName='flex' disabled={useCanAccessApp?.result} popupContent={t('app.noAccessPermission')} asChild={false}>
<SuggestedAction disabled={!publishedAt || !useCanAccessApp?.result} link={appURL} icon={<PlayCircle />}>{t('workflow.common.runApp')}</SuggestedAction> <SuggestedAction disabled={!publishedAt || !useCanAccessApp?.result} link={appURL} icon={<PlayCircle />}>{t('workflow.common.runApp')}</SuggestedAction>
</Tooltip>
{appDetail?.mode === 'workflow' {appDetail?.mode === 'workflow'
? ( ? (<Tooltip triggerClassName='flex' disabled={useCanAccessApp?.result} popupContent={t('app.noAccessPermission')} asChild={false}>
<SuggestedAction <SuggestedAction
disabled={!publishedAt || !useCanAccessApp?.result} disabled={!publishedAt || !useCanAccessApp?.result}
link={`${appURL}${appURL.includes('?') ? '&' : '?'}mode=batch`} link={`${appURL}${appURL.includes('?') ? '&' : '?'}mode=batch`}
@ -262,8 +265,9 @@ const AppPublisher = ({
> >
{t('workflow.common.batchRunApp')} {t('workflow.common.batchRunApp')}
</SuggestedAction> </SuggestedAction>
</Tooltip>
) )
: ( : (<Tooltip triggerClassName='flex' disabled={useCanAccessApp?.result} popupContent={t('app.noAccessPermission')} asChild={false}>
<SuggestedAction <SuggestedAction
onClick={() => { onClick={() => {
setEmbeddingModalOpen(true) setEmbeddingModalOpen(true)
@ -274,7 +278,9 @@ const AppPublisher = ({
> >
{t('workflow.common.embedIntoSite')} {t('workflow.common.embedIntoSite')}
</SuggestedAction> </SuggestedAction>
</Tooltip>
)} )}
<Tooltip triggerClassName='flex' disabled={useCanAccessApp?.result} popupContent={t('app.noAccessPermission')} asChild={false}>
<SuggestedAction <SuggestedAction
onClick={() => { onClick={() => {
handleOpenInExplore() handleOpenInExplore()
@ -284,8 +290,13 @@ const AppPublisher = ({
> >
{t('workflow.common.openInExplore')} {t('workflow.common.openInExplore')}
</SuggestedAction> </SuggestedAction>
</Tooltip>
<Tooltip triggerClassName='flex' disabled={useCanAccessApp?.result} popupContent={t('app.noAccessPermission')} asChild={false}>
<SuggestedAction disabled={!publishedAt || !useCanAccessApp?.result} link='./develop' icon={<FileText className='w-4 h-4' />}>{t('workflow.common.accessAPIReference')}</SuggestedAction> <SuggestedAction disabled={!publishedAt || !useCanAccessApp?.result} link='./develop' icon={<FileText className='w-4 h-4' />}>{t('workflow.common.accessAPIReference')}</SuggestedAction>
</Tooltip>
{appDetail?.mode === 'workflow' && ( {appDetail?.mode === 'workflow' && (
<Tooltip triggerClassName='flex' disabled={useCanAccessApp?.result} popupContent={t('app.noAccessPermission')} asChild={false}>
<WorkflowToolConfigureButton <WorkflowToolConfigureButton
disabled={!publishedAt || !useCanAccessApp?.result} disabled={!publishedAt || !useCanAccessApp?.result}
published={!!toolPublished} published={!!toolPublished}
@ -301,6 +312,7 @@ const AppPublisher = ({
handlePublish={handlePublish} handlePublish={handlePublish}
onRefreshData={onRefreshData} onRefreshData={onRefreshData}
/> />
</Tooltip>
)} )}
</div> </div>
</>} </>}

@ -14,7 +14,7 @@ const SuggestedAction = ({ icon, link, disabled, children, className, ...props }
target='_blank' target='_blank'
rel='noreferrer' rel='noreferrer'
className={classNames( className={classNames(
'flex justify-start items-center gap-2 h-[34px] px-2.5 bg-gray-100 rounded-lg transition-colors [&:not(:first-child)]:mt-1', 'flex-1 flex justify-start items-center gap-2 h-[34px] px-2.5 bg-gray-100 rounded-lg transition-colors [&:not(:first-child)]:mt-1',
disabled ? 'shadow-xs opacity-30 cursor-not-allowed' : 'hover:bg-primary-50 hover:text-primary-600 cursor-pointer', disabled ? 'shadow-xs opacity-30 cursor-not-allowed' : 'hover:bg-primary-50 hover:text-primary-600 cursor-pointer',
className, className,
)} )}

@ -90,6 +90,7 @@ const Tooltip: FC<TooltipProps> = ({
}} }}
onMouseLeave={() => triggerMethod === 'hover' && handleLeave(true)} onMouseLeave={() => triggerMethod === 'hover' && handleLeave(true)}
asChild={asChild} asChild={asChild}
className={!asChild ? triggerClassName : ''}
> >
{children || <div className={triggerClassName || 'p-[1px] w-3.5 h-3.5 shrink-0'}><RiQuestionLine className='text-text-quaternary hover:text-text-tertiary w-full h-full' /></div>} {children || <div className={triggerClassName || 'p-[1px] w-3.5 h-3.5 shrink-0'}><RiQuestionLine className='text-text-quaternary hover:text-text-tertiary w-full h-full' /></div>}
</PortalToFollowElemTrigger> </PortalToFollowElemTrigger>

@ -65,7 +65,7 @@ const translation = {
more: { more: {
entry: 'Show more settings', entry: 'Show more settings',
copyright: 'Copyright', copyright: 'Copyright',
copyrightTip: 'Display copyright information in the webapp', copyrightTip: 'Display copyright information in the web app',
copyrightTooltip: 'Please upgrade to Professional plan or above', copyrightTooltip: 'Please upgrade to Professional plan or above',
copyRightPlaceholder: 'Enter the name of the author or organization', copyRightPlaceholder: 'Enter the name of the author or organization',
privacyPolicy: 'Privacy Policy', privacyPolicy: 'Privacy Policy',

@ -174,10 +174,10 @@ const translation = {
}, },
}, },
showMyCreatedAppsOnly: 'Created by me', showMyCreatedAppsOnly: 'Created by me',
accessControl: 'Webapp Access Control', accessControl: 'web app Access Control',
accessControlDialog: { accessControlDialog: {
title: 'Access Control', title: 'Access Control',
description: 'Set webapp access permissions', description: 'Set web app access permissions',
accessLabel: 'Who has access', accessLabel: 'Who has access',
accessItems: { accessItems: {
anyone: 'Anyone with the link', anyone: 'Anyone with the link',
@ -202,6 +202,7 @@ const translation = {
title: 'Who can access web app', title: 'Who can access web app',
notSet: 'Not set', notSet: 'Not set',
}, },
noAccessPermission: 'No access permission',
} }
export default translation export default translation

@ -105,7 +105,7 @@ const translation = {
licenseInactive: 'License Inactive', licenseInactive: 'License Inactive',
licenseInactiveTip: 'The Dify Enterprise license for your workspace is inactive. Please contact your administrator to continue using Dify.', licenseInactiveTip: 'The Dify Enterprise license for your workspace is inactive. Please contact your administrator to continue using Dify.',
webapp: { webapp: {
noLoginMethod: 'Authentication method not configured for webapp', noLoginMethod: 'Authentication method not configured for web app',
noLoginMethodTip: 'Please contact the system admin to add an authentication method.', noLoginMethodTip: 'Please contact the system admin to add an authentication method.',
disabled: 'Webapp authentication is disabled. Please contact the system admin to enable it. You can try to use the app directly.', disabled: 'Webapp authentication is disabled. Please contact the system admin to enable it. You can try to use the app directly.',
}, },

@ -73,7 +73,7 @@ const translation = {
'Inserisci il testo del disclaimer personalizzato', 'Inserisci il testo del disclaimer personalizzato',
customDisclaimerTip: customDisclaimerTip:
'Il testo del disclaimer personalizzato verrà visualizzato sul lato client, fornendo informazioni aggiuntive sull\'applicazione', 'Il testo del disclaimer personalizzato verrà visualizzato sul lato client, fornendo informazioni aggiuntive sull\'applicazione',
copyrightTip: 'Visualizzare le informazioni sul copyright nella webapp', copyrightTip: 'Visualizzare le informazioni sul copyright nella web app',
copyrightTooltip: 'Si prega di eseguire l\'upgrade al piano Professional o superiore', copyrightTooltip: 'Si prega di eseguire l\'upgrade al piano Professional o superiore',
}, },
sso: { sso: {

@ -65,7 +65,7 @@ const translation = {
customDisclaimer: 'Aviso Legal Personalizado', customDisclaimer: 'Aviso Legal Personalizado',
customDisclaimerPlaceholder: 'Insira o texto do aviso legal', customDisclaimerPlaceholder: 'Insira o texto do aviso legal',
customDisclaimerTip: 'O texto do aviso legal personalizado será exibido no lado do cliente, fornecendo informações adicionais sobre o aplicativo', customDisclaimerTip: 'O texto do aviso legal personalizado será exibido no lado do cliente, fornecendo informações adicionais sobre o aplicativo',
copyrightTip: 'Exibir informações de direitos autorais no webapp', copyrightTip: 'Exibir informações de direitos autorais no web app',
copyrightTooltip: 'Por favor, atualize para o plano Professional ou superior', copyrightTooltip: 'Por favor, atualize para o plano Professional ou superior',
}, },
sso: { sso: {

@ -214,7 +214,7 @@ const translation = {
modalTitle: '图片上传设置', modalTitle: '图片上传设置',
}, },
bar: { bar: {
empty: '开启功能增强 webapp 用户体验', empty: '开启功能增强 web app 用户体验',
enableText: '功能已开启', enableText: '功能已开启',
manage: '管理', manage: '管理',
}, },

Loading…
Cancel
Save