mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(settings): fit notification group controls in the settings pane (#4810)
Settings › Appearance & Behavior › Notifications shows the notification groups as a list beside the selected group's popup type and tool window option instead of a wide table, and stacks them in a narrow settings pane. Searching selects the matching group.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test.beforeEach(async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await dialog.getByRole("textbox", { name: "Search settings" }).fill("Notifications");
|
||||
await dialog.getByRole("treeitem", { name: "Notifications", exact: true }).click();
|
||||
});
|
||||
|
||||
test("notification group controls stay inside narrow settings", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 520, height: 760 });
|
||||
const groups = page.getByRole("region", { name: "Groups", exact: true });
|
||||
const popup = groups.getByRole("button", { name: "System Messages popup type" });
|
||||
await expect(popup).toBeInViewport({ ratio: 0.98 });
|
||||
expect(await groups.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
|
||||
const list = groups.getByRole("listbox", { name: "Notification groups" });
|
||||
const controls = groups.getByRole("region", { name: "System Messages", exact: true });
|
||||
const listBounds = (await list.boundingBox())!;
|
||||
expect((await controls.boundingBox())!.y).toBeGreaterThanOrEqual(listBounds.y + listBounds.height);
|
||||
await popup.click();
|
||||
await expect(page.getByRole("option", { name: "Sticky balloon", exact: true })).toBeInViewport();
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
await list.press("End");
|
||||
const lastGroup = list.getByRole("option", { name: "Distraction Free Mode", exact: true });
|
||||
await expect(lastGroup).toHaveAttribute("aria-selected", "true");
|
||||
await expect(lastGroup).toBeInViewport({ ratio: 0.98 });
|
||||
await list.press("Home");
|
||||
|
||||
await page.setViewportSize({ width: 1100, height: 760 });
|
||||
const wideList = (await list.boundingBox())!;
|
||||
const wideControls = (await controls.boundingBox())!;
|
||||
expect(wideControls.x).toBeGreaterThan(wideList.x + wideList.width);
|
||||
expect(wideControls.y).toBeLessThan(wideList.y + wideList.height);
|
||||
});
|
||||
|
||||
test("notification groups follow settings search and keep edits per group", async ({ workbench: page }) => {
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = dialog.getByRole("textbox", { name: "Search settings" });
|
||||
const list = dialog.getByRole("listbox", { name: "Notification groups" });
|
||||
const systemPopup = dialog.getByRole("button", { name: "System Messages popup type" });
|
||||
const versionControlPopup = dialog.getByRole("button", { name: "Version Control popup type" });
|
||||
const versionControlLog = dialog.getByRole("checkbox", { name: "Show Version Control in tool window" });
|
||||
|
||||
await list.press("ArrowDown");
|
||||
await expect(list.getByRole("option", { name: "Language Servers" })).toHaveAttribute("aria-selected", "true");
|
||||
await search.fill("Version Control");
|
||||
await dialog.getByRole("treeitem", { name: "Notifications", exact: true }).click();
|
||||
await expect(list.getByRole("option", { name: "Version Control", exact: true })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
await versionControlPopup.click();
|
||||
await page.getByRole("option", { name: "No popup", exact: true }).click();
|
||||
await versionControlLog.uncheck();
|
||||
|
||||
await list.press("Home");
|
||||
await expect(systemPopup).toHaveText("Balloon");
|
||||
await expect(dialog.getByRole("checkbox", { name: "Show System Messages in tool window" })).toBeChecked();
|
||||
await list.getByRole("option", { name: "Version Control", exact: true }).click();
|
||||
await expect(versionControlPopup).toHaveText("No popup");
|
||||
await expect(versionControlLog).not.toBeChecked();
|
||||
|
||||
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
|
||||
await expect(dialog.getByRole("button", { name: "Apply", exact: true })).toBeDisabled();
|
||||
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await page.keyboard.press("Meta+,");
|
||||
await search.fill("Version Control");
|
||||
await dialog.getByRole("treeitem", { name: "Notifications", exact: true }).click();
|
||||
await expect(versionControlPopup).toHaveText("No popup");
|
||||
await expect(versionControlLog).not.toBeChecked();
|
||||
});
|
||||
@@ -132,29 +132,53 @@
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
.notificationGroups {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
||||
align-items: start;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
.table th {
|
||||
white-space: nowrap;
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
color: var(--fg-muted);
|
||||
height: var(--h-list-row);
|
||||
padding: 0 8px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
.notificationList {
|
||||
height: calc(10 * var(--h-list-row) + 2px);
|
||||
min-width: 0;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-small);
|
||||
}
|
||||
.table td {
|
||||
white-space: nowrap;
|
||||
height: 32px;
|
||||
padding: 0 8px;
|
||||
.notificationGroupLabel {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.table tbody tr:hover {
|
||||
background: var(--bg-tree-hover);
|
||||
.notificationDetails {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
min-width: 0;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.center {
|
||||
text-align: center;
|
||||
.notificationTitle {
|
||||
margin: 0;
|
||||
color: var(--fg-strong);
|
||||
font-size: var(--fs-ui);
|
||||
font-weight: 600;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.notificationDetails .notificationPopupRow {
|
||||
grid-template-columns: fit-content(42%) minmax(0, 1fr);
|
||||
align-self: stretch;
|
||||
padding-inline: 0;
|
||||
margin-inline: 0;
|
||||
}
|
||||
.notificationPopupRow label {
|
||||
white-space: normal;
|
||||
}
|
||||
@container settings-content (max-width: 440px) {
|
||||
.notificationGroups {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.notificationList {
|
||||
height: calc(5 * var(--h-list-row) + 2px);
|
||||
}
|
||||
}
|
||||
|
||||
.iconPacks {
|
||||
|
||||
@@ -16,10 +16,10 @@ import { notifications } from "@/workbench/contributions";
|
||||
import { ZOOM_LIMITS } from "@/platform/zoom";
|
||||
import { SCHEMES as EDITOR_SCHEMES, listSchemes, customSchemes } from "@/platform/colorScheme";
|
||||
import { formatTimestamp } from "@/platform/dateFormat";
|
||||
import { Button, Checkbox, IconButton, Input, Popup, type SelectOption, T } from "@/ui";
|
||||
import { Button, Checkbox, IconButton, Input, List, Popup, type SelectOption, T } from "@/ui";
|
||||
import { NOTIFICATION_GROUPS } from "@/workbench/notificationStore";
|
||||
import { ColorSwatches, FormGroup, NumberInput, Row, SearchLabel, Select, Toggle } from "../components/Form";
|
||||
import { useLabelMatch, useSetting } from "../components/context";
|
||||
import { useLabelMatch, useSearchQuery, useSetting } from "../components/context";
|
||||
import {
|
||||
IDLE_LIMITS,
|
||||
type Antialiasing,
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
type PresentationAssistantPosition,
|
||||
type PresentationAssistantSize,
|
||||
} from "../model/behaviorSchema";
|
||||
import { labelMatches } from "../model/pages";
|
||||
import { ACCENT_PRESETS, LIMITS, type ThemeId } from "../model/schema";
|
||||
import type { PageSpec } from "./spec";
|
||||
import { HTTP_PROXY_PAGE } from "./httpProxy";
|
||||
@@ -825,59 +826,57 @@ const DISPLAY_OPTIONS: SelectOption<NotificationDisplay>[] = [
|
||||
{ value: "none", label: "No popup" },
|
||||
];
|
||||
|
||||
function NotificationGroupsTable() {
|
||||
function NotificationGroups() {
|
||||
const [groups, setGroups] = useSetting<Record<string, NotificationGroupValid>>("notifications.groups");
|
||||
const update = (id: string, patch: Partial<NotificationGroupValid>) => {
|
||||
const next = { ...(groups[id] ?? { display: "balloon", log: true }), ...patch };
|
||||
const query = useSearchQuery();
|
||||
const [selection, setSelection] = useState({ query: "", index: 0 });
|
||||
const matched = NOTIFICATION_GROUPS.findIndex((group) => labelMatches(group.title, query));
|
||||
const index = matched >= 0 && query !== selection.query ? matched : selection.index;
|
||||
const { id, title } = NOTIFICATION_GROUPS[index]!;
|
||||
const value = groups[id] ?? { display: "balloon", log: true };
|
||||
const update = (patch: Partial<NotificationGroupValid>) => {
|
||||
const next = { ...value, ...patch };
|
||||
const all = { ...groups };
|
||||
// Defaults are not stored.
|
||||
if (next.display === "balloon" && next.log) delete all[id];
|
||||
else all[id] = next;
|
||||
setGroups(all);
|
||||
};
|
||||
|
||||
return (
|
||||
<table className={styles.table} aria-label={tx("Notification groups")}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<T>Group</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Popup type</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Show in tool window</T>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{NOTIFICATION_GROUPS.map((g) => {
|
||||
const v = groups[g.id] ?? { display: "balloon", log: true };
|
||||
return (
|
||||
<tr key={g.id}>
|
||||
<td>
|
||||
<SearchLabel text={g.title} />
|
||||
</td>
|
||||
<td>
|
||||
<Select<NotificationDisplay>
|
||||
value={v.display}
|
||||
options={DISPLAY_OPTIONS}
|
||||
onChange={(display) => update(g.id, { display })}
|
||||
aria-label={tx`${g.title} popup type`}
|
||||
/>
|
||||
</td>
|
||||
<td className={styles.center}>
|
||||
<Checkbox
|
||||
checked={v.log}
|
||||
onChange={(log) => update(g.id, { log })}
|
||||
aria-label={tx`Show ${g.title} in tool window`}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
<div className={styles.notificationGroups}>
|
||||
<List
|
||||
className={styles.notificationList}
|
||||
aria-label={tx("Notification groups")}
|
||||
items={NOTIFICATION_GROUPS}
|
||||
getKey={(group) => group.id}
|
||||
activeIndex={index}
|
||||
onActiveChange={(index) => setSelection({ query, index })}
|
||||
renderItem={(group) => (
|
||||
<span title={tx(group.title)} className={styles.notificationGroupLabel}>
|
||||
<SearchLabel text={group.title} />
|
||||
</span>
|
||||
)}
|
||||
/>
|
||||
<section className={styles.notificationDetails} aria-label={tx(title)}>
|
||||
<h3 className={styles.notificationTitle}>
|
||||
<SearchLabel text={title} />
|
||||
</h3>
|
||||
<Row label="Popup type" className={styles.notificationPopupRow}>
|
||||
<Select<NotificationDisplay>
|
||||
value={value.display}
|
||||
options={DISPLAY_OPTIONS}
|
||||
onChange={(display) => update({ display })}
|
||||
aria-label={tx`${title} popup type`}
|
||||
/>
|
||||
</Row>
|
||||
<Checkbox
|
||||
checked={value.log}
|
||||
onChange={(log) => update({ log })}
|
||||
label={<SearchLabel text="Show in tool window" />}
|
||||
aria-label={tx`Show ${title} in tool window`}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1211,6 +1210,17 @@ export const BEHAVIOR_PAGES: PageSpec[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Groups",
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Popup type",
|
||||
keywords: [...NOTIFICATION_GROUPS.map((g) => g.title), "Sticky balloon", "No popup", "Show in tool window"],
|
||||
component: NotificationGroups,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Terminal",
|
||||
options: [
|
||||
@@ -1236,17 +1246,6 @@ export const BEHAVIOR_PAGES: PageSpec[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Groups",
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Popup type",
|
||||
keywords: [...NOTIFICATION_GROUPS.map((g) => g.title), "Sticky balloon", "No popup", "Show in tool window"],
|
||||
component: NotificationGroupsTable,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user