Skip to content

Commit

Permalink
PR Correction
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradPietocha committed Jan 10, 2025
1 parent 8c1f72e commit c0fde4a
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/components/Extensibility/components/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ export function Badge({
arrayItems,
});

const getLatestStatusMessage = (resource, defaultValue) => {
const getTime = date => new Date(date)?.getTime();
const latestStatus = resource?.status?.conditions?.reduce((prev, current) =>
prev &&
getTime(prev.lastTransitionTime) > getTime(current.lastTransitionTime)
? prev
: current,
);
return latestStatus?.message ?? defaultValue;
};

const [tooltip, tooltipError] = jsonata(structure?.description);

let type = null;
Expand Down Expand Up @@ -82,17 +71,23 @@ export function Badge({

type = TYPE_FALLBACK.get(type) || type;

const getTooltipContent = description => {
if (tooltip && !tooltipError) {
return tooltip;
}
if (!tooltip && !tooltipError) {
return '';
}
return description;
};

return isNil(value) ? (
emptyLeafPlaceholder
) : structure?.description ? (
<StatusBadge
autoResolveType={!type}
type={type}
tooltipContent={
tooltip && !tooltipError
? tooltip
: getLatestStatusMessage(originalResource, structure.description)
}
tooltipContent={getTooltipContent(structure.description)}
>
{tExt(value)}
</StatusBadge>
Expand Down

0 comments on commit c0fde4a

Please sign in to comment.