|
4 | 4 | * Header-left organization (workspace) switcher — the standard place users |
5 | 5 | * expect "which org am I in / switch org" to live (Linear/Vercel/GitHub style). |
6 | 6 | * |
7 | | - * - Single-org users (the vast majority): render NOTHING. With one org there is |
8 | | - * nothing to switch to, so a dropdown here would control nothing. The |
9 | | - * switcher is a multi-org affordance. Where a tenancy wall IS in force the |
| 7 | + * - Single-org users (the vast majority): render NOTHING on the web. With one |
| 8 | + * org there is nothing to switch to, so a dropdown here would control |
| 9 | + * nothing. The web switcher is a multi-org affordance (the mobile shell's |
| 10 | + * native switcher, below, is not). Where a tenancy wall IS in force the |
10 | 11 | * org name still matters at one membership — `CurrentOrganizationIndicator` |
11 | 12 | * renders it read-only there (objectui#5287), without a control. |
12 | 13 | * - Multi-org users: the active org name + a dropdown to switch orgs inline |
|
15 | 16 | * - No org context at all: renders nothing. |
16 | 17 | * |
17 | 18 | * Inside the ObjectStack mobile shell (`@object-ui/mobile`), when the shell |
18 | | - * announces `showConnectionSwitcher`, the same button opens the shell's native |
19 | | - * switcher instead of the dropdown: it lists the saved organizations and |
20 | | - * company servers the shell holds, which the web menu cannot see. In a plain |
21 | | - * browser, or a shell without the capability, the dropdown opens as before. |
| 19 | + * announces `showConnectionSwitcher`, the button opens the shell's native |
| 20 | + * switcher instead of the dropdown, and it renders whenever there is an active |
| 21 | + * organization, at any membership count: the sheet lists the connections the |
| 22 | + * shell holds across company servers, which this server's membership list |
| 23 | + * cannot count. In a plain browser, or a shell without the capability, the |
| 24 | + * rules above apply unchanged. |
22 | 25 | * |
23 | 26 | * Under `group` tenancy posture (ADR-0105) the switcher's meaning changes: |
24 | 27 | * the active organization is only the WRITE target — reads span every |
@@ -79,35 +82,6 @@ export function WorkspaceSwitcher() { |
79 | 82 | // rather than an empty switcher or a guessed name. |
80 | 83 | if (!current) return null; |
81 | 84 |
|
82 | | - // Single-org: render nothing. With only one org there's nothing to switch to, |
83 | | - // so a dropdown here would be a control that controls nothing. The switcher |
84 | | - // appears only once a second org exists. On a walled deployment the org NAME |
85 | | - // is still load-bearing context at one membership — `CurrentOrganizationIndicator` |
86 | | - // renders it read-only for exactly this case (objectui#5287); this rule is |
87 | | - // unchanged. |
88 | | - if (orgList.length <= 1) return null; |
89 | | - |
90 | | - const handleSwitch = (org: AuthOrganization) => { |
91 | | - if (org.id === current.id) return; |
92 | | - // objectui#13231 — ask BEFORE `set-active` is sent. Asking at the reload |
93 | | - // would be too late: the server has already switched, and the page holding |
94 | | - // the edits reloads itself for the new organization (dropping them, and its |
95 | | - // leave prompt with them) before the document load starts. On Cancel |
96 | | - // nothing is sent: the organization, the URL and the edits stay. |
97 | | - confirmUnsavedLeave(async () => { |
98 | | - try { |
99 | | - await switchOrganization(org.id); |
100 | | - // switchOrganization only updates state; reload to the console root so the |
101 | | - // new active org propagates to every data scope app-wide AND |
102 | | - // RootLandingRedirect resolves the right landing (single-app workspace → |
103 | | - // that app, not the redundant launcher). Same as OrganizationsPage. |
104 | | - window.location.href = resolveRootUrl(); |
105 | | - } catch (err) { |
106 | | - console.error('[WorkspaceSwitcher] switch failed', err); |
107 | | - } |
108 | | - }); |
109 | | - }; |
110 | | - |
111 | 85 | const triggerClassName = |
112 | 86 | 'ml-2 inline-flex max-w-[14rem] items-center gap-1.5 rounded-md px-1.5 py-1 text-sm font-medium text-foreground/80 transition-colors hover:bg-accent hover:text-foreground'; |
113 | 87 | const triggerContent = ( |
@@ -140,6 +114,35 @@ export function WorkspaceSwitcher() { |
140 | 114 | ); |
141 | 115 | } |
142 | 116 |
|
| 117 | + // Single-org: render nothing. With only one org there's nothing to switch to, |
| 118 | + // so a dropdown here would be a control that controls nothing. The switcher |
| 119 | + // appears only once a second org exists. On a walled deployment the org NAME |
| 120 | + // is still load-bearing context at one membership — `CurrentOrganizationIndicator` |
| 121 | + // renders it read-only for exactly this case (objectui#5287); this rule is |
| 122 | + // unchanged. |
| 123 | + if (orgList.length <= 1) return null; |
| 124 | + |
| 125 | + const handleSwitch = (org: AuthOrganization) => { |
| 126 | + if (org.id === current.id) return; |
| 127 | + // objectui#13231 — ask BEFORE `set-active` is sent. Asking at the reload |
| 128 | + // would be too late: the server has already switched, and the page holding |
| 129 | + // the edits reloads itself for the new organization (dropping them, and its |
| 130 | + // leave prompt with them) before the document load starts. On Cancel |
| 131 | + // nothing is sent: the organization, the URL and the edits stay. |
| 132 | + confirmUnsavedLeave(async () => { |
| 133 | + try { |
| 134 | + await switchOrganization(org.id); |
| 135 | + // switchOrganization only updates state; reload to the console root so the |
| 136 | + // new active org propagates to every data scope app-wide AND |
| 137 | + // RootLandingRedirect resolves the right landing (single-app workspace → |
| 138 | + // that app, not the redundant launcher). Same as OrganizationsPage. |
| 139 | + window.location.href = resolveRootUrl(); |
| 140 | + } catch (err) { |
| 141 | + console.error('[WorkspaceSwitcher] switch failed', err); |
| 142 | + } |
| 143 | + }); |
| 144 | + }; |
| 145 | + |
143 | 146 | return ( |
144 | 147 | <DropdownMenu> |
145 | 148 | <DropdownMenuTrigger className={triggerClassName} data-testid="workspace-switcher"> |
|
0 commit comments