mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-30 07:06:39 +08:00
Fix: Add a no-data filter condition to MetaData (#12189)
### What problem does this PR solve? Fix: Add a no-data filter condition to MetaData ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -42,8 +42,8 @@ export const MetadataDeleteMap = (
|
||||
},
|
||||
[MetadataType.Setting]: {
|
||||
title: t('common.delete') + ' ' + t('knowledgeDetails.metadata.metadata'),
|
||||
warnFieldText: t('knowledgeDetails.metadata.deleteManageFieldAllWarn'),
|
||||
warnValueText: t('knowledgeDetails.metadata.deleteManageValueAllWarn'),
|
||||
warnFieldText: t('knowledgeDetails.metadata.deleteSettingFieldWarn'),
|
||||
warnValueText: t('knowledgeDetails.metadata.deleteSettingValueWarn'),
|
||||
},
|
||||
[MetadataType.UpdateSingle]: {
|
||||
title: t('common.delete') + ' ' + t('knowledgeDetails.metadata.metadata'),
|
||||
@ -52,8 +52,8 @@ export const MetadataDeleteMap = (
|
||||
},
|
||||
[MetadataType.SingleFileSetting]: {
|
||||
title: t('common.delete') + ' ' + t('knowledgeDetails.metadata.metadata'),
|
||||
warnFieldText: t('knowledgeDetails.metadata.deleteManageFieldSingleWarn'),
|
||||
warnValueText: t('knowledgeDetails.metadata.deleteManageValueSingleWarn'),
|
||||
warnFieldText: t('knowledgeDetails.metadata.deleteSettingFieldWarn'),
|
||||
warnValueText: t('knowledgeDetails.metadata.deleteSettingValueWarn'),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -4,6 +4,7 @@ import {
|
||||
} from '@/components/confirm-delete-dialog';
|
||||
import EditTag from '@/components/edit-tag';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { FormLabel } from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Modal } from '@/components/ui/modal/modal';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
@ -116,7 +117,12 @@ export const ManageValuesModal = (props: IManageValuesProps) => {
|
||||
)}
|
||||
{isShowDescription && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>{t('knowledgeDetails.metadata.description')}</div>
|
||||
<FormLabel
|
||||
className="text-text-primary text-base"
|
||||
tooltip={t('knowledgeDetails.metadata.descriptionTip')}
|
||||
>
|
||||
{t('knowledgeDetails.metadata.description')}
|
||||
</FormLabel>
|
||||
<div>
|
||||
<Textarea
|
||||
value={metaData.description}
|
||||
@ -129,7 +135,12 @@ export const ManageValuesModal = (props: IManageValuesProps) => {
|
||||
)}
|
||||
{isShowValueSwitch && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>{t('knowledgeDetails.metadata.restrictDefinedValues')}</div>
|
||||
<FormLabel
|
||||
className="text-text-primary text-base"
|
||||
tooltip={t('knowledgeDetails.metadata.restrictTDefinedValuesTip')}
|
||||
>
|
||||
{t('knowledgeDetails.metadata.restrictDefinedValues')}
|
||||
</FormLabel>
|
||||
<div>
|
||||
<Switch
|
||||
checked={metaData.restrictDefinedValues || false}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
import { FilterCollection } from '@/components/list-filter-bar/interface';
|
||||
import {
|
||||
FilterCollection,
|
||||
FilterType,
|
||||
} from '@/components/list-filter-bar/interface';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useGetDocumentFilter } from '@/hooks/use-document-request';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export const EMPTY_METADATA_FIELD = 'empty_metadata';
|
||||
|
||||
export function useSelectDatasetFilters() {
|
||||
const { t } = useTranslate('knowledgeDetails');
|
||||
const { filter, onOpenChange } = useGetDocumentFilter();
|
||||
@ -17,34 +22,52 @@ export function useSelectDatasetFilters() {
|
||||
}
|
||||
}, [filter.suffix]);
|
||||
const fileStatus = useMemo(() => {
|
||||
let list = [] as FilterType[];
|
||||
if (filter.run_status) {
|
||||
return Object.keys(filter.run_status).map((x) => ({
|
||||
list = Object.keys(filter.run_status).map((x) => ({
|
||||
id: x,
|
||||
label: t(`runningStatus${x}`),
|
||||
count: filter.run_status[x as unknown as number],
|
||||
}));
|
||||
}
|
||||
}, [filter.run_status, t]);
|
||||
if (filter.metadata) {
|
||||
const emptyMetadata = filter.metadata?.empty_metadata;
|
||||
if (emptyMetadata) {
|
||||
list.push({
|
||||
id: EMPTY_METADATA_FIELD,
|
||||
label: t('emptyMetadata'),
|
||||
count: emptyMetadata.true,
|
||||
});
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}, [filter.run_status, filter.metadata, t]);
|
||||
const metaDataList = useMemo(() => {
|
||||
if (filter.metadata) {
|
||||
return Object.keys(filter.metadata).map((x) => ({
|
||||
id: x.toString(),
|
||||
field: x.toString(),
|
||||
label: x.toString(),
|
||||
list: Object.keys(filter.metadata[x]).map((y) => ({
|
||||
id: y.toString(),
|
||||
field: y.toString(),
|
||||
label: y.toString(),
|
||||
value: [y],
|
||||
count: filter.metadata[x][y],
|
||||
})),
|
||||
count: Object.keys(filter.metadata[x]).reduce(
|
||||
(acc, cur) => acc + filter.metadata[x][cur],
|
||||
0,
|
||||
),
|
||||
}));
|
||||
const list = Object.keys(filter.metadata)
|
||||
?.filter((m) => m !== EMPTY_METADATA_FIELD)
|
||||
?.map((x) => {
|
||||
return {
|
||||
id: x.toString(),
|
||||
field: x.toString(),
|
||||
label: x.toString(),
|
||||
list: Object.keys(filter.metadata[x]).map((y) => ({
|
||||
id: y.toString(),
|
||||
field: y.toString(),
|
||||
label: y.toString(),
|
||||
value: [y],
|
||||
count: filter.metadata[x][y],
|
||||
})),
|
||||
count: Object.keys(filter.metadata[x]).reduce(
|
||||
(acc, cur) => acc + filter.metadata[x][cur],
|
||||
0,
|
||||
),
|
||||
};
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}, [filter.metadata]);
|
||||
|
||||
const filters: FilterCollection[] = useMemo(() => {
|
||||
return [
|
||||
{ field: 'type', label: 'File Type', list: fileTypes },
|
||||
|
||||
Reference in New Issue
Block a user