fix(registratura): NAS links copy to clipboard instead of broken file:///

Browsers block file:/// URLs from web pages for security. Changed:
- Detail sheet: click on NAS attachment copies path to clipboard with
  'Copiat!' green badge feedback. Full UNC path shown below.
- Entry form: NAS link click = copy path (removed window.open fallback)
- Removed unused toFileUrl/toFileUrlByIp imports from form
- User pastes in Explorer address bar to open the file
This commit is contained in:
AI Assistant
2026-02-28 17:55:27 +02:00
parent 4dae06be44
commit 05efd525e3
3 changed files with 53 additions and 105 deletions
@@ -33,8 +33,6 @@ import { DEFAULT_DOC_TYPE_LABELS } from "../types";
import {
isNetworkPath,
toUncPath,
toFileUrl,
toFileUrlByIp,
pathFileName,
shortDisplayPath,
shareLabelFor,
@@ -1273,48 +1271,25 @@ export function RegistryEntryForm({
className="flex items-center gap-2 rounded border border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/20 px-2 py-1.5 text-sm group"
>
<HardDrive className="h-3.5 w-3.5 text-blue-600 dark:text-blue-400 shrink-0" />
<a
href={toFileUrl(att.networkPath)}
className="flex-1 min-w-0 flex items-center gap-1 text-blue-700 dark:text-blue-300 hover:underline cursor-pointer"
title={`Deschide în Explorer: ${att.networkPath}`}
onClick={(e) => {
e.preventDefault();
window.open(toFileUrl(att.networkPath!), "_blank");
<button
type="button"
className="flex-1 min-w-0 flex items-center gap-1 text-blue-700 dark:text-blue-300 hover:underline cursor-pointer text-left"
title="Click copiază calea — lipește în Explorer"
onClick={() => {
navigator.clipboard.writeText(att.networkPath!);
}}
>
<FolderOpen className="h-3 w-3 shrink-0" />
<span className="truncate font-mono text-xs">
{shortDisplayPath(att.networkPath)}
</span>
</a>
{/* IP fallback link — visible on hover when DNS fails */}
<a
href={toFileUrlByIp(att.networkPath)}
className="opacity-0 group-hover:opacity-100 transition-opacity text-[10px] text-blue-400 hover:text-blue-600 dark:hover:text-blue-200 shrink-0"
title={`Fallback IP: ${toFileUrlByIp(att.networkPath!)}`}
onClick={(e) => {
e.preventDefault();
window.open(toFileUrlByIp(att.networkPath!), "_blank");
}}
>
IP
</a>
</button>
<Badge
variant="outline"
className="text-[10px] border-blue-300 dark:border-blue-700 text-blue-600 dark:text-blue-400 shrink-0"
>
{shareLabelFor(att.networkPath) ?? "NAS"}
</Badge>
<button
type="button"
className="text-blue-400 hover:text-destructive opacity-0 group-hover:opacity-100 transition-opacity"
onClick={() => {
navigator.clipboard.writeText(att.networkPath!);
}}
title="Copiază calea"
>
<Link2 className="h-3 w-3" />
</button>
<button
type="button"
onClick={() => removeAttachment(att.id)}