feat: no linked app ui

pull/12097/head
Joel 1 year ago
parent dd23f1093b
commit 87e284ef75

@ -7,27 +7,21 @@ import { useTranslation } from 'react-i18next'
import { useBoolean } from 'ahooks' import { useBoolean } from 'ahooks'
import { import {
Cog8ToothIcon, Cog8ToothIcon,
// CommandLineIcon,
Squares2X2Icon,
// eslint-disable-next-line sort-imports
PuzzlePieceIcon,
DocumentTextIcon, DocumentTextIcon,
PaperClipIcon, PaperClipIcon,
QuestionMarkCircleIcon,
} from '@heroicons/react/24/outline' } from '@heroicons/react/24/outline'
import { import {
Cog8ToothIcon as Cog8ToothSolidIcon, Cog8ToothIcon as Cog8ToothSolidIcon,
// CommandLineIcon as CommandLineSolidIcon, // CommandLineIcon as CommandLineSolidIcon,
DocumentTextIcon as DocumentTextSolidIcon, DocumentTextIcon as DocumentTextSolidIcon,
} from '@heroicons/react/24/solid' } from '@heroicons/react/24/solid'
import { RiInformation2Line } from '@remixicon/react' import { RiApps2AddLine, RiInformation2Line } from '@remixicon/react'
import s from './style.module.css' import s from './style.module.css'
import classNames from '@/utils/classnames' import classNames from '@/utils/classnames'
import { fetchDatasetDetail, fetchDatasetRelatedApps } from '@/service/datasets' import { fetchDatasetDetail, fetchDatasetRelatedApps } from '@/service/datasets'
import type { RelatedAppResponse } from '@/models/datasets' import type { RelatedAppResponse } from '@/models/datasets'
import AppSideBar from '@/app/components/app-sidebar' import AppSideBar from '@/app/components/app-sidebar'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import FloatPopoverContainer from '@/app/components/base/float-popover-container'
import DatasetDetailContext from '@/context/dataset-detail' import DatasetDetailContext from '@/context/dataset-detail'
import { DataSourceType } from '@/models/datasets' import { DataSourceType } from '@/models/datasets'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
@ -74,9 +68,10 @@ const BookOpenIcon = ({ className }: SVGProps<SVGElement>) => {
type IExtraInfoProps = { type IExtraInfoProps = {
isMobile: boolean isMobile: boolean
relatedApps?: RelatedAppResponse relatedApps?: RelatedAppResponse
expand: boolean
} }
const ExtraInfo = ({ isMobile, relatedApps }: IExtraInfoProps) => { const ExtraInfo = ({ isMobile, relatedApps, expand }: IExtraInfoProps) => {
const locale = getLocaleOnClient() const locale = getLocaleOnClient()
const [isShowTips, { toggle: toggleTips, set: setShowTips }] = useBoolean(!isMobile) const [isShowTips, { toggle: toggleTips, set: setShowTips }] = useBoolean(!isMobile)
const { t } = useTranslation() const { t } = useTranslation()
@ -114,45 +109,39 @@ const ExtraInfo = ({ isMobile, relatedApps }: IExtraInfoProps) => {
{relatedAppsTotal || '--'} {relatedAppsTotal || '--'}
<PaperClipIcon className='h-4 w-4 text-gray-700' /> <PaperClipIcon className='h-4 w-4 text-gray-700' />
</div>} </div>}
</> </>
)} )}
{!hasRelatedApps && ( {!hasRelatedApps && !expand && (
<FloatPopoverContainer <Tooltip
placement='bottom-start' position='right'
open={isShowTips} noDecoration
toggle={toggleTips} needsDelay
isMobile={isMobile} popupContent={
triggerElement={ <div className='p-4 w-[240px] bg-components-panel-bg-blur border-[0.5px] border-components-panel-border rounded-xl'>
<div className={classNames('h-7 w-7 inline-flex justify-center items-center rounded-lg bg-transparent', isShowTips && '!bg-gray-50')}> <div className='inline-flex p-2 rounded-lg border-[0.5px] border-components-panel-border-subtle bg-background-default-subtle'>
<QuestionMarkCircleIcon className='h-4 w-4 flex-shrink-0 text-gray-500' /> <RiApps2AddLine className='h-4 w-4 text-text-tertiary' />
</div>
<div className='text-xs text-text-tertiary my-2'>{t('common.datasetMenus.emptyTip')}</div>
<a
className='inline-flex items-center text-xs text-text-accent mt-2 cursor-pointer'
href={
locale === LanguagesSupported[1]
? 'https://docs.dify.ai/v/zh-hans/guides/knowledge-base/integrate-knowledge-within-application'
: 'https://docs.dify.ai/guides/knowledge-base/integrate-knowledge-within-application'
}
target='_blank' rel='noopener noreferrer'
>
<BookOpenIcon className='mr-1' />
{t('common.datasetMenus.viewDoc')}
</a>
</div> </div>
} }
> >
<div className={classNames('mt-5 p-3', isMobile && 'border-[0.5px] border-gray-200 shadow-lg rounded-lg bg-white w-[160px]')}> <div className='inline-flex items-center system-xs-medium-uppercase text-text-secondary space-x-1 cursor-pointer'>
<div className='flex items-center justify-start gap-2'> <span>{t('common.datasetMenus.noRelatedApp')}</span>
<div className={s.emptyIconDiv}> <RiInformation2Line className='w-4 h-4' />
<Squares2X2Icon className='w-3 h-3 text-gray-500' />
</div>
<div className={s.emptyIconDiv}>
<PuzzlePieceIcon className='w-3 h-3 text-gray-500' />
</div>
</div>
<div className='text-xs text-gray-500 mt-2'>{t('common.datasetMenus.emptyTip')}</div>
<a
className='inline-flex items-center text-xs text-primary-600 mt-2 cursor-pointer'
href={
locale === LanguagesSupported[1]
? 'https://docs.dify.ai/v/zh-hans/guides/knowledge-base/integrate_knowledge_within_application'
: 'https://docs.dify.ai/guides/knowledge-base/integrate-knowledge-within-application'
}
target='_blank' rel='noopener noreferrer'
>
<BookOpenIcon className='mr-1' />
{t('common.datasetMenus.viewDoc')}
</a>
</div> </div>
</FloatPopoverContainer> </Tooltip>
)} )}
</div> </div>
} }
@ -223,7 +212,7 @@ const DatasetDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
desc={datasetRes?.description || '--'} desc={datasetRes?.description || '--'}
isExternal={datasetRes?.provider === 'external'} isExternal={datasetRes?.provider === 'external'}
navigation={navigation} navigation={navigation}
extraInfo={!isCurrentWorkspaceDatasetOperator ? mode => <ExtraInfo isMobile={mode === 'collapse'} relatedApps={relatedApps} /> : undefined} extraInfo={!isCurrentWorkspaceDatasetOperator ? mode => <ExtraInfo isMobile={mode === 'collapse'} relatedApps={relatedApps} expand={mode === 'collapse'} /> : undefined}
iconType={datasetRes?.data_source_type === DataSourceType.NOTION ? 'notion' : 'dataset'} iconType={datasetRes?.data_source_type === DataSourceType.NOTION ? 'notion' : 'dataset'}
/>} />}
<DatasetDetailContext.Provider value={{ <DatasetDetailContext.Provider value={{

@ -474,9 +474,10 @@ const translation = {
documents: 'Documents', documents: 'Documents',
hitTesting: 'Retrieval Testing', hitTesting: 'Retrieval Testing',
settings: 'Settings', settings: 'Settings',
emptyTip: 'The Knowledge has not been associated, please go to the application or plug-in to complete the association.', emptyTip: 'This Knowledge has not been integrated within any application. Please refer to the document for guidance.',
viewDoc: 'View documentation', viewDoc: 'View documentation',
relatedApp: 'linked apps', relatedApp: 'linked apps',
noRelatedApp: 'No linked apps',
}, },
voiceInput: { voiceInput: {
speaking: 'Speak now...', speaking: 'Speak now...',

@ -474,9 +474,10 @@ const translation = {
documents: '文档', documents: '文档',
hitTesting: '召回测试', hitTesting: '召回测试',
settings: '设置', settings: '设置',
emptyTip: ' 知识库尚未关联,请前往应用程序或插件完成关联。', emptyTip: '此知识尚未集成到任何应用程序中。请参阅文档以获取指导。',
viewDoc: '查看文档', viewDoc: '查看文档',
relatedApp: '个关联应用', relatedApp: '个关联应用',
noRelatedApp: '无关联应用',
}, },
voiceInput: { voiceInput: {
speaking: '现在讲...', speaking: '现在讲...',

Loading…
Cancel
Save