дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
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
Цей коміт міститься в:
1 джерело
0df4bc2289
коміт
a69ff2499d
3 files changed
+42
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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(<ServiceImportHost />);
|
||||
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"]));
|
||||
});
|
||||
@@ -86,6 +86,14 @@ function ImportDialog(props: {
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={styles.importAll}>
|
||||
<Checkbox
|
||||
checked={picked.size === props.configs.length}
|
||||
indeterminate={picked.size > 0 && picked.size < props.configs.length}
|
||||
onChange={(checked) => setPicked(new Set(checked ? props.configs.map((c) => c.id) : []))}
|
||||
label="Select All"
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.importList}>
|
||||
{props.configs.map((c) => (
|
||||
<Checkbox key={c.id} checked={picked.has(c.id)} onChange={() => toggle(c.id)} label={<span>{c.name}</span>} />
|
||||
|
||||
Reference in new issue
Заблокувати користувача