From a69ff2499d5a7f0f41ba75ff33bbf5139c009449 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sat, 5 Dec 2026 21:26:45 +0800 Subject: [PATCH] feat(services): select or clear every configuration in Add Service (#8231) Add Service of a configuration type now has a tri-state Select All checkbox above its list of configurations, so a long list can be cleared or checked in one click. Closes #8174 --- src/features/run/RunServices.module.css | 5 +++++ src/features/run/serviceImport.test.tsx | 29 +++++++++++++++++++++++++ src/features/run/serviceImport.tsx | 8 +++++++ 3 files changed, 42 insertions(+) create mode 100644 src/features/run/serviceImport.test.tsx diff --git a/src/features/run/RunServices.module.css b/src/features/run/RunServices.module.css index ee0ece83c3..b914a21b78 100644 --- a/src/features/run/RunServices.module.css +++ b/src/features/run/RunServices.module.css @@ -36,6 +36,11 @@ min-height: 0; } +.importAll { + padding: var(--space-3) var(--space-3) var(--space-2); + border-bottom: 1px solid var(--border); +} + .importList { display: flex; flex-direction: column; diff --git a/src/features/run/serviceImport.test.tsx b/src/features/run/serviceImport.test.tsx new file mode 100644 index 0000000000..145fc4e961 --- /dev/null +++ b/src/features/run/serviceImport.test.tsx @@ -0,0 +1,29 @@ +import { afterEach, expect, it } from "vitest"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import type { RunConfig } from "@/platform/ipc"; +import { pickServices, ServiceImportHost } from "./serviceImport"; + +afterEach(cleanup); + +const config = (id: string) => ({ id, name: id, kind: "spring-boot" }) as RunConfig; + +it("selects or clears every configuration with Select All", async () => { + render(); + const configs = ["a", "b", "c"].map(config); + const picked = pickServices("spring-boot", configs, new Set(["a", "b", "c"])); + const all = await screen.findByRole("checkbox", { name: "Select All" }); + expect(all).toBeChecked(); + + fireEvent.click(all); + for (const id of ["a", "b", "c"]) expect(screen.getByRole("checkbox", { name: id })).not.toBeChecked(); + expect(screen.getByRole("button", { name: "OK" })).toBeDisabled(); + + fireEvent.click(screen.getByRole("checkbox", { name: "b" })); + expect(all).toHaveAttribute("aria-checked", "mixed"); + + fireEvent.click(all); + expect(all).toBeChecked(); + fireEvent.click(screen.getByRole("checkbox", { name: "a" })); + fireEvent.click(screen.getByRole("button", { name: "OK" })); + expect(await picked).toEqual(new Set(["b", "c"])); +}); diff --git a/src/features/run/serviceImport.tsx b/src/features/run/serviceImport.tsx index e9791c2332..0e05a945ec 100644 --- a/src/features/run/serviceImport.tsx +++ b/src/features/run/serviceImport.tsx @@ -86,6 +86,14 @@ function ImportDialog(props: { { label: "Cancel", role: "cancel" }, ]} > +
+ 0 && picked.size < props.configs.length} + onChange={(checked) => setPicked(new Set(checked ? props.configs.map((c) => c.id) : []))} + label="Select All" + /> +
{props.configs.map((c) => ( toggle(c.id)} label={{c.name}} />