Skip to content

Commit 5dd1d2e

Browse files
committed
feat: some minor cleanups to the tray profiles menu layout and source code
- place boot and shutdown at the top - add a Status "header" to the Head x/y Worker x/y section
1 parent 4021c7f commit 5dd1d2e

File tree

4 files changed

+77
-26
lines changed

4 files changed

+77
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { CreateWindowFunction } from "@kui-shell/core"
18+
19+
import { bootIcon } from "../../icons"
20+
import windowOptions from "../../window"
21+
22+
/** Handler for booting up a profile */
23+
async function boot(profile: string, createWindow: CreateWindowFunction) {
24+
createWindow(
25+
["codeflare", "gui", "guide", "ml/ray/start/kubernetes", "--profile", profile],
26+
windowOptions({ title: "Booting " + profile })
27+
)
28+
}
29+
30+
export default function bootMenuItem(profile: string, createWindow: CreateWindowFunction) {
31+
return { label: "Boot", icon: bootIcon, click: () => boot(profile, createWindow) }
32+
}

plugins/plugin-codeflare/src/tray/menus/profiles.ts renamed to plugins/plugin-codeflare/src/tray/menus/profiles/index.ts

+9-22
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,14 @@ import { Choices, Profiles } from "madwizard"
1818
import { MenuItemConstructorOptions } from "electron"
1919
import { CreateWindowFunction } from "@kui-shell/core"
2020

21-
import UpdateFunction from "../update"
22-
import windowOptions from "../window"
23-
import { profileIcon, bootIcon, shutDownIcon } from "../icons"
21+
import boot from "./boot"
22+
import shutdown from "./shutdown"
2423
import submenuForRuns from "./runs"
2524

26-
import ProfileStatusWatcher from "../watchers/profile/status"
25+
import UpdateFunction from "../../update"
26+
import { profileIcon } from "../../icons"
2727

28-
/** Handler for booting up a profile */
29-
async function boot(profile: string, createWindow: CreateWindowFunction) {
30-
createWindow(
31-
["codeflare", "gui", "guide", "ml/ray/start/kubernetes", "--profile", profile],
32-
windowOptions({ title: "Booting " + profile })
33-
)
34-
}
35-
36-
/** Handler for shutting down a profile */
37-
async function shutdown(profile: string, createWindow: CreateWindowFunction) {
38-
createWindow(
39-
["codeflare", "gui", "guide", "ml/ray/stop/kubernetes", "--profile", profile],
40-
windowOptions({ title: "Shutting down " + profile })
41-
)
42-
}
28+
import ProfileStatusWatcher from "../../watchers/profile/status"
4329

4430
const watchers: Record<string, ProfileStatusWatcher> = {}
4531

@@ -58,12 +44,13 @@ async function submenuForOneProfile(
5844
label: state.profile.name,
5945
icon: profileIcon,
6046
submenu: [
47+
boot(state.profile.name, createWindow),
48+
shutdown(state.profile.name, createWindow),
49+
{ type: "separator" },
50+
{ label: "Status", enabled: false },
6151
watcher.head,
6252
watcher.workers,
6353
{ type: "separator" },
64-
{ label: "Boot", icon: bootIcon, click: () => boot(state.profile.name, createWindow) },
65-
{ label: "Shutdown", icon: shutDownIcon, click: () => shutdown(state.profile.name, createWindow) },
66-
{ type: "separator" },
6754
...(await submenuForRuns(createWindow)),
6855
],
6956
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { MenuItemConstructorOptions } from "electron"
17+
import { join } from "path"
18+
import { readdir } from "fs/promises"
1819
import { Profiles } from "madwizard"
20+
import { MenuItemConstructorOptions } from "electron"
1921
import { CreateWindowFunction } from "@kui-shell/core"
20-
import { readdir } from "fs/promises"
21-
import { join } from "path"
2222

23-
import windowOptions from "../window"
23+
import windowOptions from "../../window"
2424

2525
export const RUNS_ERROR = "No runs found"
2626

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { CreateWindowFunction } from "@kui-shell/core"
18+
19+
import windowOptions from "../../window"
20+
import { shutDownIcon } from "../../icons"
21+
22+
/** Handler for shutting down a profile */
23+
async function shutdown(profile: string, createWindow: CreateWindowFunction) {
24+
createWindow(
25+
["codeflare", "gui", "guide", "ml/ray/stop/kubernetes", "--profile", profile],
26+
windowOptions({ title: "Shutting down " + profile })
27+
)
28+
}
29+
30+
export default function shutdownMenuItem(profile: string, createWindow: CreateWindowFunction) {
31+
return { label: "Shutdown", icon: shutDownIcon, click: () => shutdown(profile, createWindow) }
32+
}

0 commit comments

Comments
 (0)