import React, { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { RiApps2AddLine, RiArrowRightLine, RiSparklingFill } from '@remixicon/react' import { Citations, ContentModeration, FolderUpload, LoveMessage, MessageFast, Microphone01, TextToAudio, VirtualAssistant } from '@/app/components/base/icons/src/vender/features' import Button from '@/app/components/base/button' import Tooltip from '@/app/components/base/tooltip' import VoiceSettings from '@/app/components/base/features/new-feature-panel/text-to-speech/voice-settings' import { useFeatures } from '@/app/components/base/features/hooks' import cn from '@/utils/classnames' type Props = { isChatMode?: boolean showFileUpload?: boolean disabled?: boolean onFeatureBarClick?: (state: boolean) => void } const FeatureBar = ({ isChatMode = true, showFileUpload = true, disabled, onFeatureBarClick, }: Props) => { const { t } = useTranslation() const features = useFeatures(s => s.features) const [modalOpen, setModalOpen] = useState(false) const noFeatureEnabled = useMemo(() => { // completion app citation is always true but not enabled for setting const data = { ...features, citation: { enabled: isChatMode ? features.citation?.enabled : false }, file: showFileUpload ? features.file! : { enabled: false }, } return !Object.values(data).some(f => f.enabled) }, [features, isChatMode, showFileUpload]) return (
{noFeatureEnabled && (
onFeatureBarClick?.(true)}>
{t('appDebug.feature.bar.empty')}
)} {!noFeatureEnabled && (
{!!features.moreLikeThis?.enabled && (
)} {!!features.opening?.enabled && (
)} {!!features.moderation?.enabled && (
)} {!!features.speech2text?.enabled && (
)} {!!features.text2speech?.enabled && (
)} {showFileUpload && !!features.file?.enabled && (
)} {!!features.suggested?.enabled && (
)} {isChatMode && !!features.citation?.enabled && (
)} {isChatMode && !!features.annotationReply?.enabled && (
)}
{t('appDebug.feature.bar.enableText')}
)}
) } export default FeatureBar