@the-portland-company/shell 0.101.0 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 0.102.0
2
+
3
+ Linked Accounts in the chrome (live test 2026-11-15 of county party ↔ campaign links; Organization Settings §8.8, Parent workspace plan row 9).
4
+
5
+ - **"Via <Parent>" in the org switcher.** A membership that comes through a Parent Organization link carries `via: { id, name }` (Politogy ID `GET /api/orgs`). `NavOrgOption` and `ChromeOrgSummary` gain an optional `via`, every org-list mapping in the chrome passes it through, and the switcher row shows "Via TEST County Party" over the Linked Account's name. Ordinary memberships look as before. New export on `./native`: `orgViaLabel(via)`. Apps that build their own list (`tokenOrg.orgs`, `controlledOrg.orgs`) must pass `via` through to show it.
6
+ - **Plain role words in the account menu.** "Roles & Organizations" printed the stored role upper-cased, so a link Account Manager read "ACCOUNT_MANAGER". It now uses the user card's labels (Admin, Account Manager, Member, Viewer), else the raw role made readable, and no longer upper-cases it. New: `menuRoleLabel()` in `lib/roleLabel`.
7
+ - Tests: `__tests__/orgSwitcherVia.test.tsx` (new).
8
+
9
+ ## 0.101.1
10
+
11
+ The user card's re-read after a profile change asks for a fresh profile (follow-up to 0.101.0, live check 2026-11-14).
12
+
13
+ - **Cause.** The chrome API (Contacts) keeps each profile row for 15 s. Politogy ID writes a new photo or name straight to VRM Core, so the re-read that 0.101.0 fires right after the save could still get the old photo when the page had read `me` in the last 15 s. Seen live: the card kept the old photo until the event fired again later.
14
+ - **Fix.** On `politogy:profile-changed` the provider reads `me?fresh=1`, and the chrome API drops its cached copy of the caller's own profile before answering (politogy-contacts, `GET /api/me?fresh=1`). An API without the flag answers a normal read.
15
+ - Tests: `__tests__/profileChanged.test.tsx` checks the re-read path.
16
+
1
17
  ## 0.101.0
2
18
 
3
19
  A new photo or name saved on My Profile shows in the left-bar user card at once (bug seen live 2026-11-14, Ben: "updating profile picture from My Profile does not immediately display in the personal information footer").
@@ -810,9 +810,10 @@ function NavChromeProvider({
810
810
  react.useEffect(() => {
811
811
  let cancelled = false;
812
812
  let latest = 0;
813
- const load = () => {
813
+ const load = (fresh = false) => {
814
814
  const call = ++latest;
815
- dedupedFetch("me", void 0).then((data) => {
815
+ const read = fresh ? fetchJsonRef.current("me?fresh=1", void 0) : dedupedFetch("me", void 0);
816
+ read.then((data) => {
816
817
  if (!cancelled && call === latest) setMe(data);
817
818
  }).catch(() => {
818
819
  }).finally(() => {
@@ -822,7 +823,7 @@ function NavChromeProvider({
822
823
  load();
823
824
  const onProfileChanged = () => {
824
825
  invalidateChromeCache("me");
825
- load();
826
+ load(true);
826
827
  };
827
828
  window.addEventListener(PROFILE_CHANGED_EVENT, onProfileChanged);
828
829
  return () => {
@@ -2238,6 +2239,11 @@ function ShellBuildLine({ footer, hidden }) {
2238
2239
  }
2239
2240
  );
2240
2241
  }
2242
+ function orgViaLabel(via) {
2243
+ if (!via) return null;
2244
+ const name = via.name?.trim();
2245
+ return name ? `Via ${name}` : "Via a parent organization";
2246
+ }
2241
2247
  var ORG_PILL_DEFAULT = "var(--color-accent-bg-safe,var(--color-accent))";
2242
2248
  var RailCollapsibleContext = react.createContext(false);
2243
2249
  function useRailCollapse() {
@@ -2559,7 +2565,22 @@ function NavSidebar({
2559
2565
  ) : (o.name ?? "Org").slice(0, 2).toUpperCase()
2560
2566
  }
2561
2567
  ),
2562
- /* @__PURE__ */ jsxRuntime.jsx("span", { title: o.name ?? o.id, className: "truncate", children: o.name ?? o.id.slice(0, 8) })
2568
+ (() => {
2569
+ const viaLabel = orgViaLabel(o.via);
2570
+ const nameEl = /* @__PURE__ */ jsxRuntime.jsx("span", { title: o.name ?? o.id, className: "truncate", children: o.name ?? o.id.slice(0, 8) });
2571
+ if (!viaLabel) return nameEl;
2572
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-col", children: [
2573
+ /* @__PURE__ */ jsxRuntime.jsx(
2574
+ "span",
2575
+ {
2576
+ "data-org-option-via": true,
2577
+ className: "truncate text-[11px] font-medium leading-tight text-[color:var(--muted)]",
2578
+ children: viaLabel
2579
+ }
2580
+ ),
2581
+ nameEl
2582
+ ] });
2583
+ })()
2563
2584
  ]
2564
2585
  },
2565
2586
  o.id
@@ -3145,7 +3166,7 @@ function NavAccountMenuPanel({
3145
3166
  userMenu?.roles && userMenu.roles.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-[color:var(--line)] px-4 py-3", children: [
3146
3167
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]", children: "Roles & Organizations" }),
3147
3168
  /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-1.5", children: userMenu.roles.map((r, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex flex-wrap items-center gap-1.5 text-sm", children: [
3148
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-md bg-[color:var(--panel)] px-2 py-0.5 text-xs font-bold uppercase tracking-wide text-[color:var(--foreground)]", children: r.role }),
3169
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-md bg-[color:var(--panel)] px-2 py-0.5 text-xs font-bold text-[color:var(--foreground)]", children: r.role }),
3149
3170
  r.orgName ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[color:var(--muted)]", children: [
3150
3171
  "in ",
3151
3172
  r.orgName
@@ -3703,6 +3724,40 @@ function resolveIdentity(input) {
3703
3724
  };
3704
3725
  }
3705
3726
 
3727
+ // src/lib/roleLabel.ts
3728
+ var ADMIN_ROLES = /* @__PURE__ */ new Set(["owner", "admin", "account_admin"]);
3729
+ var STAFF_ROLES = /* @__PURE__ */ new Set(["super_admin", "super administrator", "politogy_admin"]);
3730
+ var MANAGER_ROLES = /* @__PURE__ */ new Set(["account_manager", "account manager", "manager", "campaign_manager"]);
3731
+ var FIELD_ROLES = /* @__PURE__ */ new Set([
3732
+ "member",
3733
+ "field_user",
3734
+ "field user",
3735
+ "field",
3736
+ "volunteer",
3737
+ "canvasser",
3738
+ "caller",
3739
+ "staff"
3740
+ ]);
3741
+ var VIEWER_ROLES = /* @__PURE__ */ new Set(["viewer"]);
3742
+ function roleLabel(raw) {
3743
+ const role = (raw ?? "").trim().toLowerCase();
3744
+ if (!role) return null;
3745
+ if (ADMIN_ROLES.has(role) || STAFF_ROLES.has(role)) return "Admin";
3746
+ if (MANAGER_ROLES.has(role)) return "Account Manager";
3747
+ if (FIELD_ROLES.has(role)) return "Member";
3748
+ if (VIEWER_ROLES.has(role)) return "Viewer";
3749
+ return null;
3750
+ }
3751
+ function userCardRole(activeRawRole, appRole) {
3752
+ return roleLabel(activeRawRole) ?? roleLabel(appRole) ?? (appRole?.trim() || null);
3753
+ }
3754
+ function menuRoleLabel(raw) {
3755
+ const known = roleLabel(raw);
3756
+ if (known) return known;
3757
+ const words = (raw ?? "").trim().replace(/[_-]+/g, " ").replace(/\s+/g, " ").toLowerCase();
3758
+ return words.replace(/\b\w/g, (c) => c.toUpperCase());
3759
+ }
3760
+
3706
3761
  // src/logout-signal.ts
3707
3762
  var LOGOUT_COOKIE = "politogy_logout_at";
3708
3763
  var LOGOUT_CHANNEL = "politogy-logout";
@@ -4176,34 +4231,6 @@ function LoadingScreen({
4176
4231
  );
4177
4232
  }
4178
4233
 
4179
- // src/lib/roleLabel.ts
4180
- var ADMIN_ROLES = /* @__PURE__ */ new Set(["owner", "admin", "account_admin"]);
4181
- var STAFF_ROLES = /* @__PURE__ */ new Set(["super_admin", "super administrator", "politogy_admin"]);
4182
- var MANAGER_ROLES = /* @__PURE__ */ new Set(["account_manager", "account manager", "manager", "campaign_manager"]);
4183
- var FIELD_ROLES = /* @__PURE__ */ new Set([
4184
- "member",
4185
- "field_user",
4186
- "field user",
4187
- "field",
4188
- "volunteer",
4189
- "canvasser",
4190
- "caller",
4191
- "staff"
4192
- ]);
4193
- var VIEWER_ROLES = /* @__PURE__ */ new Set(["viewer"]);
4194
- function roleLabel(raw) {
4195
- const role = (raw ?? "").trim().toLowerCase();
4196
- if (!role) return null;
4197
- if (ADMIN_ROLES.has(role) || STAFF_ROLES.has(role)) return "Admin";
4198
- if (MANAGER_ROLES.has(role)) return "Account Manager";
4199
- if (FIELD_ROLES.has(role)) return "Member";
4200
- if (VIEWER_ROLES.has(role)) return "Viewer";
4201
- return null;
4202
- }
4203
- function userCardRole(activeRawRole, appRole) {
4204
- return roleLabel(activeRawRole) ?? roleLabel(appRole) ?? (appRole?.trim() || null);
4205
- }
4206
-
4207
4234
  // src/url-state.ts
4208
4235
  var URL_STATE_MODES = ["relationship", "campaign", "petition"];
4209
4236
  var URL_STATE_KEYS = ["mode", "page", "tab", "section", "org_id"];
@@ -4730,7 +4757,8 @@ function TokenChromeStateProvider({
4730
4757
  iconUrl: o.iconUrl ?? null,
4731
4758
  brandColor: o.brandColor,
4732
4759
  role: o.role,
4733
- rawRole: o.rawRole ?? null
4760
+ rawRole: o.rawRole ?? null,
4761
+ via: o.via ?? null
4734
4762
  })),
4735
4763
  [tokenOrg.orgs, fetchedOrgs]
4736
4764
  );
@@ -4994,7 +5022,8 @@ function ChromeStateProvider({
4994
5022
  iconUrl: o.iconUrl ?? null,
4995
5023
  brandColor: o.brandColor,
4996
5024
  role: o.role,
4997
- rawRole: o.rawRole ?? null
5025
+ rawRole: o.rawRole ?? null,
5026
+ via: o.via ?? null
4998
5027
  })),
4999
5028
  orgsLoading: false,
5000
5029
  orgPending: false,
@@ -5015,7 +5044,8 @@ function ChromeStateProvider({
5015
5044
  iconUrl: o.iconUrl ?? null,
5016
5045
  brandColor: o.brandColor,
5017
5046
  role: o.role,
5018
- rawRole: o.rawRole ?? null
5047
+ rawRole: o.rawRole ?? null,
5048
+ via: o.via ?? null
5019
5049
  })),
5020
5050
  // Loading until the fetch settles. On error we stop loading so the frame
5021
5051
  // falls back to the app label rather than shimmering forever.
@@ -5262,7 +5292,7 @@ function useChromeUserMenu({
5262
5292
  // My Profile is global — NOT org-suffixed.
5263
5293
  myProfileHref: `${auth}/my-profile`,
5264
5294
  organizationSettingsHref: `${settings}/organization-settings${orgSuffix}`,
5265
- roles: (state?.orgs ?? []).filter((o) => o.rawRole || o.role).map((o) => ({ role: o.rawRole ?? o.role, orgName: o.name })),
5295
+ roles: (state?.orgs ?? []).filter((o) => o.rawRole || o.role).map((o) => ({ role: menuRoleLabel(o.rawRole ?? o.role), orgName: o.name })),
5266
5296
  accounts: [{ id: userId, name: userName, email, avatarUrl: null, active: true }],
5267
5297
  addAccountHref: `${auth}/my-profile#accounts`
5268
5298
  // No theme control: the product is light only (Reference/UI-Platform