@@ -21,7 +21,7 @@ import { CreateWindowFunction } from "@kui-shell/core"
2121import UpdateFunction from "../update"
2222import windowOptions from "../window"
2323import { profileIcon , bootIcon , shutDownIcon } from "../icons"
24- import { RUNS_ERROR , submenuForRuns , readRunsDir } from "./runs"
24+ import submenuForRuns from "./runs"
2525
2626import ProfileStatusWatcher from "../watchers/profile/status"
2727
@@ -44,31 +44,27 @@ async function shutdown(profile: string, createWindow: CreateWindowFunction) {
4444const watchers : Record < string , ProfileStatusWatcher > = { }
4545
4646/** @return a menu for the given profile */
47- function submenuForOneProfile (
47+ async function submenuForOneProfile (
4848 state : Choices . ChoiceState ,
4949 createWindow : CreateWindowFunction ,
50- runs : string [ ] ,
5150 updateFunction : UpdateFunction
52- ) : MenuItemConstructorOptions {
53- const isRunsSubMenu =
54- runs . length && runs [ 0 ] !== RUNS_ERROR
55- ? { label : "Runs" , submenu : submenuForRuns ( createWindow , runs ) }
56- : { label : RUNS_ERROR }
51+ ) : Promise < MenuItemConstructorOptions > {
5752 if ( ! watchers [ state . profile . name ] ) {
5853 watchers [ state . profile . name ] = new ProfileStatusWatcher ( state . profile . name , updateFunction )
5954 }
6055 const watcher = watchers [ state . profile . name ]
6156
6257 return {
6358 label : state . profile . name ,
59+ icon : profileIcon ,
6460 submenu : [
6561 watcher . head ,
6662 watcher . workers ,
6763 { type : "separator" } ,
6864 { label : "Boot" , icon : bootIcon , click : ( ) => boot ( state . profile . name , createWindow ) } ,
6965 { label : "Shutdown" , icon : shutDownIcon , click : ( ) => shutdown ( state . profile . name , createWindow ) } ,
7066 { type : "separator" } ,
71- isRunsSubMenu ,
67+ ... ( await submenuForRuns ( createWindow ) ) ,
7268 ] ,
7369 }
7470}
@@ -77,13 +73,14 @@ function submenuForOneProfile(
7773export default async function profilesMenu (
7874 createWindow : CreateWindowFunction ,
7975 updateFn : UpdateFunction
80- ) : Promise < MenuItemConstructorOptions > {
76+ ) : Promise < MenuItemConstructorOptions [ ] > {
8177 const profiles = await Profiles . list ( { } )
82- const runs = await readRunsDir ( )
8378
84- return {
85- label : "Profiles" ,
86- icon : profileIcon ,
87- submenu : profiles . map ( ( _ ) => submenuForOneProfile ( _ , createWindow , runs , updateFn ) ) ,
88- }
79+ return [
80+ {
81+ label : "Profiles" ,
82+ enabled : false ,
83+ } ,
84+ ...( await Promise . all ( profiles . map ( ( _ ) => submenuForOneProfile ( _ , createWindow , updateFn ) ) ) ) ,
85+ ]
8986}
0 commit comments