Skip to content

Commit 643391d

Browse files
committed
feat: add "ago" to tray runs menu
This should help in understanding the age of each run. This PR also updates the "Run Summary" menu item to instead say "Open Grid View", and with a grid menu item icon.
1 parent 810ec7b commit 643391d

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed
454 Bytes
Loading
176 Bytes
Loading

plugins/plugin-codeflare/src/tray/icons.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import profile from "@kui-shell/client/icons/png/profileTemplate.png"
2020
import bug from "@kui-shell/client/icons/png/bugTemplate.png"
2121
import powerOff from "@kui-shell/client/icons/png/powerOffTemplate.png"
2222
import play from "@kui-shell/client/icons/png/playTemplate.png"
23+
import grid from "@kui-shell/client/icons/png/gridTemplate.png"
2324

2425
import { join } from "path"
2526

@@ -35,3 +36,4 @@ export const bugIcon = iconFor(bug)
3536
export const powerOffIcon = iconFor(powerOff)
3637
export const bootIcon = iconFor(play)
3738
export const shutDownIcon = iconFor(powerOff)
39+
export const gridIcon = iconFor(grid)

plugins/plugin-codeflare/src/tray/menus/profiles/dashboards/codeflare.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { CreateWindowFunction } from "@kui-shell/core"
2121

2222
import runs from "../runs"
2323
import section from "../../section"
24+
import { gridIcon } from "../../../icons"
2425
import windowOptions from "../../../window"
2526
import UpdateFunction from "../../../update"
2627

@@ -42,7 +43,8 @@ export default async function codeflareDashboards(
4243
): Promise<MenuItemConstructorOptions[]> {
4344
return [
4445
{
45-
label: "Run Summary",
46+
icon: gridIcon,
47+
label: "Open Grid View",
4648
click: () =>
4749
createWindow(["codeflare", "get", "run", "--profile", profile], {
4850
title: "Codeflare Run Summary - " + profile,

plugins/plugin-codeflare/src/tray/menus/profiles/runs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import prettyMillis from "pretty-ms"
1718
import { MenuItemConstructorOptions } from "electron"
1819

1920
import UpdateFunction from "../../update"
@@ -22,6 +23,10 @@ import ProfileRunWatcher, { RUNS_ERROR } from "../../watchers/profile/run"
2223
/** Handler for "opening" the selected `runId` in the given `profile` */
2324
type RunOpener = (profile: string, runId: string) => void
2425

26+
function ago(timestamp: number) {
27+
return prettyMillis(Date.now() - timestamp, { compact: true }) + " ago"
28+
}
29+
2530
/**
2631
*
2732
* @return a menu for all runs of a profile
@@ -34,7 +39,10 @@ export function runMenuItems(
3439
return runs
3540
.slice(0, 10)
3641
.sort((a, b) => b.timestamp - a.timestamp)
37-
.map((run) => ({ label: run.runId, click: () => open(profile, run.runId) }))
42+
.map((run) => ({
43+
label: `${ago(run.timestamp).padEnd(8)} \u2014 ${run.runId.slice(0, run.runId.indexOf("-"))}`,
44+
click: () => open(profile, run.runId),
45+
}))
3846
}
3947

4048
/** Memo of `ProfileStatusWatcher`, keyed by profile name */

0 commit comments

Comments
 (0)