@the-portland-company/shell 0.101.1 → 0.102.1

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.1
2
+
3
+ The Credits tooltip's gauges stay inside the tooltip (bug seen live 2026-11-15, Ben: "the credits tooltip has gauges extending past the container").
4
+
5
+ - **Cause.** The shared top-bar tooltip is at most `max-w-56` (224px) with `px-3` padding, so it has 200px for content. The Credits tooltip's content was a fixed `w-56` (224px), so its gauges ran 24px past the content edge and 12px past the tooltip's own edge.
6
+ - **Fix.** The Credits tooltip content is `w-full min-w-48`: it fills the 200px content box, and short lines no longer shrink the gauges. Checked in a browser: the gauges are 200px wide (192px when every line is short) and stay inside the padding.
7
+ - Tests: `__tests__/chromeActions.test.tsx` checks the content has no fixed width wider than the tooltip.
8
+
9
+ ## 0.102.0
10
+
11
+ Linked Accounts in the chrome (live test 2026-11-15 of county party ↔ campaign links; Organization Settings §8.8, Parent workspace plan row 9).
12
+
13
+ - **"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.
14
+ - **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`.
15
+ - Tests: `__tests__/orgSwitcherVia.test.tsx` (new).
16
+
1
17
  ## 0.101.1
2
18
 
3
19
  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).
@@ -1167,7 +1167,7 @@ function CreditRow({
1167
1167
  ] });
1168
1168
  }
1169
1169
  function CreditsTooltip({ fuel }) {
1170
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex w-56 flex-col gap-1.5", "data-testid": "credits-tooltip", children: CREDIT_TYPE_ORDER.map((type) => {
1170
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex w-full min-w-48 flex-col gap-1.5", "data-testid": "credits-tooltip", children: CREDIT_TYPE_ORDER.map((type) => {
1171
1171
  const channel = fuel ? fuel[type] ?? null : null;
1172
1172
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col gap-0.5", children: [
1173
1173
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: creditTooltipLine(type, channel) }),
@@ -2239,6 +2239,11 @@ function ShellBuildLine({ footer, hidden }) {
2239
2239
  }
2240
2240
  );
2241
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
+ }
2242
2247
  var ORG_PILL_DEFAULT = "var(--color-accent-bg-safe,var(--color-accent))";
2243
2248
  var RailCollapsibleContext = react.createContext(false);
2244
2249
  function useRailCollapse() {
@@ -2560,7 +2565,22 @@ function NavSidebar({
2560
2565
  ) : (o.name ?? "Org").slice(0, 2).toUpperCase()
2561
2566
  }
2562
2567
  ),
2563
- /* @__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
+ })()
2564
2584
  ]
2565
2585
  },
2566
2586
  o.id
@@ -3146,7 +3166,7 @@ function NavAccountMenuPanel({
3146
3166
  userMenu?.roles && userMenu.roles.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-[color:var(--line)] px-4 py-3", children: [
3147
3167
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]", children: "Roles & Organizations" }),
3148
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: [
3149
- /* @__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 }),
3150
3170
  r.orgName ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[color:var(--muted)]", children: [
3151
3171
  "in ",
3152
3172
  r.orgName
@@ -3704,6 +3724,40 @@ function resolveIdentity(input) {
3704
3724
  };
3705
3725
  }
3706
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
+
3707
3761
  // src/logout-signal.ts
3708
3762
  var LOGOUT_COOKIE = "politogy_logout_at";
3709
3763
  var LOGOUT_CHANNEL = "politogy-logout";
@@ -4177,34 +4231,6 @@ function LoadingScreen({
4177
4231
  );
4178
4232
  }
4179
4233
 
4180
- // src/lib/roleLabel.ts
4181
- var ADMIN_ROLES = /* @__PURE__ */ new Set(["owner", "admin", "account_admin"]);
4182
- var STAFF_ROLES = /* @__PURE__ */ new Set(["super_admin", "super administrator", "politogy_admin"]);
4183
- var MANAGER_ROLES = /* @__PURE__ */ new Set(["account_manager", "account manager", "manager", "campaign_manager"]);
4184
- var FIELD_ROLES = /* @__PURE__ */ new Set([
4185
- "member",
4186
- "field_user",
4187
- "field user",
4188
- "field",
4189
- "volunteer",
4190
- "canvasser",
4191
- "caller",
4192
- "staff"
4193
- ]);
4194
- var VIEWER_ROLES = /* @__PURE__ */ new Set(["viewer"]);
4195
- function roleLabel(raw) {
4196
- const role = (raw ?? "").trim().toLowerCase();
4197
- if (!role) return null;
4198
- if (ADMIN_ROLES.has(role) || STAFF_ROLES.has(role)) return "Admin";
4199
- if (MANAGER_ROLES.has(role)) return "Account Manager";
4200
- if (FIELD_ROLES.has(role)) return "Member";
4201
- if (VIEWER_ROLES.has(role)) return "Viewer";
4202
- return null;
4203
- }
4204
- function userCardRole(activeRawRole, appRole) {
4205
- return roleLabel(activeRawRole) ?? roleLabel(appRole) ?? (appRole?.trim() || null);
4206
- }
4207
-
4208
4234
  // src/url-state.ts
4209
4235
  var URL_STATE_MODES = ["relationship", "campaign", "petition"];
4210
4236
  var URL_STATE_KEYS = ["mode", "page", "tab", "section", "org_id"];
@@ -4731,7 +4757,8 @@ function TokenChromeStateProvider({
4731
4757
  iconUrl: o.iconUrl ?? null,
4732
4758
  brandColor: o.brandColor,
4733
4759
  role: o.role,
4734
- rawRole: o.rawRole ?? null
4760
+ rawRole: o.rawRole ?? null,
4761
+ via: o.via ?? null
4735
4762
  })),
4736
4763
  [tokenOrg.orgs, fetchedOrgs]
4737
4764
  );
@@ -4995,7 +5022,8 @@ function ChromeStateProvider({
4995
5022
  iconUrl: o.iconUrl ?? null,
4996
5023
  brandColor: o.brandColor,
4997
5024
  role: o.role,
4998
- rawRole: o.rawRole ?? null
5025
+ rawRole: o.rawRole ?? null,
5026
+ via: o.via ?? null
4999
5027
  })),
5000
5028
  orgsLoading: false,
5001
5029
  orgPending: false,
@@ -5016,7 +5044,8 @@ function ChromeStateProvider({
5016
5044
  iconUrl: o.iconUrl ?? null,
5017
5045
  brandColor: o.brandColor,
5018
5046
  role: o.role,
5019
- rawRole: o.rawRole ?? null
5047
+ rawRole: o.rawRole ?? null,
5048
+ via: o.via ?? null
5020
5049
  })),
5021
5050
  // Loading until the fetch settles. On error we stop loading so the frame
5022
5051
  // falls back to the app label rather than shimmering forever.
@@ -5263,7 +5292,7 @@ function useChromeUserMenu({
5263
5292
  // My Profile is global — NOT org-suffixed.
5264
5293
  myProfileHref: `${auth}/my-profile`,
5265
5294
  organizationSettingsHref: `${settings}/organization-settings${orgSuffix}`,
5266
- 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 })),
5267
5296
  accounts: [{ id: userId, name: userName, email, avatarUrl: null, active: true }],
5268
5297
  addAccountHref: `${auth}/my-profile#accounts`
5269
5298
  // No theme control: the product is light only (Reference/UI-Platform