@@ -20,6 +20,7 @@ import { CreateWindowFunction } from "@kui-shell/core"
2020
2121import windowOptions from "../window"
2222import { profileIcon , bootIcon , shutDownIcon } from "../icons"
23+ import { RUNS_ERROR , submenuForRuns , readRunsDir } from "./runs"
2324
2425/** Handler for booting up a profile */
2526async function boot ( profile : string , createWindow : CreateWindowFunction ) {
@@ -40,20 +41,32 @@ async function shutdown(profile: string, createWindow: CreateWindowFunction) {
4041/** @return a menu for the given profile */
4142function submenuForOneProfile (
4243 state : Choices . ChoiceState ,
43- createWindow : CreateWindowFunction
44+ createWindow : CreateWindowFunction ,
45+ runs : string [ ]
4446) : MenuItemConstructorOptions {
47+ const isRunsSubMenu =
48+ runs . length && runs [ 0 ] !== RUNS_ERROR
49+ ? { label : "Runs" , submenu : submenuForRuns ( createWindow , runs ) }
50+ : { label : RUNS_ERROR }
4551 return {
4652 label : state . profile . name ,
4753 submenu : [
4854 { label : "Boot" , icon : bootIcon , click : ( ) => boot ( state . profile . name , createWindow ) } ,
4955 { label : "Shutdown" , icon : shutDownIcon , click : ( ) => shutdown ( state . profile . name , createWindow ) } ,
56+ { type : "separator" } ,
57+ isRunsSubMenu ,
5058 ] ,
5159 }
5260}
5361
5462/** @return a menu for all profiles */
5563export default async function profilesMenu ( createWindow : CreateWindowFunction ) : Promise < MenuItemConstructorOptions > {
5664 const profiles = await Profiles . list ( { } )
65+ const runs = await readRunsDir ( )
5766
58- return { label : "Profiles" , icon : profileIcon , submenu : profiles . map ( ( _ ) => submenuForOneProfile ( _ , createWindow ) ) }
67+ return {
68+ label : "Profiles" ,
69+ icon : profileIcon ,
70+ submenu : profiles . map ( ( _ ) => submenuForOneProfile ( _ , createWindow , runs ) ) ,
71+ }
5972}
0 commit comments