Skip to content

Commit

Permalink
Merge pull request #3056 from danswer-ai/form_stretch
Browse files Browse the repository at this point in the history
Improve form
  • Loading branch information
hagen-danswer authored Nov 5, 2024
2 parents 6bf06ac + afce57b commit 08600db
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 29 deletions.
3 changes: 0 additions & 3 deletions web/src/app/ee/admin/performance/usage/DanswerBotChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export function DanswerBotChart({
categories={["Total Queries", "Automatically Resolved"]}
index="Day"
colors={["indigo", "fuchsia"]}
valueFormatter={(number: number) =>
`${Intl.NumberFormat("us").format(number).toString()}`
}
yAxisWidth={60}
/>
);
Expand Down
3 changes: 0 additions & 3 deletions web/src/app/ee/admin/performance/usage/FeedbackChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ export function FeedbackChart({
categories={["Positive Feedback", "Negative Feedback"]}
index="Day"
colors={["indigo", "fuchsia"]}
valueFormatter={(number: number) =>
`${Intl.NumberFormat("us").format(number).toString()}`
}
yAxisWidth={60}
/>
);
Expand Down
15 changes: 13 additions & 2 deletions web/src/app/ee/admin/performance/usage/QueryPerformanceChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,21 @@ export function QueryPerformanceChart({
categories={["Queries", "Unique Users"]}
index="Day"
colors={["indigo", "fuchsia"]}
valueFormatter={(number: number) =>
`${Intl.NumberFormat("us").format(number).toString()}`
yAxisFormatter={(number: number) =>
new Intl.NumberFormat("en-US", {
notation: "standard",
maximumFractionDigits: 0,
}).format(number)
}
xAxisFormatter={(dateStr: string) => {
const date = new Date(dateStr);
return date.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
}}
yAxisWidth={60}
allowDecimals={false}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/admin/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function CardSection({
return (
<div
className={cn(
"p-6 shadow-sm rounded-lg bg-white border border-border-strong/80",
"p-6 shadow-sm rounded-lg bg-white border border-border-strong/80",
className
)}
>
Expand Down
26 changes: 12 additions & 14 deletions web/src/components/admin/connectors/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,22 +635,20 @@ export function SelectorFormField({
className={maxHeight ? `max-h-[${maxHeight}]` : undefined}
container={container}
>
{options.length == 0 && (
{options.length === 0 ? (
<SelectItem value="default">Select...</SelectItem>
) : (
options.map((option) => (
<SelectItem
icon={option.icon}
key={option.value}
value={String(option.value)}
selected={field.value === option.value}
>
{option.name}
</SelectItem>
))
)}
{defaultValue && (
<SelectItem value={defaultValue}>{defaultValue}</SelectItem>
)}
{options.map((option) => (
<SelectItem
icon={option.icon}
key={option.value}
value={String(option.value)}
selected={field.value === option.value}
>
{option.name}
</SelectItem>
))}
</SelectContent>
)}
</Select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default function CreateCredential({
onSubmit={() => {}} // This will be overridden by our custom submit handlers
>
{(formikProps) => (
<Form>
<Form className="w-full flex items-stretch">
{!hideSource && (
<p className="text-sm">
Check our
Expand Down
11 changes: 6 additions & 5 deletions web/src/components/ui/areaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface AreaChartProps {
categories?: string[];
index?: string;
colors?: string[];
valueFormatter?: (value: number) => string;
startEndOnly?: boolean;
showXAxis?: boolean;
showYAxis?: boolean;
Expand All @@ -42,15 +41,15 @@ interface AreaChartProps {
className?: string;
title?: string;
description?: string;
xAxisFormatter?: (value: any) => string;
yAxisFormatter?: (value: any) => string;
}

export function AreaChartDisplay({
data = [],
categories = [],
index,
colors = ["indigo", "fuchsia"],
valueFormatter = (number: number) =>
`${Intl.NumberFormat("us").format(number).toString()}`,
startEndOnly = false,
showXAxis = true,
showYAxis = true,
Expand All @@ -68,6 +67,8 @@ export function AreaChartDisplay({
className,
title,
description,
xAxisFormatter = (dateStr: string) => dateStr,
yAxisFormatter = (number: number) => number.toString(),
}: AreaChartProps) {
return (
<Card className={className}>
Expand All @@ -94,15 +95,15 @@ export function AreaChartDisplay({
tickLine={false}
axisLine={false}
tickMargin={8}
tickFormatter={(value) => value.slice(0, 3)}
tickFormatter={(value) => xAxisFormatter(value)}
/>
)}
{showYAxis && (
<YAxis
width={yAxisWidth}
tickLine={false}
axisLine={false}
tickFormatter={valueFormatter}
tickFormatter={(value) => yAxisFormatter(value)}
allowDecimals={allowDecimals}
/>
)}
Expand Down

0 comments on commit 08600db

Please sign in to comment.