/* * Copyright 2025 coze-dev Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type ReactNode, useState } from 'react'; import cls from 'classnames'; import { I18n } from '@coze-arch/i18n'; import { IconCozInfoCircle } from '@coze-arch/coze-design/icons'; import { Search, Tooltip } from '@coze-arch/coze-design'; import { type ILevelSegment } from '@coze-data/knowledge-stores'; import MergeOperation from '../assets/merge-operation.png'; import MergeOperationEn from '../assets/merge-operation-en.png'; import LevelOperation from '../assets/level-operation.png'; import DeleteOperation from '../assets/delete-operation.png'; import DeleteOperationEn from '../assets/delete-operation-en.png'; import { SegmentTree } from './segment-tree'; import DocumentItem from './document-item'; interface IMenuItem { id: string; title: string; label?: ReactNode; tag?: ReactNode; tosUrl?: string; } interface ISegmentMenuProps { list: IMenuItem[]; onClick?: (id: string) => void; selectedID?: string; isSearchable?: boolean; treeVisible?: boolean; treeDisabled?: boolean; levelSegments?: ILevelSegment[]; setLevelSegments?: (segments: ILevelSegment[]) => void; setSelectionIDs?: (ids: string[]) => void; } const SegmentMenu: React.FC = props => { const { isSearchable, list, onClick, selectedID, levelSegments, setLevelSegments, setSelectionIDs, treeDisabled, treeVisible, } = props; const [searchValue, setSearchValue] = useState(''); return (
{isSearchable ? ( ) : null}
{/**文档列表 */} {I18n.t('knowledge_level_012')}
{list .filter(item => item.title.includes(searchValue)) .map(document => { if (document.id !== '') { return ( ); } else { return null; } })}
{levelSegments?.length && treeVisible ? ( <>
{/**分段层级 */} {I18n.t('knowledge_level_adjust')}
{treeDisabled ? null : (
{I18n.t('knowledge_hierarchies_categories')}
{I18n.t('level_999')}
{I18n.t('level_998')}
{I18n.t('level_997')}
} >
)}
) : null}
); }; export default SegmentMenu;