aido-onyx/branding/smb/smb-ui.patch
livdebus 2c42e9fd03 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.
2026-11-09 21:39:49 +01:00

79 lines
No EOL
3.3 KiB
Diff

diff --git a/web/src/ee/sections/SearchCard.tsx b/web/src/ee/sections/SearchCard.tsx
index f4cc98b..63dce83 100644
--- a/web/src/ee/sections/SearchCard.tsx
+++ b/web/src/ee/sections/SearchCard.tsx
@@ -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 { 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;
function handleClick() {
+ // AIDO: documents synced from SMB/network shares have no browsable link and
+ // no stored file to preview — the preview pane would just fail. Copy the
+ // logical path to the clipboard so the user can open the file directly on the
+ // share. Mirrors openDocument() used by the chat view.
+ if (document.metadata?.smb_source) {
+ // The full network path is in metadata.logical_path (the search result does
+ // not always carry `link`); semantic_identifier is only the file name.
+ const logicalPath = document.metadata?.logical_path;
+ const path =
+ (typeof logicalPath === "string" ? logicalPath : undefined) ||
+ document.link?.replace(/^file:\/\//, "") ||
+ document.semantic_identifier ||
+ document.document_id;
+ if (path) {
+ void navigator.clipboard
+ ?.writeText(path)
+ .then(() => toast.success(path))
+ .catch(() => undefined);
+ }
+ return;
+ }
if (document.link) {
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 38dc56f..95de8ea 100644
--- a/web/src/lib/search/utils.ts
+++ b/web/src/lib/search/utils.ts
@@ -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";
export const openExternalLink = (url: string) => {
const safeUrl = transformLinkUri(url);
@@ -47,6 +48,26 @@ export const openDocument = (
document: OnyxDocument,
updatePresentingDocument?: (document: MinimalOnyxDocument) => void
) => {
+ // AIDO: documents synced from SMB/network shares have no browsable link and no
+ // stored file to preview — a normal preview click would just fail. Instead,
+ // surface the logical path by copying it to the clipboard so the user can open
+ // the file directly on the share.
+ if (document.metadata?.smb_source) {
+ // The full network path is in metadata.logical_path (the citation object
+ // does not always carry `link`); semantic_identifier is only the file name.
+ const path =
+ document.metadata?.logical_path ||
+ document.link?.replace(/^file:\/\//, "") ||
+ document.semantic_identifier ||
+ document.document_id;
+ if (path) {
+ void navigator.clipboard
+ ?.writeText(path)
+ .then(() => toast.success(path))
+ .catch(() => undefined);
+ }
+ return;
+ }
if (document.link) {
openExternalLink(document.link);
} else if (