Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {useCallback} from "react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the filename typo.

The filename "CaseSenstiveToggle.tsx" contains a typo and should be "CaseSensitiveToggle.tsx" to match the component name and maintain consistency.

🤖 Prompt for AI Agents
In
components/log-viewer-webui/client/src/components/QueryBox/InputWithCaseSensitive/CaseSenstiveToggle.tsx
at line 1, the filename contains a typo "CaseSenstiveToggle.tsx". Rename the
file to "CaseSensitiveToggle.tsx" to match the component name and ensure
consistency across the codebase.


import {
Button,
Tooltip,
Typography,
} from "antd";


interface CaseSensitiveToggleProps {
disabled: boolean;
isCaseSensitive: boolean;
onCaseSensitiveChange: (newValue: boolean) => void;
}

/**
* A toggle button component that switches between case-sensitive and case-insensitive
* modes when clicked.
*
* @param props
* @param props.disabled
* @param props.isCaseSensitive
* @param props.onCaseSensitiveChange
* @return
*/
const CaseSensitiveToggle = ({
disabled,
isCaseSensitive,
onCaseSensitiveChange,
}: CaseSensitiveToggleProps) => {
const handleButtonClick = useCallback(() => {
onCaseSensitiveChange(!isCaseSensitive);
}, [
isCaseSensitive,
onCaseSensitiveChange,
]);
Comment on lines +31 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Use explicit comparison instead of unary “!” per coding guidelines.

Replace the negation with the preferred style:

-        onCaseSensitiveChange(!isCaseSensitive);
+        onCaseSensitiveChange(false == isCaseSensitive);

This keeps the behaviour identical while aligning with the project’s boolean-expression rule.

🤖 Prompt for AI Agents
In
components/log-viewer-webui/client/src/components/QueryBox/InputWithCaseSensitive/CaseSenstiveToggle.tsx
around lines 32 to 37, the code uses a unary "!" operator to negate the boolean
isCaseSensitive. To comply with the project's coding guidelines, replace the
negation with an explicit comparison expression that achieves the same boolean
toggle effect without using "!". This will maintain the behavior while adhering
to the boolean-expression rule.


return (
<Tooltip
title={"Match case"}
>
<Button
color={"default"}
disabled={disabled}
size={"small"}
icon={
<Typography.Text disabled={disabled}>
Aa
</Typography.Text>
}
variant={isCaseSensitive ?
"outlined" :
"text"}
onClick={handleButtonClick}/>
</Tooltip>
);
};


export type {CaseSensitiveToggleProps};
export default CaseSensitiveToggle;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
Input,
InputProps,
} from "antd";

import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSenstiveToggle";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the filename typo in the import.

The imported file name contains a typo: "CaseSenstiveToggle" should be "CaseSensitiveToggle".

-import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSenstiveToggle";
+import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSensitiveToggle";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSenstiveToggle";
import CaseSensitiveToggle, {CaseSensitiveToggleProps} from "./CaseSensitiveToggle";
🤖 Prompt for AI Agents
In
components/log-viewer-webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx
at line 6, fix the typo in the import statement by changing "CaseSenstiveToggle"
to "CaseSensitiveToggle" so the import matches the correct filename.



/**
* Antd Input props and case sensitive toggle props with suffix omitted since set by component.
*/
type InputWithCaseSensitiveProps = Omit<InputProps, "suffix"> & CaseSensitiveToggleProps;

Comment on lines +12 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

disabled becomes mandatory due to type intersection

InputProps declares disabled?: boolean (optional) but CaseSensitiveToggleProps declares disabled: boolean (required).
The intersection forces the final prop to be required, breaking existing call-sites that omit it.

Make disabled optional in CaseSensitiveToggleProps, or remove it so callers rely on InputProps alone.

-interface CaseSensitiveToggleProps {
-    disabled: boolean;
+interface CaseSensitiveToggleProps {
+    disabled?: boolean;

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
components/log-viewer-webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx
around lines 12 to 13, the intersection of InputProps and
CaseSensitiveToggleProps makes the 'disabled' prop required because
CaseSensitiveToggleProps declares it as mandatory while InputProps has it
optional. To fix this, modify CaseSensitiveToggleProps to make 'disabled'
optional or remove 'disabled' from CaseSensitiveToggleProps entirely so that
callers can rely on the optional 'disabled' from InputProps, preventing breaking
existing call-sites.

/**
* Antd Input with a built-in case sensitivity toggle.
*
* @param props
* @param props.isCaseSensitive
* @param props.onCaseSensitiveChange
* @param props.inputProps
* @return
*/
const InputWithCaseSensitive = ({
isCaseSensitive,
onCaseSensitiveChange,
...inputProps
}: InputWithCaseSensitiveProps) => {
return (
<Input
{...inputProps}
suffix={
<CaseSensitiveToggle
disabled={inputProps.disabled}
isCaseSensitive={isCaseSensitive}
onCaseSensitiveChange={onCaseSensitiveChange}/>
}/>
);
};

export type {InputWithCaseSensitiveProps};
export default InputWithCaseSensitive;
Original file line number Diff line number Diff line change
@@ -1,92 +1,36 @@
import {useCallback} from "react";

import {
Button,
Input,
InputProps,
Progress,
theme,
Tooltip,
Typography,
} from "antd";
import {Nullable} from "src/typings/common";

import styles from "./index.module.css";
import InputWithCaseSensitive, {InputWithCaseSensitiveProps} from "./InputWithCaseSensitive";


interface CaseSensitiveToggleProps {
isCaseSensitive: boolean;
onCaseSensitiveChange: (newValue: boolean) => void;
}

/**
* A toggle button component that switches between case-sensitive and case-insensitive modes.
*
* This component displays a button labeled "Aa". When clicked, it toggles the `isCaseSensitive`
* state and invokes the `onCaseSensitiveChange` callback with the new value.
*
* @param props
* @param props.isCaseSensitive
* @param props.onCaseSensitiveChange
* @return
*/
const CaseSensitiveToggle = ({
isCaseSensitive,
onCaseSensitiveChange,
}: CaseSensitiveToggleProps) => {
const handleButtonClick = useCallback(() => {
onCaseSensitiveChange(!isCaseSensitive);
}, [
isCaseSensitive,
onCaseSensitiveChange,
]);

return (
<Tooltip title={"Match case"}>
<Button
color={"default"}
icon={<Typography.Text disabled={!isCaseSensitive}>Aa</Typography.Text>}
size={"small"}
variant={isCaseSensitive ?
"filled" :
"text"}
onClick={handleButtonClick}/>
</Tooltip>
);
};


interface QueryBoxProps extends InputProps, CaseSensitiveToggleProps {
interface QueryBoxProps extends InputWithCaseSensitiveProps {
/**
* The progress of the progress bar from `0` to `100`. Hides the bar if `null`.
*/
progress: Nullable<number>;
}

/**
* Renders an Input with a progress bar.
* Renders an Input with a case sensitivity toggle and progress bar.
*
* @param props
* @param props.progress
* @param props.inputProps
* @param props.onCaseSensitiveChange
* @param props.isCaseSensitive
* @return
*/
Comment on lines 18 to 25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Update JSDoc to reflect actual props.

The @param props.inputProps tag is misleading—there is no inputProps prop. Rename or remove this line and document isCaseSensitive and onCaseSensitiveChange explicitly, along with progress.

🤖 Prompt for AI Agents
In components/log-viewer-webui/client/src/components/QueryBox/index.tsx around
lines 18 to 25, the JSDoc incorrectly documents a non-existent prop named
inputProps. Remove or rename the @param tag for inputProps and explicitly add
@param tags for the actual props isCaseSensitive and onCaseSensitiveChange,
along with progress, to accurately reflect the component's props.

const QueryBox = ({
progress,
isCaseSensitive,
onCaseSensitiveChange,
...inputProps
}: QueryBoxProps) => {
const {token} = theme.useToken();
return (
<div className={styles["queryBox"]}>
<Input
{...inputProps}
suffix={<CaseSensitiveToggle
isCaseSensitive={isCaseSensitive}
onCaseSensitiveChange={onCaseSensitiveChange}/>}/>
<InputWithCaseSensitive {...inputProps}/>
<div
className={styles["progressBarMask"]}
style={{borderRadius: token.borderRadiusLG}}
Expand Down