All files / src/pages/flowsheet-page/flowsheet/revisions versionLabels.ts

100% Statements 5/5
83.33% Branches 5/6
100% Functions 0/0
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23            59x 59x 59x                 52x 52x        
import type { FlowsheetRevisionRead } from "@/api/apiStore.gen";
 
/** Present backend revision metadata using the product term "Version". */
export function getFlowsheetVersionLabel(
  revision: FlowsheetRevisionRead,
): string {
  const backendLabel = revision.display_label?.trim();
  const backendDefault = `Revision ${revision.revision_number}`;
  return backendLabel && backendLabel !== backendDefault
    ? backendLabel
    : `Version ${revision.revision_number}`;
}
 
/** Return whether the backend supplied its generated rather than custom name. */
export function hasDefaultFlowsheetVersionLabel(
  revision: FlowsheetRevisionRead,
): boolean {
  const backendLabel = revision.display_label?.trim();
  return (
    !backendLabel || backendLabel === `Revision ${revision.revision_number}`
  );
}