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
+1 -1
View File
@@ -97,7 +97,7 @@ legacy/ # Original HTML tools for reference
## Implemented Modules (14/14 — zero placeholders) ## Implemented Modules (14/14 — zero placeholders)
| # | Module | Route | Version | Key Features | | # | Module | Route | Version | Key Features |
| --- | ---------------------- | --------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --- | ---------------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1 | **Dashboard** | `/` | 0.1.0 | KPI cards (6), activity feed (last 20), module grid, external tools | | 1 | **Dashboard** | `/` | 0.1.0 | KPI cards (6), activity feed (last 20), module grid, external tools |
| 2 | **Email Signature** | `/email-signature` | 0.1.0 | Multi-company branding, address toggle (BTG/US/SDT), live preview, zoom/copy/download | | 2 | **Email Signature** | `/email-signature` | 0.1.0 | Multi-company branding, address toggle (BTG/US/SDT), live preview, zoom/copy/download |
| 3 | **Word XML Generator** | `/word-xml` | 0.1.0 | Category-based XML gen, simple/advanced mode, ZIP export | | 3 | **Word XML Generator** | `/word-xml` | 0.1.0 | Category-based XML gen, simple/advanced mode, ZIP export |
@@ -34,14 +34,9 @@ import {
import type { RegistryEntry } from "../types"; import type { RegistryEntry } from "../types";
import { DEFAULT_DOC_TYPE_LABELS } from "../types"; import { DEFAULT_DOC_TYPE_LABELS } from "../types";
import { getOverdueDays } from "../services/registry-service"; import { getOverdueDays } from "../services/registry-service";
import { import { shortDisplayPath, shareLabelFor } from "@/config/nas-paths";
toFileUrl,
toFileUrlByIp,
shortDisplayPath,
shareLabelFor,
} from "@/config/nas-paths";
import { cn } from "@/shared/lib/utils"; import { cn } from "@/shared/lib/utils";
import { useState } from "react"; import { useState, useCallback } from "react";
interface RegistryEntryDetailProps { interface RegistryEntryDetailProps {
entry: RegistryEntry | null; entry: RegistryEntry | null;
@@ -139,6 +134,13 @@ export function RegistryEntryDetail({
const [previewAttachment, setPreviewAttachment] = useState<string | null>( const [previewAttachment, setPreviewAttachment] = useState<string | null>(
null, null,
); );
const [copiedPath, setCopiedPath] = useState<string | null>(null);
const copyPath = useCallback(async (path: string) => {
await navigator.clipboard.writeText(path);
setCopiedPath(path);
setTimeout(() => setCopiedPath(null), 2000);
}, []);
if (!entry) return null; if (!entry) return null;
@@ -396,64 +398,35 @@ export function RegistryEntryDetail({
att.networkPath ? ( att.networkPath ? (
<div <div
key={att.id} key={att.id}
className="flex items-center gap-2 rounded-md border border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/20 px-3 py-2 group" className="rounded-md border border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/20 px-3 py-2 group cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/30 transition-colors"
onClick={() => copyPath(att.networkPath!)}
title="Click pentru a copia calea — lipește în Explorer"
> >
<div className="flex items-center gap-2">
<HardDrive className="h-4 w-4 text-blue-600 dark:text-blue-400 shrink-0" /> <HardDrive className="h-4 w-4 text-blue-600 dark:text-blue-400 shrink-0" />
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<a <span className="text-sm text-blue-700 dark:text-blue-300 font-mono">
href={toFileUrl(att.networkPath)}
className="text-sm text-blue-700 dark:text-blue-300 hover:underline font-mono"
title={att.networkPath}
onClick={(e) => {
e.preventDefault();
window.open(
toFileUrl(att.networkPath!),
"_blank",
);
}}
>
<FolderOpen className="mr-1 inline h-3 w-3" /> <FolderOpen className="mr-1 inline h-3 w-3" />
{shortDisplayPath(att.networkPath)} {shortDisplayPath(att.networkPath)}
</a> </span>
<p className="text-[10px] text-muted-foreground mt-0.5">
{att.networkPath}
</p>
</div> </div>
<div className="flex items-center gap-1 shrink-0">
<Badge <Badge
variant="outline" variant="outline"
className="text-[10px] border-blue-300 dark:border-blue-700 text-blue-600 dark:text-blue-400" className="text-[10px] border-blue-300 dark:border-blue-700 text-blue-600 dark:text-blue-400 shrink-0"
> >
{shareLabelFor(att.networkPath) ?? "NAS"} {shareLabelFor(att.networkPath) ?? "NAS"}
</Badge> </Badge>
<Button {copiedPath === att.networkPath ? (
type="button" <Badge className="text-[10px] bg-green-600 text-white shrink-0 animate-in fade-in">
variant="ghost" Copiat!
size="icon" </Badge>
className="h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity" ) : (
onClick={() => <Copy className="h-3.5 w-3.5 text-blue-400 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity" />
navigator.clipboard.writeText(att.networkPath!) )}
}
title="Copiază calea"
>
<Copy className="h-3 w-3" />
</Button>
<Button
type="button"
variant="ghost"
size="icon"
className="h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"
onClick={() =>
window.open(
toFileUrlByIp(att.networkPath!),
"_blank",
)
}
title="Deschide prin IP (fallback)"
>
<ExternalLink className="h-3 w-3" />
</Button>
</div> </div>
<p className="text-[10px] text-muted-foreground mt-1 pl-6 font-mono truncate">
{att.networkPath}
</p>
</div> </div>
) : ( ) : (
<div <div
@@ -33,8 +33,6 @@ import { DEFAULT_DOC_TYPE_LABELS } from "../types";
import { import {
isNetworkPath, isNetworkPath,
toUncPath, toUncPath,
toFileUrl,
toFileUrlByIp,
pathFileName, pathFileName,
shortDisplayPath, shortDisplayPath,
shareLabelFor, 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" 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" /> <HardDrive className="h-3.5 w-3.5 text-blue-600 dark:text-blue-400 shrink-0" />
<a <button
href={toFileUrl(att.networkPath)} type="button"
className="flex-1 min-w-0 flex items-center gap-1 text-blue-700 dark:text-blue-300 hover:underline cursor-pointer" 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={`Deschide în Explorer: ${att.networkPath}`} title="Click copiază calea — lipește în Explorer"
onClick={(e) => { onClick={() => {
e.preventDefault(); navigator.clipboard.writeText(att.networkPath!);
window.open(toFileUrl(att.networkPath!), "_blank");
}} }}
> >
<FolderOpen className="h-3 w-3 shrink-0" /> <FolderOpen className="h-3 w-3 shrink-0" />
<span className="truncate font-mono text-xs"> <span className="truncate font-mono text-xs">
{shortDisplayPath(att.networkPath)} {shortDisplayPath(att.networkPath)}
</span> </span>
</a> </button>
{/* 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>
<Badge <Badge
variant="outline" variant="outline"
className="text-[10px] border-blue-300 dark:border-blue-700 text-blue-600 dark:text-blue-400 shrink-0" className="text-[10px] border-blue-300 dark:border-blue-700 text-blue-600 dark:text-blue-400 shrink-0"
> >
{shareLabelFor(att.networkPath) ?? "NAS"} {shareLabelFor(att.networkPath) ?? "NAS"}
</Badge> </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 <button
type="button" type="button"
onClick={() => removeAttachment(att.id)} onClick={() => removeAttachment(att.id)}