fix:Optimized the style of the dataset configuration page and added the l… (#8655)

### What problem does this PR solve?

Optimized the style of the dataset configuration page and added the
logic of cancelling submission
[#3221](https://github.com/infiniflow/ragflow/issues/3221)

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
dcc123456
2025-07-04 15:11:30 +08:00
committed by GitHub
parent b382b63f9a
commit 1cf24be04b
8 changed files with 71 additions and 82 deletions

View File

@ -207,6 +207,7 @@ export default {
'Update your knowledge base configuration here, particularly the chunking method.', 'Update your knowledge base configuration here, particularly the chunking method.',
name: 'Knowledge base name', name: 'Knowledge base name',
photo: 'Knowledge base photo', photo: 'Knowledge base photo',
photoTip: 'You can upload a file with 4 MB',
description: 'Description', description: 'Description',
language: 'Document language', language: 'Document language',
languageMessage: 'Please input your language!', languageMessage: 'Please input your language!',

View File

@ -205,6 +205,7 @@ export default {
titleDescription: '在這裡更新您的知識庫詳細信息,尤其是切片方法。', titleDescription: '在這裡更新您的知識庫詳細信息,尤其是切片方法。',
name: '知識庫名稱', name: '知識庫名稱',
photo: '知識庫圖片', photo: '知識庫圖片',
photoTip: '你可以上傳4MB的文件',
description: '描述', description: '描述',
language: '文件語言', language: '文件語言',
languageMessage: '請輸入語言', languageMessage: '請輸入語言',

View File

@ -205,6 +205,7 @@ export default {
titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。', titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。',
name: '知识库名称', name: '知识库名称',
photo: '知识库图片', photo: '知识库图片',
photoTip: '你可以上传4MB的文件',
description: '描述', description: '描述',
language: '文档语言', language: '文档语言',
languageMessage: '请输入语言', languageMessage: '请输入语言',

View File

@ -12,7 +12,9 @@ import {
} from '@/components/ui/dropdown-menu'; } from '@/components/ui/dropdown-menu';
import { useRowSelection } from '@/hooks/logic-hooks/use-row-selection'; import { useRowSelection } from '@/hooks/logic-hooks/use-row-selection';
import { useFetchDocumentList } from '@/hooks/use-document-request'; import { useFetchDocumentList } from '@/hooks/use-document-request';
import { IDocumentInfo } from '@/interfaces/database/document';
import { Upload } from 'lucide-react'; import { Upload } from 'lucide-react';
import { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { DatasetTable } from './dataset-table'; import { DatasetTable } from './dataset-table';
import { useBulkOperateDataset } from './use-bulk-operate-dataset'; import { useBulkOperateDataset } from './use-bulk-operate-dataset';
@ -40,7 +42,16 @@ export default function Dataset() {
handleFilterSubmit, handleFilterSubmit,
loading, loading,
} = useFetchDocumentList(); } = useFetchDocumentList();
const { filters } = useSelectDatasetFilters(); const { filters, documents: filteredDocuments } = useSelectDatasetFilters();
const [datasetInfo, setDatasetInfo] = useState<IDocumentInfo[]>(documents);
useMemo(() => {
setDatasetInfo(documents);
}, [documents]);
useMemo(() => {
setDatasetInfo(filteredDocuments);
}, [filteredDocuments]);
const { const {
createLoading, createLoading,
@ -100,7 +111,7 @@ export default function Dataset() {
<BulkOperateBar list={list} count={selectedCount}></BulkOperateBar> <BulkOperateBar list={list} count={selectedCount}></BulkOperateBar>
)} )}
<DatasetTable <DatasetTable
documents={documents} documents={datasetInfo}
pagination={pagination} pagination={pagination}
setPagination={setPagination} setPagination={setPagination}
rowSelection={rowSelection} rowSelection={rowSelection}

View File

@ -19,7 +19,6 @@ export function useSelectDatasetFilters() {
label: t(`knowledgeDetails.runningStatus${x.label}`), label: t(`knowledgeDetails.runningStatus${x.label}`),
})); }));
}, [documents, t]); }, [documents, t]);
const filters = useMemo(() => { const filters = useMemo(() => {
return [ return [
{ field: 'type', label: 'File Type', list: fileTypes }, { field: 'type', label: 'File Type', list: fileTypes },
@ -27,5 +26,5 @@ export function useSelectDatasetFilters() {
]; ];
}, [fileStatus, fileTypes]); }, [fileStatus, fileTypes]);
return { fileTypes, fileStatus, filters }; return { fileTypes, fileStatus, filters, documents };
} }

View File

@ -70,15 +70,22 @@ export function ChunkMethodForm() {
<section className="overflow-auto max-h-[76vh]"> <section className="overflow-auto max-h-[76vh]">
<ConfigurationComponent></ConfigurationComponent> <ConfigurationComponent></ConfigurationComponent>
</section> </section>
<div className="text-right pt-4"> <div className="text-right pt-4 flex justify-end gap-3">
<Button
type="reset"
className="bg-transparent text-color-white hover:bg-transparent border-gray-500 border-[1px]"
onClick={() => {
form.reset();
}}
>
{t('knowledgeConfiguration.cancel')}
</Button>
<Button <Button
disabled={submitLoading} disabled={submitLoading}
onClick={() => { onClick={() => {
(async () => { (async () => {
try { try {
let beValid = await form.formControl.trigger(); let beValid = await form.formControl.trigger();
console.log('user chunk form: ', form);
if (beValid) { if (beValid) {
// setSubmitLoading(true); // setSubmitLoading(true);
let postData = form.formState.values; let postData = form.formState.values;
@ -98,7 +105,7 @@ export function ChunkMethodForm() {
}} }}
> >
{submitLoading && <Loader2Icon className="animate-spin" />} {submitLoading && <Loader2Icon className="animate-spin" />}
{t('common.submit')} {t('knowledgeConfiguration.save')}
</Button> </Button>
</div> </div>
</> </>

View File

@ -9,7 +9,6 @@ import {
FormMessage, FormMessage,
} from '@/components/ui/form'; } from '@/components/ui/form';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { useUpdateKnowledge } from '@/hooks/knowledge-hooks'; import { useUpdateKnowledge } from '@/hooks/knowledge-hooks';
import { transformFile2Base64 } from '@/utils/file-util'; import { transformFile2Base64 } from '@/utils/file-util';
import { Loader2Icon, Pencil, Upload } from 'lucide-react'; import { Loader2Icon, Pencil, Upload } from 'lucide-react';
@ -79,43 +78,17 @@ export function GeneralForm() {
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={form.control}
name="description"
render={({ field }) => {
// null initialize empty string
if (typeof field.value === 'object' && !field.value) {
form.setValue('description', ' ');
}
return (
<FormItem className="items-center space-y-0">
<div className="flex">
<FormLabel className="text-sm text-muted-foreground whitespace-nowrap w-1/4">
{t('flow.description')}
</FormLabel>
<FormControl className="w-3/4">
<Input {...field}></Input>
</FormControl>
</div>
<div className="flex pt-1">
<div className="w-1/4"></div>
<FormMessage />
</div>
</FormItem>
);
}}
/>
<FormField <FormField
control={form.control} control={form.control}
name="avatar" name="avatar"
render={({ field }) => ( render={() => (
<FormItem className="items-center space-y-0"> <FormItem className="items-center space-y-0">
<div className="flex"> <div className="flex">
<FormLabel className="text-sm text-muted-foreground whitespace-nowrap w-1/4"> <FormLabel className="text-sm text-muted-foreground whitespace-nowrap w-1/4">
{t('setting.avatar')} {t('setting.avatar')}
</FormLabel> </FormLabel>
<FormControl className="w-3/4"> <FormControl className="w-3/4">
<> <div className="flex justify-start items-end space-x-2">
<div className="relative group"> <div className="relative group">
{!avatarBase64Str ? ( {!avatarBase64Str ? (
<div className="w-[64px] h-[64px] grid place-content-center border border-dashed rounded-md"> <div className="w-[64px] h-[64px] grid place-content-center border border-dashed rounded-md">
@ -126,7 +99,7 @@ export function GeneralForm() {
</div> </div>
) : ( ) : (
<div className="w-[64px] h-[64px] relative grid place-content-center"> <div className="w-[64px] h-[64px] relative grid place-content-center">
<Avatar className="w-[64px] h-[64px]"> <Avatar className="w-[64px] h-[64px] rounded-md">
<AvatarImage <AvatarImage
className=" block" className=" block"
src={avatarBase64Str} src={avatarBase64Str}
@ -160,7 +133,10 @@ export function GeneralForm() {
}} }}
/> />
</div> </div>
</> <div className="margin-1 text-muted-foreground">
{t('knowledgeConfiguration.photoTip')}
</div>
</div>
</FormControl> </FormControl>
</div> </div>
<div className="flex pt-1"> <div className="flex pt-1">
@ -172,54 +148,48 @@ export function GeneralForm() {
/> />
<FormField <FormField
control={form.control} control={form.control}
name="permission" name="description"
render={({ field }) => ( render={({ field }) => {
<FormItem className="flex items-center space-y-0"> // null initialize empty string
<FormLabel if (typeof field.value === 'object' && !field.value) {
className="text-sm text-muted-foreground whitespace-nowrap w-1/4" form.setValue('description', ' ');
tooltip={t('knowledgeConfiguration.permissionsTip')} }
> return (
{t('knowledgeConfiguration.permissions')} <FormItem className="items-center space-y-0">
<div className="flex">
<FormLabel className="text-sm text-muted-foreground whitespace-nowrap w-1/4">
{t('flow.description')}
</FormLabel> </FormLabel>
<FormControl className="w-3/4"> <FormControl className="w-3/4">
<RadioGroup <Input {...field}></Input>
onValueChange={field.onChange}
value={field.value}
className="flex space-y-1 gap-5"
>
<FormItem className="flex items-center space-x-1 space-y-0">
<FormControl>
<RadioGroupItem value="me" />
</FormControl>
<FormLabel className="font-normal">
{t('knowledgeConfiguration.me')}
</FormLabel>
</FormItem>
<FormItem className="flex items-center space-x-1 space-y-0">
<FormControl>
<RadioGroupItem value="team" />
</FormControl>
<FormLabel className="font-normal">
{t('knowledgeConfiguration.team')}
</FormLabel>
</FormItem>
</RadioGroup>
</FormControl> </FormControl>
</div>
<div className="flex pt-1">
<div className="w-1/4"></div>
<FormMessage /> <FormMessage />
</div>
</FormItem> </FormItem>
)} );
}}
/> />
</FormContainer> </FormContainer>
<div className="text-right pt-4"> <div className="text-right pt-4 flex justify-end gap-3">
<Button
type="reset"
className="bg-transparent text-color-white hover:bg-transparent border-gray-500 border-[1px]"
onClick={() => {
form.reset();
}}
>
{t('knowledgeConfiguration.cancel')}
</Button>
<Button <Button
type="button" type="button"
disabled={submitLoading} disabled={submitLoading}
onClick={() => { onClick={() => {
// console.log('form.formControl: ', form.formState.values);
(async () => { (async () => {
let isValidate = await form.formControl.trigger('name'); let isValidate = await form.formControl.trigger('name');
// console.log(isValidate); const { name, description } = form.formState.values;
const { name, description, permission } = form.formState.values;
const avatar = avatarBase64Str; const avatar = avatarBase64Str;
if (isValidate) { if (isValidate) {
@ -228,7 +198,6 @@ export function GeneralForm() {
parser_id, parser_id,
name, name,
description, description,
permission,
avatar, avatar,
}); });
} }
@ -236,7 +205,7 @@ export function GeneralForm() {
}} }}
> >
{submitLoading && <Loader2Icon className="animate-spin" />} {submitLoading && <Loader2Icon className="animate-spin" />}
{t('common.submit')} {t('knowledgeConfiguration.save')}
</Button> </Button>
</div> </div>
</> </>

View File

@ -102,7 +102,7 @@ export default function DatasetSettings() {
setCurrentTab(val); setCurrentTab(val);
}} }}
> >
<TabsList className="grid w-full bg-background grid-cols-2 rounded-none bg-[#161618]"> <TabsList className="grid bg-background grid-cols-2 rounded-none bg-[#161618]">
<TabsTrigger <TabsTrigger
value="generalForm" value="generalForm"
className="group bg-transparent p-0 !border-transparent" className="group bg-transparent p-0 !border-transparent"