-
Notifications
You must be signed in to change notification settings - Fork 81
fix(new-webui): Disable case sensitivity toggle while querying. #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8987aff
a3e50e0
7ac0379
4d204fe
85dafca
3c20751
568bad9
963384c
3fe213b
49cfd41
b818231
b809196
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {useCallback} from "react"; | ||
|
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
|
||
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"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
🤖 Prompt for AI Agents
|
||||||
|
||||||
|
||||||
/** | ||||||
* 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
Make -interface CaseSensitiveToggleProps {
- disabled: boolean;
+interface CaseSensitiveToggleProps {
+ disabled?: boolean;
🤖 Prompt for AI Agents
|
||||||
/** | ||||||
* 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Update JSDoc to reflect actual props. The 🤖 Prompt for AI Agents
|
||
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}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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