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
4 changes: 3 additions & 1 deletion web/src/app/admin/settings/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export function Checkbox({
className="mr-2 w-3.5 h-3.5 my-auto"
/>
<div>
<Label small>{label}</Label>
<span className="block font-medium text-text-700 dark:text-neutral-100 text-sm">
{label}
</span>
{sublabel && <SubLabel>{sublabel}</SubLabel>}
</div>
</label>
Expand Down
38 changes: 25 additions & 13 deletions web/src/components/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ export function Label({
children,
small,
className,
htmlFor,
}: {
children: string | JSX.Element;
small?: boolean;
className?: string;
htmlFor?: string;
}) {
return (
<label
{...(htmlFor ? { htmlFor } : {})}
className={`block font-medium text-text-700 dark:text-neutral-100 ${className} ${
small ? "text-sm" : "text-base"
}`}
Expand Down Expand Up @@ -96,21 +99,21 @@ export function SubLabel({ children }: { children: string | JSX.Element }) {
// If children is a string, use RichTextSubtext to parse and render links
if (typeof children === "string") {
return (
<div className="text-sm text-neutral-600 dark:text-neutral-300 mb-2">
<span className="block text-sm text-neutral-600 dark:text-neutral-300 mb-2">
<RichTextSubtext
text={children}
className={hasNewlines ? "whitespace-pre-wrap" : ""}
/>
</div>
</span>
);
}

return (
<div
className={`text-sm text-neutral-600 dark:text-neutral-300 mb-2 ${hasNewlines ? "whitespace-pre-wrap" : ""}`}
<span
className={`block text-sm text-neutral-600 dark:text-neutral-300 mb-2 ${hasNewlines ? "whitespace-pre-wrap" : ""}`}
>
{children}
</div>
</span>
);
}

Expand Down Expand Up @@ -705,14 +708,18 @@ export const BooleanFormField = ({
[disabled, name, setFieldValue, onChange]
);

// Generate a stable, valid id from the field name for label association
const checkboxId = `checkbox-${name.replace(/[^a-zA-Z0-9_-]/g, "_")}`;

return (
<div>
<label className="flex items-center text-sm cursor-pointer">
<div className="flex items-center text-sm">
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<TooltipTrigger asChild>
<CheckboxField
name={name}
id={checkboxId}
size="sm"
className={`
${disabled ? "opacity-50" : ""}
Expand All @@ -732,16 +739,21 @@ export const BooleanFormField = ({
{!noLabel && (
<div>
<div className="flex items-center gap-x-2">
<Label small={small}>{`${label}${
optional ? " (Optional)" : ""
}`}</Label>
<Label
htmlFor={checkboxId}
small={small}
className="cursor-pointer"
>{`${label}${optional ? " (Optional)" : ""}`}</Label>
{tooltip && <ToolTipDetails>{tooltip}</ToolTipDetails>}
</div>

{subtext && <SubLabel>{subtext}</SubLabel>}
{subtext && (
<label htmlFor={checkboxId} className="cursor-pointer">
<SubLabel>{subtext}</SubLabel>
</label>
)}
</div>
)}
</label>
</div>

<ErrorMessage
name={name}
Expand Down
8 changes: 7 additions & 1 deletion web/src/components/credentials/CredentialFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ export const AdminBooleanFormField = ({
/>
{!noLabel && (
<div>
<Label small={small}>{label}</Label>
<span
className={`block font-medium text-text-700 dark:text-neutral-100 ${
small ? "text-sm" : "text-base"
} cursor-pointer`}
>
{label}
</span>
{subtext && <SubLabel>{subtext}</SubLabel>}
</div>
)}
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/ui/CheckField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export const CheckFormField: React.FC<CheckFieldProps> = ({

const handleClick = (e: React.MouseEvent<HTMLLabelElement>) => {
e.preventDefault();
helpers.setValue(!field.value);
onChange?.(field.value);
const next = !field.value;
helpers.setValue(next);
onChange?.(next);
};

const checkboxContent = (
Expand Down
12 changes: 3 additions & 9 deletions web/tests/e2e/assistants/create_and_edit_assistant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const getAdvancedOptionsButton = (page: Page) =>
const getReminderTextarea = (page: Page) =>
page.locator('textarea[name="task_prompt"]');
const getDateTimeAwareCheckbox = (page: Page) =>
page
.locator('label:has-text("Date and Time Aware")')
.locator('button[role="checkbox"]');
page.getByRole("checkbox", { name: /Date and Time Aware/i });
const getKnowledgeCutoffInput = (page: Page) =>
page.locator('input[name="search_start_date"]');
const getKnowledgeToggle = (page: Page) =>
Expand All @@ -25,13 +23,9 @@ const getKnowledgeToggle = (page: Page) =>
const getNumChunksInput = (page: Page) =>
page.locator('input[name="num_chunks"]');
const getAiRelevanceCheckbox = (page: Page) =>
page
.locator('label:has-text("AI Relevance Filter")')
.locator('button[role="checkbox"]');
page.getByRole("checkbox", { name: /AI Relevance Filter/i });
const getCitationsCheckbox = (page: Page) =>
page
.locator('label:has-text("Citations")')
.locator('button[role="checkbox"]');
page.getByRole("checkbox", { name: /Citations/i });
const getStarterMessageInput = (page: Page, index: number = 0) =>
page.locator(`input[name="starter_messages.${index}.message"]`);
const getCreateSubmitButton = (page: Page) =>
Expand Down