Skip to content

Commit

Permalink
clearer preflight status' on version history rows (#2055)
Browse files Browse the repository at this point in the history
* clearer preflight status' on version history rows

* clean up duplicated code
  • Loading branch information
GraysonNull committed Aug 6, 2021
1 parent 7ff3c7f commit 5f09a83
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions web/src/components/apps/AppVersionHistoryRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,23 @@ function renderVersionStatus(version, app, match, viewLogs) {
}

let preflightsFailed = false;
if (version.status === "pending" && version.preflightResult) {
let preflightState = "";
if (version.preflightResult) {
const preflightResult = JSON.parse(version.preflightResult);
const preflightState = getPreflightResultState(preflightResult);
preflightsFailed = preflightState === "fail";
preflightState = getPreflightResultState(preflightResult);
if (version.status === "pending") {
preflightsFailed = preflightState === "fail";
}
}

const checksPassedToolTip = "This version was deployed before preflight checks had finished. Checks continue to run in the background until completed.";
let checkBypassedResultText = "";
if (preflightState === "pass") {
checkBypassedResultText = "Checks bypassed & passed";
} else if (preflightState === "warn") {
checkBypassedResultText = "Checks bypassed & passed with warnings";
} else if (preflightState === "fail") {
checkBypassedResultText = "Checks bypassed";
}

const isPastVersion = find(downstream.pastVersions, { sequence: version.sequence });
Expand All @@ -133,8 +146,6 @@ function renderVersionStatus(version, app, match, viewLogs) {

if (isPastVersion && app.hasPreflight) {
if (preflightsFailed) {
preflightBlock = (<Link to={`/app/${match.params.slug}/downstreams/${clusterSlug}/version-history/preflight/${version.sequence}`} className="replicated-link u-marginLeft--5 u-fontSize--small">See details</Link>);
} else if (version.status !== "pending_config") {
preflightBlock = (<Link to={`/app/${match.params.slug}/downstreams/${clusterSlug}/version-history/preflight/${version.sequence}`} className="replicated-link u-marginLeft--5 u-fontSize--small">View preflights</Link>);
}
}
Expand All @@ -145,8 +156,6 @@ function renderVersionStatus(version, app, match, viewLogs) {
</span>);
} else if (app.hasPreflight) {
if (preflightsFailed) {
preflightBlock = (<Link to={`/app/${match.params.slug}/downstreams/${clusterSlug}/version-history/preflight/${version.sequence}`} className="replicated-link u-marginLeft--5 u-fontSize--small">See details</Link>);
} else if (version.status !== "pending_config") {
preflightBlock = (<Link to={`/app/${match.params.slug}/downstreams/${clusterSlug}/version-history/preflight/${version.sequence}`} className="replicated-link u-marginLeft--5 u-fontSize--small">View preflights</Link>);
}
}
Expand Down Expand Up @@ -182,7 +191,9 @@ function renderVersionStatus(version, app, match, viewLogs) {
: version.status
).replace("_", " ")}
</span>
{version.preflightSkipped && <span className="u-textColor--warning u-fontSize--small u-fontWeight--medium u-lineHeight--normal u-marginLeft--5">Checks skipped</span>}
{version.preflightSkipped && <span className="u-textColor--warning u-fontSize--small u-fontWeight--medium u-lineHeight--normal u-marginLeft--5 alignItems--center justifyContent--center">{checkBypassedResultText} <span className="icon u-top--3 grayOutlineQuestionMark--icon" data-tip={checksPassedToolTip} />
<ReactTooltip effect="solid" className="replicated-tooltip" />
</span>}
</div>
{preflightBlock}
{version.status === "failed" &&
Expand Down Expand Up @@ -217,7 +228,9 @@ function renderVersionStatus(version, app, match, viewLogs) {
version.status === "failed" ?
"Failed" : ""}
</span>
{version.preflightSkipped && <span className="u-textColor--warning u-fontSize--small u-fontWeight--medium u-lineHeight--normal u-marginLeft--5">Checks skipped</span>}
{version.preflightSkipped && <span className="u-textColor--warning u-fontSize--small u-fontWeight--medium u-lineHeight--normal u-marginLeft--5 alignItems--center justifyContent--center">{checkBypassedResultText} <span className="icon u-top--3 grayOutlineQuestionMark--icon" data-tip={checksPassedToolTip}/>
<ReactTooltip effect="solid" className="replicated-tooltip" />
</span>}
</div>
{preflightBlock}
{version.status === "failed" &&
Expand Down

0 comments on commit 5f09a83

Please sign in to comment.