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:
parent
8143cc123f
commit
2c42e9fd03
3 changed files with 103 additions and 72 deletions
|
|
@ -298,69 +298,98 @@ await patchFile("components/icons/icons.tsx", [{
|
|||
}]);
|
||||
|
||||
// (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.
|
||||
// Gate on hasAdminAccess (admins + curators) from useUser().
|
||||
// panel and unread badge for everyone except full admins. Gate on `isAdmin`
|
||||
// (= 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", [
|
||||
{
|
||||
desc: "expose hasAdminAccess from useUser (both popovers)",
|
||||
done: "userResolution, hasAdminAccess }",
|
||||
find: "const { user, userResolution } = useUser();",
|
||||
replace: "const { user, userResolution, hasAdminAccess } = useUser();",
|
||||
desc: "expose isAdmin from useUser in useSettingsItems",
|
||||
done: "userResolution, isAdmin } = useUser();\n const settings",
|
||||
find: `const { user, userResolution } = useUser();
|
||||
const settings = useSettings();`,
|
||||
replace: `const { user, userResolution, isAdmin } = useUser();
|
||||
const settings = useSettings();`,
|
||||
},
|
||||
{
|
||||
desc: "hide Notifications menu item for non-admins",
|
||||
done: "// AIDO: the notification centre is admin-facing only",
|
||||
find: ` </div>,
|
||||
<LineItemButton
|
||||
key="notifications"
|
||||
sizePreset="main-ui"
|
||||
variant="section"
|
||||
rounding={2}
|
||||
icon={SvgBell}
|
||||
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={
|
||||
undismissedCount ? (
|
||||
<SvgNotificationBubble count={undismissedCount} />
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
) : null,`,
|
||||
desc: "expose isAdmin from useUser in AccountPopover",
|
||||
done: "setMenuOpen(false);\n const { user, userResolution, isAdmin }",
|
||||
find: `const [menuOpen, setMenuOpen] = useState(false);
|
||||
const { user, userResolution } = useUser();`,
|
||||
replace: `const [menuOpen, setMenuOpen] = useState(false);
|
||||
const { user, userResolution, isAdmin } = useUser();`,
|
||||
},
|
||||
{
|
||||
desc: "hide unread badge on the account button for non-admins",
|
||||
done: "hasAdminAccess && undismissedCount ?",
|
||||
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
|
||||
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}
|
||||
/>
|
||||
),
|
||||
},`,
|
||||
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 the unread badge on the account button for non-admins",
|
||||
done: "isAdmin && undismissedCount ? (",
|
||||
find: ` rightChildren={
|
||||
undismissedCount ? (
|
||||
<Section padding={2}>`,
|
||||
replace: ` rightChildren={
|
||||
hasAdminAccess && undismissedCount ? (
|
||||
isAdmin && undismissedCount ? (
|
||||
<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
|
||||
|
|
@ -369,10 +398,11 @@ await patchFile("sections/sidebar/AccountPopover.tsx", [
|
|||
await patchFile("views/SettingsPage.tsx", [
|
||||
{
|
||||
desc: "limit language selector to de + en",
|
||||
done: `["en", "de"].includes(l)`,
|
||||
find: `{SUPPORTED_LOCALES.map((locale) => (`,
|
||||
replace: `{SUPPORTED_LOCALES.filter((l) => ["en", "de"].includes(l)).map(
|
||||
(locale) => (`,
|
||||
done: `LOCALE_OPTIONS.filter((o) => ["en", "de"].includes(o.value))`,
|
||||
find: ` ...LOCALE_OPTIONS,`,
|
||||
replace: ` ...LOCALE_OPTIONS.filter((o) =>
|
||||
["en", "de"].includes(o.value)
|
||||
),`,
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
@ -537,4 +567,4 @@ if (CONFIG.i18n && CONFIG.i18n.enabled && CONFIG.i18n.rebrandLocales) {
|
|||
step("4/4 Done");
|
||||
log(`${c.green}White-label applied for ${c.bold}${CONFIG.brand.name}${c.reset}${c.green} (${CONFIG.brand.legalName}).${c.reset}`);
|
||||
log(`${c.gray}Next: docker compose build web_server && docker compose up -d${c.reset}`);
|
||||
if (DRY) warn("dry-run: no files were written.");
|
||||
if (DRY) warn("dry-run: no files were written.");
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
"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.",
|
||||
"repo": "https://github.com/onyx-dot-app/onyx",
|
||||
"pinnedCommit": "v4.8.2",
|
||||
"pinnedCommit": "v5.0.3",
|
||||
"webSrcRoot": "web"
|
||||
},
|
||||
"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`."
|
||||
},
|
||||
"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,
|
||||
"patch": "branding/smb/smb-ui.patch"
|
||||
},
|
||||
|
|
@ -93,4 +93,4 @@
|
|||
"sanitize": false,
|
||||
"suppressTypes": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
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
|
||||
+++ b/web/src/ee/sections/SearchCard.tsx
|
||||
@@ -10,6 +10,7 @@ import { ValidSources } from "@/lib/types";
|
||||
import { MinimalOnyxDocument } from "@/lib/search/interfaces";
|
||||
@@ -11,6 +11,7 @@ import { ValidSources } from "@/lib/connectors/types/source";
|
||||
import { MinimalOnyxDocument } from "@/lib/search/types";
|
||||
import { Section } from "@/layouts/general-layouts";
|
||||
import { Interactive } from "@opal/core";
|
||||
+import { toast } from "@opal/layouts";
|
||||
import Truncated from "@/refresh-components/texts/Truncated";
|
||||
import { timeAgo } from "@opal/time";
|
||||
import { useMemo } from "react";
|
||||
import { useLocale } from "next-intl";
|
||||
@@ -39,6 +40,27 @@ export default function SearchCard({
|
||||
document.is_internet || document.source_type === ValidSources.Web;
|
||||
|
||||
|
|
@ -39,17 +39,18 @@ index 71b5255d..9b76cbe5 100644
|
|||
window.open(document.link, "_blank", "noopener,noreferrer");
|
||||
return;
|
||||
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
|
||||
+++ b/web/src/lib/search/utils.ts
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ValidSources } from "@/lib/types";
|
||||
import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/interfaces";
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ValidSources } from "@/lib/connectors/types/source";
|
||||
import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/types";
|
||||
import { transformLinkUri } from "@/lib/utils";
|
||||
+import { toast } from "@opal/layouts";
|
||||
|
||||
// If we have a link, open it in a new tab (including if it's a file)
|
||||
// If above fails and we have a file, update the presenting document
|
||||
@@ -7,6 +8,26 @@ export const openDocument = (
|
||||
export const openExternalLink = (url: string) => {
|
||||
const safeUrl = transformLinkUri(url);
|
||||
@@ -47,6 +48,26 @@ export const openDocument = (
|
||||
document: OnyxDocument,
|
||||
updatePresentingDocument?: (document: MinimalOnyxDocument) => void
|
||||
) => {
|
||||
|
|
@ -74,5 +75,5 @@ index ce7eab36..ebddf26b 100644
|
|||
+ return;
|
||||
+ }
|
||||
if (document.link) {
|
||||
window.open(document.link, "_blank");
|
||||
} else if (
|
||||
openExternalLink(document.link);
|
||||
} else if (
|
||||
Loading…
Add table
Reference in a new issue