Skip to content

Commit 6b98b4e

Browse files
committed
feat: initial "welcome" popup
Show this, instead of a blank terminal window when opening a new window. Also update the tray menu to open this new popup rather than visiting the codeflare home page, when clicking the first menu item. The design here is still largely a work in progress.
1 parent 47b5954 commit 6b98b4e

File tree

14 files changed

+478
-93
lines changed

14 files changed

+478
-93
lines changed

package-lock.json

Lines changed: 139 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@
8686
"printWidth": 120
8787
},
8888
"devDependencies": {
89-
"@kui-shell/builder": "11.5.0-dev-20220713-201002",
90-
"@kui-shell/proxy": "11.5.0-dev-20220713-201002",
91-
"@kui-shell/react": "11.5.0-dev-20220713-201002",
92-
"@kui-shell/webpack": "11.5.0-dev-20220713-201002",
89+
"@kui-shell/builder": "11.5.0-dev-20220714-155044",
90+
"@kui-shell/proxy": "11.5.0-dev-20220714-155044",
91+
"@kui-shell/react": "11.5.0-dev-20220714-155044",
92+
"@kui-shell/webpack": "11.5.0-dev-20220714-155044",
9393
"@playwright/test": "^1.23.2",
9494
"@types/debug": "^4.1.7",
9595
"@types/node": "14.11.8",
@@ -113,16 +113,16 @@
113113
},
114114
"dependencies": {
115115
"@kui-shell/client": "file:./plugins/plugin-client-default",
116-
"@kui-shell/core": "11.5.0-dev-20220713-201002",
117-
"@kui-shell/plugin-bash-like": "11.5.0-dev-20220713-201002",
118-
"@kui-shell/plugin-client-common": "11.5.0-dev-20220713-201002",
116+
"@kui-shell/core": "11.5.0-dev-20220714-155044",
117+
"@kui-shell/plugin-bash-like": "11.5.0-dev-20220714-155044",
118+
"@kui-shell/plugin-client-common": "11.5.0-dev-20220714-155044",
119119
"@kui-shell/plugin-codeflare": "file:./plugins/plugin-codeflare",
120-
"@kui-shell/plugin-core-support": "11.5.0-dev-20220713-201002",
121-
"@kui-shell/plugin-electron-components": "11.5.0-dev-20220713-201002",
122-
"@kui-shell/plugin-kubectl": "11.5.0-dev-20220713-201002",
120+
"@kui-shell/plugin-core-support": "11.5.0-dev-20220714-155044",
121+
"@kui-shell/plugin-electron-components": "11.5.0-dev-20220714-155044",
122+
"@kui-shell/plugin-kubectl": "11.5.0-dev-20220714-155044",
123123
"@kui-shell/plugin-madwizard": "file:./plugins/plugin-madwizard",
124-
"@kui-shell/plugin-patternfly4-themes": "11.5.0-dev-20220713-201002",
125-
"@kui-shell/plugin-proxy-support": "11.5.0-dev-20220713-201002",
126-
"@kui-shell/plugin-s3": "11.5.0-dev-20220713-201002"
124+
"@kui-shell/plugin-patternfly4-themes": "11.5.0-dev-20220714-155044",
125+
"@kui-shell/plugin-proxy-support": "11.5.0-dev-20220714-155044",
126+
"@kui-shell/plugin-s3": "11.5.0-dev-20220714-155044"
127127
}
128128
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2+
"width": 800,
3+
"height": 600,
24
"defaultTheme": "PatternFly4 Light"
35
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Welcome
3+
className: codeflare--welcome-guidebook
4+
layout:
5+
1:
6+
position: default
7+
maximized: true
8+
2:
9+
position: default
10+
maximized: true
11+
3:
12+
position: default
13+
maximized: true
14+
inverseColors: true
15+
---
16+
17+
<img alt="CodeFlare Icon" src="@kui-shell/client/icons/svg/codeflare.svg" width="80" height="80" />
18+
19+
---
20+
21+
<!-- TODO find some content to place here? -->
22+
23+
---
24+
25+
=== "Job Runs"
26+
27+
```shell
28+
---
29+
execute: now
30+
maximize: true
31+
outputOnly: true
32+
---
33+
codeflare get run
34+
```
35+
36+
=== "Profiles"
37+
38+
```shell
39+
---
40+
execute: now
41+
maximize: true
42+
outputOnly: true
43+
---
44+
codeflare get profile
45+
```

plugins/plugin-client-default/src/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 The Kubernetes Authors
2+
* Copyright 2022 The Kubernetes Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,8 @@ import { productTitle } from "@kui-shell/client/config.d/name.json"
2626

2727
import CodeFlareWidget from "./CodeFlareWidget"
2828

29+
import "../web/scss/guidebooks/welcome.scss"
30+
2931
/**
3032
* We will set this bit when the user dismisses the Welcome to Kui
3133
* tab, so as to avoid opening it again and bothering that user for
@@ -54,9 +56,14 @@ export default function renderMain(props: KuiProps) {
5456
noNewTabButton
5557
noNewSplitButton
5658
{...props}
57-
initialTabTitle="Dashboard"
59+
initialTabTitle="Welcome"
5860
isPopup={false}
5961
quietExecCommand={false}
62+
commandLine={
63+
process.env.RUNNING_KUI_TEST
64+
? undefined
65+
: props.commandLine || ["commentary", "--readonly", "-f", "/kui/client/welcome.md"]
66+
}
6067
>
6168
<ContextWidgets>
6269
<GitHubIcon />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 "@kui-shell/plugin-client-common/web/scss/components/Terminal/mixins";
18+
@import "@kui-shell/plugin-client-common/web/scss/components/TopLevelTab/mixins";
19+
20+
@include TopLevelTab {
21+
&.codeflare--welcome-guidebook {
22+
@include Split(3) {
23+
grid-template-rows: 80px 1fr;
24+
grid-template-columns: 80px 1fr;
25+
grid-template-areas: "T1 T2" "T3 T3";
26+
}
27+
}
28+
}

plugins/plugin-codeflare/src/controller/dashboard.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ async function dashboardui(args: Arguments<DashboardOptions>) {
5858
return args.REPL.qexec(`commentary -f /kui/client/dashboard.md`)
5959
}
6060

61+
/** Desired window width */
62+
export const width = 1280
63+
64+
/** Desired window height */
65+
export const height = 960
66+
6167
export default function registerDashboardCommands(registrar: Registrar) {
6268
const flags = followFlags
6369

@@ -68,7 +74,7 @@ export default function registerDashboardCommands(registrar: Registrar) {
6874
needsUI: true,
6975
outputOnly: true,
7076
flags,
71-
width: 1280,
72-
height: 960,
77+
width,
78+
height,
7379
})
7480
}

plugins/plugin-codeflare/src/controller/description.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,21 @@ function jobDefinition(filepath: string) {
4848
return encodeComponent(expand(join(filepath.replace(/'/g, ""), "ray-job-definition.json")))
4949
}
5050

51+
export async function getJobDefinition(runDir: string, REPL: Arguments["REPL"]) {
52+
try {
53+
return JSON.parse(await REPL.qexec<string>(`vfs fslice ${encodeComponent(jobDefinition(runDir))} 0`))
54+
} catch (err) {
55+
console.error(runDir, err)
56+
}
57+
}
58+
5159
async function app(args: Arguments) {
5260
const filepath = args.argvNoOptions[2]
5361
if (!filepath) {
5462
throw new Error("Usage: description application <filepath>")
5563
}
5664

57-
const jobInfo = JSON.parse(await args.REPL.qexec<string>(`vfs fslice ${jobDefinition(filepath)} 0`))
65+
const jobInfo = await getJobDefinition(filepath, args.REPL)
5866
const { RAY_IMAGE } = jobInfo.runtime_env.env_vars
5967

6068
const status = jobInfo.status.toLowerCase()

plugins/plugin-codeflare/src/controller/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ export default function registerCodeflareCommands(registrar: Registrar) {
3939
dashboard(registrar)
4040
description(registrar)
4141
registrar.listen("/help", help)
42+
43+
registrar.listen("/codeflare/get/profile", (args) => import("./profile/get").then((_) => _.default(args)), {
44+
needsUI: true,
45+
})
46+
registrar.listen("/codeflare/get/run", (args) => import("./run/get").then((_) => _.default(args)), { needsUI: true })
4247
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 React from "react"
18+
import { Profiles } from "madwizard"
19+
import { Arguments } from "@kui-shell/core"
20+
import { Grid, GridItem, Tile } from "@patternfly/react-core"
21+
22+
import "../../../web/scss/components/Welcome/_index.scss"
23+
24+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25+
export default async function getProfiles(args: Arguments) {
26+
const profiles = await Profiles.list({})
27+
28+
return {
29+
react: (
30+
<Grid hasGutter className="codeflare--grid">
31+
{profiles.map((_) => (
32+
<GridItem key={_.profile.name}>
33+
<Tile className="codeflare--tile" title={_.profile.name} />
34+
</GridItem>
35+
))}
36+
</Grid>
37+
),
38+
}
39+
}

0 commit comments

Comments
 (0)