Upgrade to Onyx v5.0.3; gate notifications on full-admin only

- Pin upstream to v5.0.3 (branding/branding.config.json).
- Notifications: gate on isAdmin (FULL_ADMIN_PANEL_ACCESS) instead of
  hasAdminAccess. hasAdminAccess also returns true for group/agent
  managers, so manage-agents users were still seeing the bell/panel. Now
  only full admins see notifications; everyone else gets nothing.
  Re-authored for v5's refactored AccountPopover (useSettingsItems hook +
  Dropdown views model): hide the notifications menu row and the account-
  button unread badge for non-admins.
- Re-sync the overlay onto v5.0.3:
  - smb-ui.patch regenerated (v5 moved the doc types and uses
    openExternalLink); still 2 files, keyed on metadata.smb_source,
    applies clean.
  - SettingsPage language limit re-synced to v5's LOCALE_OPTIONS spread
    (was SUPPORTED_LOCALES.map).
  - Verified against v5.0.3: all patch anchors match, icons regex matches,
    logo/favicon target paths exist.
This commit is contained in:
Jannic Debus 2026-11-09 21:39:49 +01:00
parent 8143cc123f
commit 2c42e9fd03
3 changed files with 103 additions and 72 deletions

View file

@ -298,69 +298,98 @@ await patchFile("components/icons/icons.tsx", [{
}]); }]);
// (a2) Whitelabel: the notification centre is admin-facing only. Hide the bell, // (a2) Whitelabel: the notification centre is admin-facing only. Hide the bell,
// panel and unread badge for non-admin end users; admins keep the full centre. // panel and unread badge for everyone except full admins. Gate on `isAdmin`
// Gate on hasAdminAccess (admins + curators) from useUser(). // (= FULL_ADMIN_PANEL_ACCESS) from useUser(), NOT `hasAdminAccess`: the latter
// also returns true for group/agent managers (who can reach the admin panel),
// so they would still see notifications. v5 moved the account menu into the
// `useSettingsItems()` hook + a Dropdown views model, so these anchors differ
// from v4.
await patchFile("sections/sidebar/AccountPopover.tsx", [ await patchFile("sections/sidebar/AccountPopover.tsx", [
{ {
desc: "expose hasAdminAccess from useUser (both popovers)", desc: "expose isAdmin from useUser in useSettingsItems",
done: "userResolution, hasAdminAccess }", done: "userResolution, isAdmin } = useUser();\n const settings",
find: "const { user, userResolution } = useUser();", find: `const { user, userResolution } = useUser();
replace: "const { user, userResolution, hasAdminAccess } = useUser();", const settings = useSettings();`,
replace: `const { user, userResolution, isAdmin } = useUser();
const settings = useSettings();`,
}, },
{ {
desc: "hide Notifications menu item for non-admins", desc: "expose isAdmin from useUser in AccountPopover",
done: "// AIDO: the notification centre is admin-facing only", done: "setMenuOpen(false);\n const { user, userResolution, isAdmin }",
find: ` </div>, find: `const [menuOpen, setMenuOpen] = useState(false);
const { user, userResolution } = useUser();`,
replace: `const [menuOpen, setMenuOpen] = useState(false);
const { user, userResolution, isAdmin } = useUser();`,
},
{
desc: "show the Notifications menu row only to full admins",
done: "AIDO: the notification centre is admin-facing only",
find: ` {
kind: "custom",
id: "notifications",
keywords: [t("notifications.label")],
onActivate: (views) => views.push("notifications"),
render: ({ highlighted, props }) => (
<LineItemButton <LineItemButton
key="notifications" presentational
selectVariant="select-heavy"
interaction={highlighted ? "hover" : "rest"}
sizePreset="main-ui" sizePreset="main-ui"
variant="section" variant="section"
rounding={2} rounding={2}
icon={SvgBell} icon={SvgBell}
title={t("notifications.label")} title={t("notifications.label")}
onClick={onOpenNotifications}
rightChildren={
undismissedCount ? (
<SvgNotificationBubble count={undismissedCount} />
) : undefined
}
/>,`,
replace: ` </div>,
// AIDO: the notification centre is admin-facing only. Hide the bell for
// non-admin end users; admins keep the full notification centre.
hasAdminAccess ? (
<LineItemButton
key="notifications"
sizePreset="main-ui"
variant="section"
rounding={2}
icon={SvgBell}
title={t("notifications.label")}
onClick={onOpenNotifications}
rightChildren={ rightChildren={
undismissedCount ? ( undismissedCount ? (
<SvgNotificationBubble count={undismissedCount} /> <SvgNotificationBubble count={undismissedCount} />
) : undefined ) : undefined
} }
{...props}
/> />
) : null,`, ),
},`,
replace: ` // AIDO: the notification centre is admin-facing only. Show the
// notifications row only to full admins (isAdmin), not manage-agents
// curators. Non-admins never see the bell, panel or unread badge.
...(isAdmin
? [
{
kind: "custom" as const,
id: "notifications",
keywords: [t("notifications.label")],
onActivate: (views) => views.push("notifications"),
render: ({ highlighted, props }) => (
<LineItemButton
presentational
selectVariant="select-heavy"
interaction={highlighted ? "hover" : "rest"}
sizePreset="main-ui"
variant="section"
rounding={2}
icon={SvgBell}
title={t("notifications.label")}
rightChildren={
undismissedCount ? (
<SvgNotificationBubble count={undismissedCount} />
) : undefined
}
{...props}
/>
),
},
]
: []),`,
}, },
{ {
desc: "hide unread badge on the account button for non-admins", desc: "hide the unread badge on the account button for non-admins",
done: "hasAdminAccess && undismissedCount ?", done: "isAdmin && undismissedCount ? (",
find: ` rightChildren={ find: ` rightChildren={
undismissedCount ? ( undismissedCount ? (
<Section padding={2}>`, <Section padding={2}>`,
replace: ` rightChildren={ replace: ` rightChildren={
hasAdminAccess && undismissedCount ? ( isAdmin && undismissedCount ? (
<Section padding={2}>`, <Section padding={2}>`,
}, },
{
desc: "do not render the Notifications popover for non-admins",
done: `"Notifications" && hasAdminAccess`,
find: `{popupState === "Notifications" && (`,
replace: `{popupState === "Notifications" && hasAdminAccess && (`,
},
]); ]);
// (a3) Whitelabel: limit the UI language selector to German + English (client // (a3) Whitelabel: limit the UI language selector to German + English (client
@ -369,10 +398,11 @@ await patchFile("sections/sidebar/AccountPopover.tsx", [
await patchFile("views/SettingsPage.tsx", [ await patchFile("views/SettingsPage.tsx", [
{ {
desc: "limit language selector to de + en", desc: "limit language selector to de + en",
done: `["en", "de"].includes(l)`, done: `LOCALE_OPTIONS.filter((o) => ["en", "de"].includes(o.value))`,
find: `{SUPPORTED_LOCALES.map((locale) => (`, find: ` ...LOCALE_OPTIONS,`,
replace: `{SUPPORTED_LOCALES.filter((l) => ["en", "de"].includes(l)).map( replace: ` ...LOCALE_OPTIONS.filter((o) =>
(locale) => (`, ["en", "de"].includes(o.value)
),`,
}, },
]); ]);

View file

@ -9,7 +9,7 @@
"upstream": { "upstream": {
"$comment": "Pin the exact Onyx release tag this overlay is authored against. `make setup` checks this out. Locked to a release NUMBER (e.g. v4.7.2), not a raw commit. As of v4.7.2 Onyx ships OFFICIAL i18n (next-intl, incl. German), so the temporary i18n backport is disabled (i18n.enabled=false) and the codemod rebrands Onyx->AIDO inside the official message catalogs instead. To move to a newer Onyx: re-sync the smbUi patch onto the new tag (targeted patches in apply-branding.mjs are string-based and usually survive), then bump this.", "$comment": "Pin the exact Onyx release tag this overlay is authored against. `make setup` checks this out. Locked to a release NUMBER (e.g. v4.7.2), not a raw commit. As of v4.7.2 Onyx ships OFFICIAL i18n (next-intl, incl. German), so the temporary i18n backport is disabled (i18n.enabled=false) and the codemod rebrands Onyx->AIDO inside the official message catalogs instead. To move to a newer Onyx: re-sync the smbUi patch onto the new tag (targeted patches in apply-branding.mjs are string-based and usually survive), then bump this.",
"repo": "https://github.com/onyx-dot-app/onyx", "repo": "https://github.com/onyx-dot-app/onyx",
"pinnedCommit": "v4.8.2", "pinnedCommit": "v5.0.3",
"webSrcRoot": "web" "webSrcRoot": "web"
}, },
"i18n": { "i18n": {
@ -28,7 +28,7 @@
"$dictionaries_comment": "Client-editable source dictionaries. After the patch is applied, apply-branding.mjs copies dictionaries/<lang>.json over web/public/locales/<lang>/common.json — so edits here PERSIST across `make setup` (they're the source of truth, not the patch). Edit branding/i18n/locales/de.json to add/refine German (see MISSING-de.md for untranslated keys), then `make apply && make build`." "$dictionaries_comment": "Client-editable source dictionaries. After the patch is applied, apply-branding.mjs copies dictionaries/<lang>.json over web/public/locales/<lang>/common.json — so edits here PERSIST across `make setup` (they're the source of truth, not the patch). Edit branding/i18n/locales/de.json to add/refine German (see MISSING-de.md for untranslated keys), then `make apply && make build`."
}, },
"smbUi": { "smbUi": {
"$comment": "SMB connector UI overlay (smb-connector/): a tiny frontend overlay so documents synced from SMB/network shares don't present a broken, dead file-preview. SMB documents are detected by metadata.smb_source (they are ingested as the `file` source, so they show in Default Chat and the source filters). Clicking a cited SMB document copies its full logical network path (\\\\company\\share\\...) from metadata.logical_path to the clipboard instead, so the user can open it on the share. Covers both the chat citation view and the licensed Search view. (The earlier 'Initial Indexing' badge fix was dropped: File connectors report status correctly on their own.) Applied before the branding codemod; re-synced onto v4.8.2. Independent of the connector itself; set enabled=false to drop it.", "$comment": "SMB connector UI overlay (smb-connector/): a tiny frontend overlay so documents synced from SMB/network shares don't present a broken, dead file-preview. SMB documents are detected by metadata.smb_source (they are ingested as the `file` source, so they show in Default Chat and the source filters). Clicking a cited SMB document copies its full logical network path (\\\\company\\share\\...) from metadata.logical_path to the clipboard instead, so the user can open it on the share. Covers both the chat citation view and the licensed Search view. (The earlier 'Initial Indexing' badge fix was dropped: File connectors report status correctly on their own.) Applied before the branding codemod; re-synced onto v5.0.3. Independent of the connector itself; set enabled=false to drop it.",
"enabled": true, "enabled": true,
"patch": "branding/smb/smb-ui.patch" "patch": "branding/smb/smb-ui.patch"
}, },

View file

@ -1,15 +1,15 @@
diff --git a/web/src/ee/sections/SearchCard.tsx b/web/src/ee/sections/SearchCard.tsx diff --git a/web/src/ee/sections/SearchCard.tsx b/web/src/ee/sections/SearchCard.tsx
index 71b5255d..9b76cbe5 100644 index f4cc98b..63dce83 100644
--- a/web/src/ee/sections/SearchCard.tsx --- a/web/src/ee/sections/SearchCard.tsx
+++ b/web/src/ee/sections/SearchCard.tsx +++ b/web/src/ee/sections/SearchCard.tsx
@@ -10,6 +10,7 @@ import { ValidSources } from "@/lib/types"; @@ -11,6 +11,7 @@ import { ValidSources } from "@/lib/connectors/types/source";
import { MinimalOnyxDocument } from "@/lib/search/interfaces"; import { MinimalOnyxDocument } from "@/lib/search/types";
import { Section } from "@/layouts/general-layouts"; import { Section } from "@/layouts/general-layouts";
import { Interactive } from "@opal/core"; import { Interactive } from "@opal/core";
+import { toast } from "@opal/layouts"; +import { toast } from "@opal/layouts";
import Truncated from "@/refresh-components/texts/Truncated";
import { timeAgo } from "@opal/time"; import { timeAgo } from "@opal/time";
import { useMemo } from "react"; import { useMemo } from "react";
import { useLocale } from "next-intl";
@@ -39,6 +40,27 @@ export default function SearchCard({ @@ -39,6 +40,27 @@ export default function SearchCard({
document.is_internet || document.source_type === ValidSources.Web; document.is_internet || document.source_type === ValidSources.Web;
@ -39,17 +39,18 @@ index 71b5255d..9b76cbe5 100644
window.open(document.link, "_blank", "noopener,noreferrer"); window.open(document.link, "_blank", "noopener,noreferrer");
return; return;
diff --git a/web/src/lib/search/utils.ts b/web/src/lib/search/utils.ts diff --git a/web/src/lib/search/utils.ts b/web/src/lib/search/utils.ts
index ce7eab36..ebddf26b 100644 index 38dc56f..95de8ea 100644
--- a/web/src/lib/search/utils.ts --- a/web/src/lib/search/utils.ts
+++ b/web/src/lib/search/utils.ts +++ b/web/src/lib/search/utils.ts
@@ -1,5 +1,6 @@ @@ -1,6 +1,7 @@
import { ValidSources } from "@/lib/types"; import { ValidSources } from "@/lib/connectors/types/source";
import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/interfaces"; import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/types";
import { transformLinkUri } from "@/lib/utils";
+import { toast } from "@opal/layouts"; +import { toast } from "@opal/layouts";
// If we have a link, open it in a new tab (including if it's a file) export const openExternalLink = (url: string) => {
// If above fails and we have a file, update the presenting document const safeUrl = transformLinkUri(url);
@@ -7,6 +8,26 @@ export const openDocument = ( @@ -47,6 +48,26 @@ export const openDocument = (
document: OnyxDocument, document: OnyxDocument,
updatePresentingDocument?: (document: MinimalOnyxDocument) => void updatePresentingDocument?: (document: MinimalOnyxDocument) => void
) => { ) => {
@ -74,5 +75,5 @@ index ce7eab36..ebddf26b 100644
+ return; + return;
+ } + }
if (document.link) { if (document.link) {
window.open(document.link, "_blank"); openExternalLink(document.link);
} else if ( } else if (