Skip to content

Commit 9f1b6cd

Browse files
authored
UX improvements (#47)
* proper state management and enforcing a location to be selected to run the test * use consistent naming * cleanup
1 parent 51b8344 commit 9f1b6cd

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pages/index.tsx

+16-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function Page() {
3333
const [isTestRunning, setIsTestRunning] = useState(false);
3434
const [shouldTestGlobal, setShouldTestGlobal] = useState(true);
3535
const [shouldTestRegional, setShouldTestRegional] = useState(true);
36-
const [shouldTestNode, setShouldTestNode] = useState(false);
36+
const [shouldTestNode, setShouldTestNode] = useState(true);
3737
const [queryCount, setQueryCount] = useState(1);
3838
const [dataService, setDataService] = useState('');
3939
const [data, setData] = useState({
@@ -159,7 +159,13 @@ export default function Page() {
159159
data-testid="database-dropdown"
160160
className="max-w-xs"
161161
placeholder="Select Database"
162-
onValueChange={(v) => setDataService(v)}
162+
onValueChange={(v) => {
163+
// Reset all checkbox values
164+
setShouldTestGlobal(!NODE_ONLY.includes(v))
165+
setShouldTestRegional(!NODE_ONLY.includes(v))
166+
setShouldTestNode(NODE_ONLY.includes(v) || NODE_AVAILABLE.includes(v))
167+
setDataService(v)
168+
}}
163169
>
164170
<SelectItem
165171
data-testid="vercel-kv"
@@ -245,7 +251,7 @@ export default function Page() {
245251
value="supabase-drizzle"
246252
icon={BoltIcon}
247253
>
248-
Supabase (w/ Drizzle)
254+
Supabase (w/ Drizzle ORM)
249255
</SelectItem>
250256
<SelectItem
251257
data-testid="tidb-cloud"
@@ -285,7 +291,7 @@ export default function Page() {
285291
value="xata-drizzle"
286292
icon={XataIcon}
287293
>
288-
Xata (w/ Drizzle)
294+
Xata (w/ Drizzle ORM)
289295
</SelectItem>
290296
<SelectItem
291297
data-testid="xata-prisma"
@@ -388,16 +394,20 @@ export default function Page() {
388394
</p>
389395
</div>
390396

391-
<div>
397+
<div className="flex items-center">
392398
<Button
393399
type="button"
394400
data-testid="run-test"
395401
onClick={onRunTest}
396402
loading={isTestRunning}
397-
disabled={dataService === ''}
403+
disabled={dataService === '' || (!shouldTestGlobal && !shouldTestRegional && !shouldTestNode)}
398404
>
399405
Run Test
400406
</Button>
407+
{(!shouldTestGlobal && !shouldTestRegional && !shouldTestNode) &&
408+
<p className="text-gray-600 dark:text-gray-300 text-sm ml-4">
409+
You need to select at least one <strong>Location</strong> to run the benchmark.
410+
</p>}
401411
</div>
402412

403413
{data.regional.length || data.global.length || data.node.length ? (

0 commit comments

Comments
 (0)