History

fix: disable plugin actions during mutations

t3-code[bot] committed 2 months ago

Commit 52a541f1 parent 890e0022 files · +21 −1Browse files

Unified · Split

2 files
  1. apps/web/src/components/settings/PluginsSettings.test.tsx +20 −0
  2. apps/web/src/components/settings/PluginsSettings.tsx +1 −1
apps/web/src/components/settings/PluginsSettings.test.tsx+20−0
@@ -242,4 +242,24 @@ describe("PluginsSettingsPanel", () => { · 241 unmodified lines
242242 visitElements(panel, (element) => element.props["data-plugin-read-only"] === true),
243243 ).not.toBeNull();
244244 });
245+
246+ it("disables every package action while one lifecycle mutation is pending", () => {
247+ commands.disable.mockReturnValue(new Promise(() => undefined));
248+ const panel = renderPanel();
249+ const activeRow = renderPackageRow(panel, "com.acme.active");
250+ const disable = visitElements(
251+ activeRow,
252+ (element) => element.props["aria-label"] === "Disable com.acme.active",
253+ );
254+ (disable?.props.onCheckedChange as ((checked: boolean) => void) | undefined)?.(false);
255+
256+ const pendingPanel = renderPanel();
257+ const disabledRow = renderPackageRow(pendingPanel, "com.acme.disabled");
258+ const enable = visitElements(
259+ disabledRow,
260+ (element) => element.props["aria-label"] === "Enable com.acme.disabled",
261+ );
262+
263+ expect(enable?.props.disabled).toBe(true);
264+ });
245265 });
apps/web/src/components/settings/PluginsSettings.tsx+1−1
@@ -271,7 +271,7 @@ export function PluginsSettingsPanel() { · 270 unmodified lines
271271 <PluginPackageRow
272272 key={pluginPackage.id}
273273 pluginPackage={pluginPackage}
274− readOnly={readOnly}
274+ readOnly={readOnly || pending !== null}
275275 pendingAction={
276276 pending !== null && pending.id === pluginPackage.id ? pending.action : null
277277 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t