1414 * limitations under the License.
1515 */
1616
17- import React from "react"
18- import { join } from "path"
1917import { readdir } from "fs"
2018import { Profiles } from "madwizard"
21- import { Grid , GridItem , Tile } from "@patternfly/react-core"
22- import { Arguments , ReactResponse } from "@kui-shell/core"
19+ import { basename , join } from "path"
20+ import { Arguments , Table } from "@kui-shell/core"
21+
22+ import { productName } from "@kui-shell/client/config.d/name.json"
2323
2424import { width , height } from "../dashboard"
2525import { getJobDefinition } from "../description"
2626
27- async function openDashboard ( this : Arguments [ "REPL" ] , evt : React . MouseEvent < HTMLDivElement > ) {
28- const runDir = evt . currentTarget . getAttribute ( "data-run-dir" )
27+ async function openDashboard ( this : Arguments [ "REPL" ] , /* evt: React.MouseEvent<HTMLDivElement>*/ runDir : string ) {
28+ // const runDir = evt.currentTarget.getAttribute("data-run-dir")
2929 if ( runDir ) {
3030 const { ipcRenderer } = await import ( "electron" )
3131 ipcRenderer . send (
3232 "synchronous-message" ,
3333 JSON . stringify ( {
3434 operation : "new-window" ,
35- title : "Dashboard" ,
35+ title : productName + " Dashboard: " + basename ( runDir ) ,
36+ initialTabTitle : "Dashboard" ,
3637 width,
3738 height,
3839 argv : [ "codeflare" , "dashboardui" , runDir ] ,
@@ -41,10 +42,32 @@ async function openDashboard(this: Arguments["REPL"], evt: React.MouseEvent<HTML
4142 }
4243}
4344
45+ function capitalize ( str : string ) {
46+ return str [ 0 ] . toUpperCase ( ) + str . slice ( 1 )
47+ }
48+
49+ /** TODO: these are specific to Ray */
50+ type Status = "SUCCEEDED" | "STOPPED" | "RUNNING" | "PENDING" | "ERROR"
51+ function statusColor ( status : Status ) {
52+ switch ( status ) {
53+ case "SUCCEEDED" :
54+ return "green-background"
55+ case "STOPPED" :
56+ case "ERROR" :
57+ return "red-background"
58+ case "RUNNING" :
59+ return "cyan-background"
60+ case "PENDING" :
61+ return "yellow-background"
62+ default :
63+ return "gray-background"
64+ }
65+ }
66+
4467export default async function getProfiles ( args : Arguments ) {
4568 const onClick = openDashboard . bind ( args . REPL )
4669
47- return new Promise < ReactResponse > ( ( resolve , reject ) => {
70+ return new Promise < Table > ( ( resolve , reject ) => {
4871 const runsDir = Profiles . guidebookJobDataPath ( { } )
4972 readdir ( runsDir , async ( err , runs ) => {
5073 if ( err ) {
@@ -63,7 +86,19 @@ export default async function getProfiles(args: Arguments) {
6386 } ) )
6487 . filter ( ( _ ) => ! ! _ . info )
6588
66- resolve ( {
89+ const table : Table = {
90+ defaultPresentation : "grid" ,
91+ body : details . map ( ( _ ) => ( {
92+ name : _ . jobId ,
93+ onclick : ( ) => onClick ( _ . runDir ) ,
94+ attributes : [
95+ { key : "STATUS" , value : capitalize ( _ . info . status ) , tag : "badge" , css : statusColor ( _ . info . status ) } ,
96+ ] ,
97+ } ) ) ,
98+ }
99+
100+ resolve ( table )
101+ /* resolve({
67102 react: (
68103 <Grid span={1} className="codeflare--grid codeflare--mini">
69104 {details.map((_) => (
@@ -80,7 +115,7 @@ export default async function getProfiles(args: Arguments) {
80115 ))}
81116 </Grid>
82117 ),
83- } )
118+ }) */
84119 }
85120 } )
86121 } )
0 commit comments