16
16
17
17
import React from "react"
18
18
import { diff } from "json-diff"
19
- import { Profiles } from "madwizard"
20
19
import { Icons , Loading , Tooltip } from "@kui-shell/plugin-client-common"
21
20
import {
22
21
Card ,
@@ -46,11 +45,12 @@ import ProfileStatusWatcher from "../tray/watchers/profile/status"
46
45
import UpdateFunction from "../tray/update"
47
46
import { handleNew , handleDelete , handleReset } from "../controller/profile/actions"
48
47
49
- import "../../web/scss/components/Dashboard/Description.scss"
50
48
import "../../web/scss/components/ProfileExplorer/_index.scss"
51
49
50
+ type Profile = import ( "madwizard" ) . Profiles . Profile [ ]
51
+
52
52
type Props = {
53
- onSelectProfile ?( profile : string , profiles ?: import ( "madwizard" ) . Profiles . Profile [ ] ) : void
53
+ onSelectProfile ?( profile : string , profiles ?: Profile ) : void
54
54
onSelectGuidebook ?( guidebook : string ) : void
55
55
}
56
56
@@ -63,7 +63,7 @@ type State = Partial<Diff> & {
63
63
watcher : ProfileWatcher
64
64
statusWatcher : ProfileStatusWatcher
65
65
selectedProfile ?: string
66
- profiles ?: Profiles . Profile [ ]
66
+ profiles ?: Profile
67
67
catastrophicError ?: unknown
68
68
69
69
/** To help with re-rendering */
@@ -112,7 +112,7 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
112
112
113
113
private updateDebouncer : null | ReturnType < typeof setTimeout > = null
114
114
115
- private lastUsed ( profiles : Profiles . Profile [ ] ) {
115
+ private lastUsed ( profiles : Profile ) {
116
116
return profiles . slice ( 1 ) . reduce ( ( lastUsed , profile ) => {
117
117
if ( lastUsed . lastUsedTime < profile . lastUsedTime ) {
118
118
return profile
@@ -190,6 +190,8 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
190
190
191
191
private async init ( ) {
192
192
try {
193
+ const { Profiles } = await import ( "madwizard" )
194
+ Profiles . createIfNeeded ( )
193
195
const watcher = await new ProfileWatcher (
194
196
this . profileWatcherUpdateFn ,
195
197
await Profiles . profilesPath ( { } , true )
@@ -242,7 +244,7 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
242
244
type ProfileCardProps = Partial < Diff > &
243
245
Pick < Props , "onSelectGuidebook" > & {
244
246
profile : string
245
- profiles : Profiles . Profile [ ]
247
+ profiles : Profile
246
248
onSelectProfile : ( profile : string | null ) => void
247
249
248
250
profileReadiness : string
0 commit comments