Skip to content

Commit

Permalink
Improve display of last failure (#31)
Browse files Browse the repository at this point in the history
It will allow to hint user if task failure is recent (using red color to
indicate there might be something to do), a bit old (using yellow to
indicate it might the info they are looking for) or very old (using
green color to show it is likely ok despite being a failure).

Also precise some field naming

Change-Id: I66e827d1a3796de6af658c55a9231c8fdf659126
  • Loading branch information
kamaradclimber authored Apr 8, 2020
1 parent d89e360 commit 4b2f436
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/css/components/timestamp.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.timestamp-color {
&.veryold {
color: @timestamp-color-veryold;
}

&.old {
color: @timestamp-color-old;
}

&.recent {
color: @timestamp-color-recent;
}
}
1 change: 1 addition & 0 deletions src/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
@import "components/popover.less";
@import "components/task-list.less";
@import "components/task-file-list.less";
@import "components/timestamp.less";
@import "components/tooltip.less";
@import "components/toggle.less";
@import "components/volume-list.less";
4 changes: 4 additions & 0 deletions src/css/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
@app-status-delayed-color: @alizarin-crimson;
@app-status-suspended-color: @oslo-gray;

@timestamp-color-veryold: @emerald;
@timestamp-color-old: @mustard;
@timestamp-color-recent: @alizarin-crimson;

// Health is specific to tasks, and distinct from app status
@health-bar-inner-color: @mirage;
@task-health-healthy-color: @emerald;
Expand Down
22 changes: 18 additions & 4 deletions src/js/components/AppDebugInfoComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from "classnames";
import React from "react/addons";
import Moment from "moment";

Expand Down Expand Up @@ -70,23 +71,36 @@ var AppDebugInfoComponent = React.createClass({
const timeStampText = new Date(timestamp) > new Date()
? "Just now"
: new Moment(timestamp).fromNow();
const secondsSinceLastFailure = (new Date() - new Date(timestamp)) / 1000;
// adapt color based on information recency.
// Old timestamps means information is less relevant but many users
// don't see it. So we mark it anyway
var timestampTextColor = "recent";
if (secondsSinceLastFailure > 86400) {
timestampTextColor = "veryold";
} else if (secondsSinceLastFailure > 600) {
timestampTextColor = "old";
}

var timestampClassSet = classNames("timestamp-color", timestampTextColor);
const version = lastTaskFailure.version;

return (
<dl className="dl-horizontal flush-bottom">
<dt>Task id</dt>
{invalidateValue(lastTaskFailure.taskId)}
<dt>State</dt>
<dt>Task State</dt>
{invalidateValue(lastTaskFailure.state)}
<dt>Message</dt>
{invalidateValue(lastTaskFailure.message)}
<dt>Host</dt>
{invalidateValue(lastTaskFailure.host)}
<dt>Timestamp</dt>
<dt>Failure timestamp</dt>
<dd>
<span>{timestamp}</span> ({timeStampText})
<span>{timestamp}</span>&nbsp;
(<span className={timestampClassSet}>{timeStampText}</span>)
</dd>
<dt>Version</dt>
<dt>Configuration Version</dt>
<dd>
<span>{version}</span> ({new Moment(version).fromNow()})
</dd>
Expand Down

0 comments on commit 4b2f436

Please sign in to comment.