mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
Fix: Lint error. (#16172)
### What problem does this PR solve? Fix: Lint error. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -70,4 +70,12 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/__tests__/**'],
|
||||
rules: {
|
||||
'check-file/folder-naming-convention': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { MarkdownRemarkPlugins } from '@/constants/markdown-remark-plugins';
|
||||
import classNames from 'classnames';
|
||||
import Markdown from 'react-markdown';
|
||||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
||||
@@ -7,18 +8,17 @@ import {
|
||||
} from 'react-syntax-highlighter/dist/esm/styles/prism';
|
||||
import rehypeKatex from 'rehype-katex';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import { MarkdownRemarkPlugins } from '@/constants/markdown-remark-plugins';
|
||||
|
||||
import 'katex/dist/katex.min.css'; // `rehype-katex` does not import the CSS for you
|
||||
|
||||
import { preprocessLaTeX } from '@/utils/chat';
|
||||
import { citationMarkerReg } from '@/utils/citation-utils';
|
||||
import { getDirAttribute } from '@/utils/text-direction';
|
||||
import { omit } from 'lodash';
|
||||
import { useIsDarkTheme } from '../theme-provider';
|
||||
import styles from './index.module.less';
|
||||
|
||||
const HighLightMarkdown = ({
|
||||
className,
|
||||
children,
|
||||
}: {
|
||||
className?: string;
|
||||
@@ -36,8 +36,8 @@ const HighLightMarkdown = ({
|
||||
rehypePlugins={[rehypeRaw, rehypeKatex]}
|
||||
components={
|
||||
{
|
||||
p: ({ children, node, ...props }: any) => (
|
||||
<p {...props}>{children}</p>
|
||||
p: ({ children, ...props }: any) => (
|
||||
<p {...omit(props, 'node')}>{children}</p>
|
||||
),
|
||||
code(props: any) {
|
||||
const { children, className, ...rest } = props;
|
||||
|
||||
@@ -103,6 +103,7 @@ const JsonEditor: React.FC<JsonEditorProps> = ({
|
||||
try {
|
||||
currentData = editorRef.current.get();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// If there's an error getting data, use the passed value or empty object
|
||||
currentData = value || {};
|
||||
}
|
||||
@@ -127,6 +128,7 @@ const JsonEditor: React.FC<JsonEditorProps> = ({
|
||||
const updatedJson = editorRef.current.get();
|
||||
onChange(updatedJson);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// Do not trigger onChange when parsing error occurs
|
||||
}
|
||||
}
|
||||
@@ -157,6 +159,7 @@ const JsonEditor: React.FC<JsonEditorProps> = ({
|
||||
editorRef.current.set(value);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// Skip update if there is a syntax error in the current editor
|
||||
editorRef.current.set(value);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ const JsonSchemaVisualizer: FC<JsonSchemaVisualizerProps> = ({
|
||||
onChange(parsedJson);
|
||||
}
|
||||
} catch (_error) {
|
||||
console.error(_error);
|
||||
// Monaco will show the error inline, no need for additional error handling
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
!!prefix && prefixWidth ? `${prefixWidth}px` : '',
|
||||
paddingInlineEnd: isPasswordInput
|
||||
? '40px'
|
||||
: !!suffix
|
||||
: suffix
|
||||
? `${suffixWidth}px`
|
||||
: '',
|
||||
}}
|
||||
@@ -155,9 +155,6 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
|
||||
Input.displayName = 'Input';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface ExpandedInputProps extends InputProps {}
|
||||
|
||||
const ExpandedInput = Input;
|
||||
|
||||
const SearchInput = (props: InputProps) => {
|
||||
|
||||
@@ -64,7 +64,7 @@ export interface SegmentedProps extends Omit<
|
||||
|
||||
const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
|
||||
supportsCssAnchor
|
||||
? (
|
||||
? function Segmented(
|
||||
{
|
||||
options,
|
||||
value,
|
||||
@@ -77,7 +77,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
|
||||
buttonSize = 'default',
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
) {
|
||||
const anchorNamePrefix = useId().replace(/:/g, '');
|
||||
const [selectedValue, setSelectedValue] = React.useState<
|
||||
SegmentedValue | undefined
|
||||
@@ -143,7 +143,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
|
||||
</div>
|
||||
);
|
||||
}
|
||||
: (
|
||||
: function Segmented(
|
||||
{
|
||||
options,
|
||||
value,
|
||||
@@ -156,7 +156,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
|
||||
buttonSize = 'default',
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
) {
|
||||
const [selectedValue, setSelectedValue] = React.useState<
|
||||
SegmentedValue | undefined
|
||||
>(value);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { LucideCircleQuestionMark } from 'lucide-react';
|
||||
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip';
|
||||
|
||||
export default function WhatIsThis({ children }: React.PropsWithChildren<{}>) {
|
||||
export default function WhatIsThis({ children }: React.PropsWithChildren) {
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
|
||||
@@ -4,10 +4,6 @@ export interface IFileListRequestBody extends IPaginationRequestBody {
|
||||
parent_id?: string; // folder id
|
||||
}
|
||||
|
||||
interface BaseRequestBody {
|
||||
parentId: string;
|
||||
}
|
||||
|
||||
export interface IConnectRequestBody {
|
||||
fileIds: string[];
|
||||
kbIds: string[];
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
FormMessage,
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { memo } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -23,7 +22,6 @@ const FormSchema = z.object({
|
||||
});
|
||||
|
||||
function SearXNGForm() {
|
||||
const { t } = useTranslate('flow');
|
||||
const values = useValues();
|
||||
|
||||
const form = useForm<z.infer<typeof FormSchema>>({
|
||||
|
||||
@@ -12,6 +12,7 @@ export const useHandleForm = () => {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,9 @@ export function findEndOutput(list?: ITraceData[]) {
|
||||
const json = JSON.parse(str);
|
||||
return json;
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Input } from '@/components/ui/input';
|
||||
import { formatDate } from '@/utils/date';
|
||||
import { ColumnDef, Row, Table } from '@tanstack/react-table';
|
||||
import { ListChevronsDownUp, LucidePencil, Trash2 } from 'lucide-react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
getMetadataValueTypeLabel,
|
||||
@@ -56,12 +56,6 @@ export const useMetadataColumns = ({
|
||||
Record<string, boolean>
|
||||
>({});
|
||||
|
||||
const isSettingsMode =
|
||||
metadataType === MetadataType.Setting ||
|
||||
metadataType === MetadataType.SingleFileSetting ||
|
||||
metadataType === MetadataType.UpdateSingle;
|
||||
|
||||
const showTypeColumn = isSettingsMode;
|
||||
const handleEditValue = (field: string, value: string) => {
|
||||
setEditingValue({ field, value, newValue: value });
|
||||
};
|
||||
@@ -193,6 +187,35 @@ export const useMetadataColumns = ({
|
||||
}));
|
||||
};
|
||||
|
||||
const handleToggleExpand = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
toggleRowExpanded();
|
||||
};
|
||||
|
||||
const handleDeleteValueClick =
|
||||
(value: string): React.MouseEventHandler =>
|
||||
(e) => {
|
||||
e.stopPropagation();
|
||||
setDeleteDialogContent({
|
||||
visible: true,
|
||||
title:
|
||||
t('common.delete') +
|
||||
' ' +
|
||||
t('knowledgeDetails.metadata.value'),
|
||||
name: value,
|
||||
warnText:
|
||||
MetadataDeleteMap(t)[metadataType as MetadataType]
|
||||
.warnValueText,
|
||||
onOk: () => {
|
||||
hideDeleteModal();
|
||||
handleDeleteSingleValue(row.getValue('field'), value);
|
||||
},
|
||||
onCancel: () => {
|
||||
hideDeleteModal();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const displayedValues = isRowExpanded ? values : values.slice(0, 2);
|
||||
const hasMore = Array.isArray(values) && values.length > 2;
|
||||
|
||||
@@ -269,32 +292,7 @@ export const useMetadataColumns = ({
|
||||
<Button
|
||||
variant={'delete'}
|
||||
className="p-0 bg-transparent"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
// showDeleteDialogContent(value, row);
|
||||
setDeleteDialogContent({
|
||||
visible: true,
|
||||
title:
|
||||
t('common.delete') +
|
||||
' ' +
|
||||
t('knowledgeDetails.metadata.value'),
|
||||
name: value,
|
||||
warnText:
|
||||
MetadataDeleteMap(t)[
|
||||
metadataType as MetadataType
|
||||
].warnValueText,
|
||||
onOk: () => {
|
||||
hideDeleteModal();
|
||||
handleDeleteSingleValue(
|
||||
row.getValue('field'),
|
||||
value,
|
||||
);
|
||||
},
|
||||
onCancel: () => {
|
||||
hideDeleteModal();
|
||||
},
|
||||
});
|
||||
}}
|
||||
onClick={handleDeleteValueClick(value)}
|
||||
>
|
||||
<Trash2 />
|
||||
</Button>
|
||||
@@ -308,10 +306,7 @@ export const useMetadataColumns = ({
|
||||
<Button
|
||||
variant={'ghost'}
|
||||
className="border border-border-button h-auto px-2 py-1"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleRowExpanded();
|
||||
}}
|
||||
onClick={handleToggleExpand}
|
||||
>
|
||||
<div className="text-text-secondary">
|
||||
+{values.length - 2}
|
||||
@@ -323,10 +318,7 @@ export const useMetadataColumns = ({
|
||||
<Button
|
||||
variant={'ghost'}
|
||||
className="bg-transparent px-2 py-1"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleRowExpanded();
|
||||
}}
|
||||
onClick={handleToggleExpand}
|
||||
>
|
||||
<div className="text-text-secondary">
|
||||
<ListChevronsDownUp size={14} />
|
||||
|
||||
Reference in New Issue
Block a user