'use client' import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import { PlusIcon } from '@heroicons/react/24/solid' import type { ConfigItemType } from './config-item' import ConfigItem from './config-item' import s from './style.module.css' import { DataSourceType } from './types' import { DataSourceProvider } from '@/models/common' import cn from '@/utils/classnames' type Props = { type: DataSourceType provider: DataSourceProvider isConfigured: boolean onConfigure: () => void readOnly: boolean isSupportList?: boolean configuredList: ConfigItemType[] onRemove: () => void notionActions?: { onChangeAuthorizedPage: () => void } } const Panel: FC = ({ type, provider, isConfigured, onConfigure, readOnly, configuredList, isSupportList, onRemove, notionActions, }) => { const { t } = useTranslation() const isNotion = type === DataSourceType.notion const isWebsite = type === DataSourceType.website return (
{t(`common.dataSource.${type}.title`)}
{isWebsite && (
{t('common.dataSource.website.with')} { provider === DataSourceProvider.fireCrawl ? '🔥 Firecrawl' : 'Jina Reader'}
)}
{ !isConfigured && (
{t(`common.dataSource.${type}.description`)}
) }
{isNotion && ( <> { isConfigured ? (
{t('common.dataSource.configure')}
) : ( <> {isSupportList &&
{t('common.dataSource.notion.addWorkspace')}
} ) } )} {isWebsite && !isConfigured && (
{t('common.dataSource.configure')}
)}
{ isConfigured && ( <>
{isNotion ? t('common.dataSource.notion.connectedWorkspace') : t('common.dataSource.website.configuredCrawlers')}
{ configuredList.map(item => ( )) }
) }
) } export default React.memo(Panel)