Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep removed sharing destinations invalid across refreshes

pulse-triage[bot]442ec68c8412
diff --git a/frontend-modern/browser-verification/d2c64d3c18a3600f.json b/frontend-modern/browser-verification/d2c64d3c18a3600f.json
new file mode 100644
index 0000000000..506083597a
--- /dev/null
+++ b/frontend-modern/browser-verification/d2c64d3c18a3600f.json
@@ -0,0 +1,59 @@
+{
+ "version": 1,
+ "base_sha": "8ea8b57201b24fc5b55781bfe32f70cbe2612bf9",
+ "verified_at": "2026-10-31T20:48:51.097Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Settings/useOrganizationSharingPanelState.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Settings/useOrganizationSharingPanelState.ts": "2ea697afd92375b78422c6565dfb609e5ac9e8262df52e09cabbd89b32e89cde"
+ },
+ "routes": [
+ "Existing Organization Sharing settings; actual producer/state, panel, OrgsAPI/client, resource consumer and stylesheet with synthetic local HTTP and WebSocket store inputs."
+ ],
+ "states": [
+ "Removed destination remains blank and invalid across repeated accepted reads and organizations_changed events",
+ "Read pending and failed states have no write controls; recovery preserves the resource but not implicit destination consent",
+ "Old destination returning does not re-enable sharing",
+ "Only an explicit current destination enables one share; cross-org draft clearing and initial defaults remain intact"
+ ],
+ "interactions": [
+ "Repeated event/read reconciliation, including a held read and a failed-read keyboard/touch retry",
+ "Clear and then explicitly select Gamma, reconcile, activate Create Share using keyboard on desktop and touch at 320px",
+ "Observe zero writes before reselection, then exactly one scoped viewer share to org-c for vm-100, with no replay",
+ "Switch to Beta after the explicit destination disappears again; prior resource draft is cleared"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 1050
+ },
+ {
+ "width": 320,
+ "height": 900
+ }
+ ],
+ "browsers": [
+ {
+ "engine": "Chromium",
+ "version": "141.0.7390.37"
+ },
+ {
+ "engine": "WebKit",
+ "version": "26.0"
+ }
+ ],
+ "playwright_version": "1.56.1",
+ "checks": 50,
+ "captures": 10,
+ "pixel_review": "All ten current repair captures opened with native view_image. Invalid blank destination, required message and disabled create are readable at both viewports. Explicit Gamma and enabled create are clear; pending and error states conceal write controls. Existing narrow grids scroll horizontally within the panel; no page overflow.",
+ "evidence": [
+ "RECEIPTS.md",
+ "BROWSER-SUMMARY.json",
+ "PIXEL-REVIEW.json",
+ "CURRENT.tar.xz",
+ "CAPTURES.tar.xz"
+ ],
+ "limitations": "Safe fixtures, not customer recovery or a private installed service. Initial fixture had no seeded resources; the partial desktop run completed 18 successful checks and five captures then timed out assuming a Quick Pick after switching scope. The remaining-only continuation adds 32 checks/five narrow captures and desktop scope reset without replaying completed desktop proof; both cleanup results are retained."
+}
diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx
index 715233d177..951cb6a484 100644
--- a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx
@@ -639,6 +639,101 @@ describe('sharing read admission and recovery', () => {
expect(createShareMock.mock.calls[0][1].targetOrgId).toBe('org-c');
});
+ it.each(['reload', 'directory event', 'failed read recovery', 'returned destination'])(
+ 'keeps a removed destination invalid across %s until an explicit current choice',
+ async (refresh) => {
+ const replacementOrg = { ...targetOrg, id: 'org-c', displayName: 'Organization C' };
+ const { state } = renderState();
+ await accepted(state);
+ state.applyResourceQuickPick('vm::vm-100');
+ expect(state.targetOrgId()).toBe('org-b');
+ listOrgsMock.mockResolvedValue([baseOrg, replacementOrg]);
+ await state.loadSharingData();
+ expect(state.targetOrgId()).toBe('');
+ expect(state.canCreateShare()).toBe(false);
+ await state.createShare();
+ expect(createShareMock).not.toHaveBeenCalled();
+
+ if (refresh === 'directory event') {
+ const calls = listOrgsMock.mock.calls.length;
+ emit('organizations_changed');
+ expect(listOrgsMock).toHaveBeenCalledTimes(calls + 1);
+ await accepted(state);
+ } else {
+ if (refresh === 'failed read recovery') {
+ orgGetMock.mockRejectedValueOnce(new Error('503'));
+ await state.loadSharingData();
+ expect(state.loadError()).toBeTruthy();
+ await state.createShare();
+ expect(createShareMock).not.toHaveBeenCalled();
+ }
+ if (refresh === 'returned destination') {
+ listOrgsMock.mockResolvedValue([baseOrg, targetOrg, replacementOrg]);
+ }
+ await state.loadSharingData();
+ }
+ // Neither another accepted read nor the old destination returning is consent.
+ expect(state.targetOrgId()).toBe('');
+ expect(state.targetOrgError()).toBeTruthy();
+ expect(state.selectedQuickPick()).toBe('vm::vm-100');
+ expect(state.resourceId()).toBe('vm-100');
+ expect(state.canCreateShare()).toBe(false);
+ await state.createShare();
+ expect(createShareMock).not.toHaveBeenCalled();
+ state.updateTargetOrg('not-in-directory');
+ await state.loadSharingData();
+ expect(state.targetOrgId()).toBe('');
+ await state.createShare();
+ expect(createShareMock).not.toHaveBeenCalled();
+
+ state.updateTargetOrg('org-c');
+ await state.loadSharingData();
+ expect(state.canCreateShare()).toBe(true);
+ await state.createShare();
+ await accepted(state);
+ expect(createShareMock).toHaveBeenCalledTimes(1);
+ expect(createShareMock).toHaveBeenCalledWith(
+ 'org-a',
+ expect.objectContaining({
+ targetOrgId: 'org-c',
+ resourceId: 'vm-100',
+ accessRole: 'viewer',
+ }),
+ strictOptions(),
+ );
+ },
+ );
+
+ it.each(['organization', 'user'])(
+ 'clears the invalid destination and resource draft when the selected %s changes',
+ async (selection) => {
+ const replacementOrg = { ...targetOrg, id: 'org-c', displayName: 'Organization C' };
+ const { state, setUser } = renderState();
+ await accepted(state);
+ state.applyResourceQuickPick('vm::vm-100');
+ listOrgsMock.mockResolvedValue([baseOrg, replacementOrg]);
+ await state.loadSharingData();
+ expect(state.targetOrgId()).toBe('');
+ if (selection === 'organization') {
+ getOrgIDMock.mockReturnValue('org-c');
+ orgGetMock.mockResolvedValue({ ...replacementOrg, ownerUserId: 'user-1' });
+ emit('org_switched');
+ } else {
+ orgGetMock.mockResolvedValue({ ...baseOrg, ownerUserId: 'user-3' });
+ setUser('user-3');
+ }
+ await accepted(state);
+ expect(state.targetOrgId()).toBe(selection === 'organization' ? 'org-a' : 'org-c');
+ expect(state.selectedQuickPick()).toBe('');
+ expect(state.resourceType()).toBe('');
+ expect(state.resourceId()).toBe('');
+ expect(state.resourceName()).toBe('');
+ expect(state.canCreateShare()).toBe(false);
+ await state.createShare();
+ expect(createShareMock).not.toHaveBeenCalled();
+ },
+ );
+
it('ignores a late failure without suppressing current actions or emitting a stale error', async () => {
const old = deferred<typeof baseOrg>();
orgGetMock.mockReturnValueOnce(old.promise);
diff --git a/frontend-modern/src/components/Settings/useOrganizationSharingPanelState.ts b/frontend-modern/src/components/Settings/useOrganizationSharingPanelState.ts
index 1d6f4698aa..8cd77ef88c 100644
--- a/frontend-modern/src/components/Settings/useOrganizationSharingPanelState.ts
+++ b/frontend-modern/src/components/Settings/useOrganizationSharingPanelState.ts
@@ -80,6 +80,9 @@ export function useOrganizationSharingPanelState(props: OrganizationSharingPanel
let disposed = false;
let readController: AbortController | undefined;
let mutationController: AbortController | undefined;
+ // Losing a destination is a draft decision, not a transient read error.
+ // Keep it invalid across refreshes until a current destination is chosen.
+ let targetOrgNeedsReselection = false;
const surfaceEnabled = () =>
isMultiTenantEnabled() && !presentationPolicyHidesOrganizationSurfaces();
const selectionIsCurrent = () =>
@@ -171,6 +174,7 @@ export function useOrganizationSharingPanelState(props: OrganizationSharingPanel
setIncomingShares([]);
};
const clearDraft = () => {
+ targetOrgNeedsReselection = false;
setTargetOrgId('');
setResourceType('');
setResourceId('');
@@ -245,11 +249,15 @@ export function useOrganizationSharingPanelState(props: OrganizationSharingPanel
const draftTarget = targetOrgId().trim();
// If a previously chosen destination disappeared, require a new choice
// rather than retaining an invisible value or choosing a different org.
- const firstTarget = draftTarget
- ? allOrgs.some((candidate) => candidate.id === draftTarget && candidate.id !== orgId)
- ? draftTarget
- : ''
- : allOrgs.find((candidate) => candidate.id !== orgId)?.id || '';
+ if (
+ draftTarget &&
+ !allOrgs.some((candidate) => candidate.id === draftTarget && candidate.id !== orgId)
+ ) {
+ targetOrgNeedsReselection = true;
+ }
+ const firstTarget = targetOrgNeedsReselection
+ ? ''
+ : draftTarget || allOrgs.find((candidate) => candidate.id !== orgId)?.id || '';
setTargetOrgId(firstTarget);
setTargetOrgError(firstTarget === '' ? getOrganizationShareTargetOrgRequiredMessage() : '');
});
@@ -329,6 +337,7 @@ export function useOrganizationSharingPanelState(props: OrganizationSharingPanel
};
const updateTargetOrg = (value: string) => {
+ targetOrgNeedsReselection = !targetOrgOptions().some((candidate) => candidate.id === value);
setTargetOrgId(value);
setTargetOrgError(value.trim() === '' ? getOrganizationShareTargetOrgRequiredMessage() : '');
};