forked from jappel/leistungsbilanz-ts
Describe snapshot source revisions
This commit is contained in:
parent
602ae6da0b
commit
dcb303284c
10 changed files with 246 additions and 27 deletions
|
|
@ -25,6 +25,7 @@ import {
|
|||
getProjectRevisionDescription,
|
||||
getProjectRevisionSourceLabel,
|
||||
getProjectSnapshotKindLabel,
|
||||
getProjectSnapshotRevisionDescription,
|
||||
mergeProjectRevisionPages,
|
||||
} from "../utils/project-version-history";
|
||||
|
||||
|
|
@ -343,7 +344,7 @@ export function ProjectVersionHistory({
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Projektstand</th>
|
||||
<th>Gesicherter Projektstand</th>
|
||||
<th>Erstellt</th>
|
||||
<th className="text-end">Aktion</th>
|
||||
</tr>
|
||||
|
|
@ -368,7 +369,16 @@ export function ProjectVersionHistory({
|
|||
</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td>Revision {snapshot.sourceRevision}</td>
|
||||
<td>
|
||||
<strong>
|
||||
{snapshot.sourceRevision === 0
|
||||
? "Ausgangsstand"
|
||||
: `Revision ${snapshot.sourceRevision}`}
|
||||
</strong>
|
||||
<div className="small text-secondary">
|
||||
{getProjectSnapshotRevisionDescription(snapshot)}
|
||||
</div>
|
||||
</td>
|
||||
<td>{formatDateTime(snapshot.createdAtIso)}</td>
|
||||
<td className="text-end">
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export interface ProjectSnapshotMetadataDto {
|
|||
id: string;
|
||||
projectId: string;
|
||||
sourceRevision: number;
|
||||
sourceRevisionMetadata: ProjectRevisionSummaryDto | null;
|
||||
schemaVersion: number;
|
||||
kind: "named" | "automatic";
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -49,8 +49,15 @@ export function getProjectRevisionSourceLabel(
|
|||
export function getProjectRevisionDescription(
|
||||
revision: ProjectRevisionSummaryDto
|
||||
) {
|
||||
const description = revision.description?.trim();
|
||||
if (
|
||||
description === `Undo ${revision.commandType}` ||
|
||||
description === `Redo ${revision.commandType}`
|
||||
) {
|
||||
return commandTypeLabels[revision.commandType] || revision.commandType;
|
||||
}
|
||||
return (
|
||||
revision.description?.trim() ||
|
||||
description ||
|
||||
commandTypeLabels[revision.commandType] ||
|
||||
revision.commandType
|
||||
);
|
||||
|
|
@ -62,6 +69,26 @@ export function getProjectSnapshotKindLabel(
|
|||
return kind === "automatic" ? "Automatisch" : "Benannt";
|
||||
}
|
||||
|
||||
export function getProjectSnapshotRevisionDescription(
|
||||
snapshot: ProjectSnapshotMetadataDto
|
||||
) {
|
||||
if (snapshot.sourceRevision === 0) {
|
||||
return "Projektstart";
|
||||
}
|
||||
if (
|
||||
!snapshot.sourceRevisionMetadata ||
|
||||
snapshot.sourceRevisionMetadata.revisionNumber !==
|
||||
snapshot.sourceRevision
|
||||
) {
|
||||
return "Änderungsdetails nicht verfügbar";
|
||||
}
|
||||
return `${getProjectRevisionSourceLabel(
|
||||
snapshot.sourceRevisionMetadata.source
|
||||
)}: ${getProjectRevisionDescription(
|
||||
snapshot.sourceRevisionMetadata
|
||||
)}`;
|
||||
}
|
||||
|
||||
export function mergeProjectRevisionPages(
|
||||
current: ProjectRevisionSummaryDto[],
|
||||
next: ProjectRevisionSummaryDto[]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue