mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: add file icon to table of FileManager #345 fix: modify datasetDescription ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,14 +1,16 @@
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { Form, Modal, Select, SelectProps } from 'antd';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const ConnectToKnowledgeModal = ({
|
||||
visible,
|
||||
hideModal,
|
||||
onOk,
|
||||
}: IModalProps<string[]>) => {
|
||||
initialValue,
|
||||
}: IModalProps<string[]> & { initialValue: string[] }) => {
|
||||
const [form] = Form.useForm();
|
||||
const { list } = useFetchKnowledgeList();
|
||||
const { list, fetchList } = useFetchKnowledgeList();
|
||||
|
||||
const options: SelectProps['options'] = list?.map((item) => ({
|
||||
label: item.name,
|
||||
@ -18,11 +20,16 @@ const ConnectToKnowledgeModal = ({
|
||||
const handleOk = async () => {
|
||||
const values = await form.getFieldsValue();
|
||||
const knowledgeIds = values.knowledgeIds ?? [];
|
||||
if (knowledgeIds.length > 0) {
|
||||
return onOk?.(knowledgeIds);
|
||||
}
|
||||
return onOk?.(knowledgeIds);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
form.setFieldValue('knowledgeIds', initialValue);
|
||||
fetchList();
|
||||
}
|
||||
}, [visible, fetchList, initialValue, form]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="Add to Knowledge Base"
|
||||
@ -31,17 +38,7 @@ const ConnectToKnowledgeModal = ({
|
||||
onCancel={hideModal}
|
||||
>
|
||||
<Form form={form}>
|
||||
<Form.Item
|
||||
name="knowledgeIds"
|
||||
noStyle
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please select your favourite colors!',
|
||||
type: 'array',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Form.Item name="knowledgeIds" noStyle>
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
|
||||
Reference in New Issue
Block a user