SMB UI overlay: copy full network path, not just the file name
Regression from the filename-label change: the clipboard copied the label (semantic_identifier = file name) because the chat citation object does not always carry `link`. Read the full path from metadata.logical_path first (always present on SMB documents), then fall back to link, then the file name. Applies to both the chat citation and the licensed Search view.
This commit is contained in:
parent
8cc8fb3bec
commit
9a886ac835
1 changed files with 11 additions and 8 deletions
|
|
@ -18,7 +18,7 @@ index 0f61ede9..2dcb8e7e 100644
|
||||||
: ccPairsIndexingStatus.last_status == "not_started"
|
: ccPairsIndexingStatus.last_status == "not_started"
|
||||||
? ConnectorCredentialPairStatus.SCHEDULED
|
? ConnectorCredentialPairStatus.SCHEDULED
|
||||||
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 42fb3bd8..a4b8926f 100644
|
index 42fb3bd8..5ee25228 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";
|
@@ -10,6 +10,7 @@ import { ValidSources } from "@/lib/types";
|
||||||
|
|
@ -29,7 +29,7 @@ index 42fb3bd8..a4b8926f 100644
|
||||||
import Truncated from "@/refresh-components/texts/Truncated";
|
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";
|
||||||
@@ -37,6 +38,25 @@ export default function SearchCard({
|
@@ -37,6 +38,27 @@ export default function SearchCard({
|
||||||
document.is_internet || document.source_type === ValidSources.Web;
|
document.is_internet || document.source_type === ValidSources.Web;
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
|
|
@ -38,9 +38,11 @@ index 42fb3bd8..a4b8926f 100644
|
||||||
+ // fail. Copy the logical path to the clipboard so the user can open the file
|
+ // 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.
|
+ // directly on the share. Mirrors openDocument() used by the chat view.
|
||||||
+ if (document.source_type === ValidSources.IngestionApi) {
|
+ if (document.source_type === ValidSources.IngestionApi) {
|
||||||
+ // The full network path is in `link` (file://\\server\share\...); the
|
+ // The full network path is in metadata.logical_path (the search result does
|
||||||
+ // semantic_identifier is now just the file name, shown as the label.
|
+ // not always carry `link`); semantic_identifier is only the file name.
|
||||||
|
+ const logicalPath = document.metadata?.logical_path;
|
||||||
+ const path =
|
+ const path =
|
||||||
|
+ (typeof logicalPath === "string" ? logicalPath : undefined) ||
|
||||||
+ document.link?.replace(/^file:\/\//, "") ||
|
+ document.link?.replace(/^file:\/\//, "") ||
|
||||||
+ document.semantic_identifier ||
|
+ document.semantic_identifier ||
|
||||||
+ document.document_id;
|
+ document.document_id;
|
||||||
|
|
@ -56,7 +58,7 @@ index 42fb3bd8..a4b8926f 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..2431a944 100644
|
index ce7eab36..6e4baff3 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,5 +1,6 @@
|
||||||
|
|
@ -66,7 +68,7 @@ index ce7eab36..2431a944 100644
|
||||||
|
|
||||||
// If we have a link, open it in a new tab (including if it's a file)
|
// 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
|
// If above fails and we have a file, update the presenting document
|
||||||
@@ -7,6 +8,25 @@ export const openDocument = (
|
@@ -7,6 +8,26 @@ export const openDocument = (
|
||||||
document: OnyxDocument,
|
document: OnyxDocument,
|
||||||
updatePresentingDocument?: (document: MinimalOnyxDocument) => void
|
updatePresentingDocument?: (document: MinimalOnyxDocument) => void
|
||||||
) => {
|
) => {
|
||||||
|
|
@ -75,9 +77,10 @@ index ce7eab36..2431a944 100644
|
||||||
+ // just fail. Instead, surface the logical path by copying it to the clipboard
|
+ // just fail. Instead, surface the logical path by copying it to the clipboard
|
||||||
+ // so the user can open the file directly on the share.
|
+ // so the user can open the file directly on the share.
|
||||||
+ if (document.source_type === ValidSources.IngestionApi) {
|
+ if (document.source_type === ValidSources.IngestionApi) {
|
||||||
+ // The full network path is in `link` (file://\\server\share\...); the
|
+ // The full network path is in metadata.logical_path (the citation object
|
||||||
+ // semantic_identifier is now just the file name, shown as the label.
|
+ // does not always carry `link`); semantic_identifier is only the file name.
|
||||||
+ const path =
|
+ const path =
|
||||||
|
+ document.metadata?.logical_path ||
|
||||||
+ document.link?.replace(/^file:\/\//, "") ||
|
+ document.link?.replace(/^file:\/\//, "") ||
|
||||||
+ document.semantic_identifier ||
|
+ document.semantic_identifier ||
|
||||||
+ document.document_id;
|
+ document.document_id;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue