14
14
* limitations under the License.
15
15
*/
16
16
17
+ import Debug from "debug"
17
18
import React from "react"
18
19
import prettyMillis from "pretty-ms"
19
20
import prettyBytes from "pretty-bytes"
20
- import { Box , Text , TextProps } from "ink"
21
21
import { emitKeypressEvents } from "readline"
22
+ import { Box , Text , TextProps , render } from "ink"
22
23
23
24
import type { JobRec , HostRec , PodRec , OnData , UpdatePayload , Resource , ResourceSpec } from "./types.js"
24
25
@@ -63,7 +64,7 @@ type State = UI & {
63
64
refresher : ReturnType < typeof setInterval >
64
65
}
65
66
66
- export default class NodesDashboard extends React . PureComponent < Props , State > {
67
+ class Top extends React . PureComponent < Props , State > {
67
68
/** Text to use for one cell's worth of time */
68
69
private readonly block = "■" // "▇"
69
70
@@ -342,7 +343,10 @@ export default class NodesDashboard extends React.PureComponent<Props, State> {
342
343
}
343
344
344
345
public render ( ) {
345
- if ( ! this . state ?. groups || this . state . groups . length === 0 ) {
346
+ if ( ! this . state ?. groups ) {
347
+ // TODO spinner? this means we haven't received the first data set, yet
348
+ return < React . Fragment />
349
+ } else if ( this . state . groups . length === 0 ) {
346
350
return < Text > No active jobs</ Text >
347
351
} else {
348
352
return (
@@ -353,3 +357,12 @@ export default class NodesDashboard extends React.PureComponent<Props, State> {
353
357
}
354
358
}
355
359
}
360
+
361
+ export default async function renderTop ( props : Props ) {
362
+ const debug = Debug ( "plugin-codeflare-dashboard/components/Top" )
363
+
364
+ debug ( "rendering" )
365
+ const { waitUntilExit } = await render ( < Top { ...props } /> )
366
+ debug ( "initial render done" )
367
+ await waitUntilExit ( )
368
+ }
0 commit comments