import type { Operation } from './app-operations' import type { AppInfoModalType } from './use-app-info-actions' import type { App, AppSSO } from '@/types/app' import { RiDeleteBinLine, RiEditLine, RiExchange2Line, RiFileCopy2Line, RiFileDownloadLine, RiFileUploadLine, } from '@remixicon/react' import * as React from 'react' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import CardView from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view' import Button from '@/app/components/base/button' import ContentDialog from '@/app/components/base/content-dialog' import { AppModeEnum } from '@/types/app' import AppIcon from '../../base/app-icon' import { getAppModeLabel } from './app-mode-labels' import AppOperations from './app-operations' type AppInfoDetailPanelProps = { appDetail: App & Partial show: boolean onClose: () => void openModal: (modal: Exclude) => void exportCheck: () => void } const AppInfoDetailPanel = ({ appDetail, show, onClose, openModal, exportCheck, }: AppInfoDetailPanelProps) => { const { t } = useTranslation() const primaryOperations = useMemo(() => [ { id: 'edit', title: t('editApp', { ns: 'app' }), icon: , onClick: () => openModal('edit'), }, { id: 'duplicate', title: t('duplicate', { ns: 'app' }), icon: , onClick: () => openModal('duplicate'), }, { id: 'export', title: t('export', { ns: 'app' }), icon: , onClick: exportCheck, }, ], [t, openModal, exportCheck]) const secondaryOperations = useMemo(() => [ ...(appDetail.mode === AppModeEnum.ADVANCED_CHAT || appDetail.mode === AppModeEnum.WORKFLOW) ? [{ id: 'import', title: t('common.importDSL', { ns: 'workflow' }), icon: , onClick: () => openModal('importDSL'), }] : [], { id: 'divider-1', title: '', icon: <>, onClick: () => {}, type: 'divider' as const, }, { id: 'delete', title: t('operation.delete', { ns: 'common' }), icon: , onClick: () => openModal('delete'), }, ], [appDetail.mode, t, openModal]) const switchOperation = useMemo(() => { if (appDetail.mode !== AppModeEnum.COMPLETION && appDetail.mode !== AppModeEnum.CHAT) return null return { id: 'switch', title: t('switch', { ns: 'app' }), icon: , onClick: () => openModal('switch'), } }, [appDetail.mode, t, openModal]) return (
{appDetail.name}
{getAppModeLabel(appDetail.mode, t)}
{appDetail.description && (
{appDetail.description}
)}
{switchOperation && (
)}
) } export default React.memo(AppInfoDetailPanel)