This commit is contained in:
2025-11-02 01:18:24 +01:00
parent 32d627fd6d
commit 7d8595b63f
6 changed files with 65 additions and 118 deletions
@@ -244,10 +244,7 @@ const DocumentSummarySection = ({
onCorrespondentAdd,
onCorrespondentRemove,
onUpdateTitle,
onUpdateIssued,
resolveFolderPath,
onFolderNavigate,
showFolderPath = true,
onUpdateIssued
}) => {
const summary = useMemo(() => {
if (!document) {
@@ -283,74 +280,6 @@ const DocumentSummarySection = ({
return sortCorrespondents(document?.correspondents || []);
}, [correspondents, document?.correspondents]);
const folderPath = useMemo(() => {
if (
!showFolderPath
|| !document?.folder_id
|| typeof resolveFolderPath !== 'function'
) {
return null;
}
const segments = resolveFolderPath(document.folder_id);
const filtered = Array.isArray(segments)
? segments.filter((segment) => segment?.id && segment.id !== 'root')
: null;
if (!filtered || !filtered.length) {
return null;
}
return filtered;
}, [document?.folder_id, resolveFolderPath, showFolderPath]);
const folderDisplayNode = useMemo(() => {
if (!folderPath || !folderPath.length) {
return null;
}
return (
<span className="detail-folder-path">
{folderPath.map((segment, index) => {
const label = segment?.name || '…';
const targetId = segment?.id || null;
const key = `${targetId || label}-${index}`;
const isClickable = Boolean(targetId) && typeof onFolderNavigate === 'function';
const href = !isClickable
? null
: targetId === 'root'
? '/documents'
: `/documents/folder/${targetId}`;
return (
<React.Fragment key={key}>
{index > 0 ? <span className="detail-folder-path__separator">/</span> : null}
{isClickable ? (
<a
href={href}
className="detail-folder-path__link"
onClick={(event) => {
if (
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
) {
return;
}
event.preventDefault();
event.stopPropagation();
onFolderNavigate(targetId);
}}
>
{label}
</a>
) : (
<span className="detail-folder-path__segment">{label}</span>
)}
</React.Fragment>
);
})}
</span>
);
}, [folderPath, onFolderNavigate]);
const metaRows = useMemo(() => {
const rows = [];
const currentVersionNumber = document?.current_version?.version_number;
@@ -526,11 +455,6 @@ const DocumentSummarySection = ({
</>
)}
</div>
{showFolderPath && folderDisplayNode ? (
<div className="doc-title-row__path" aria-label="Folder path">
{folderDisplayNode}
</div>
) : null}
</div>
{titleError ? <div className="status-inline error">{titleError}</div> : null}