Skip to content

Commit cb57f26

Browse files
committed
fix: UI hangs with spinners for first-time users
This PR bumps us to [email protected] to pick up the `Profiles.createIfNeeded()` API, and udpates ProfileExplorer to use it. It also includes some minor code cleanup around this.
1 parent e21fcce commit cb57f26

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

Diff for: package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: plugins/plugin-codeflare/src/components/ProfileExplorer.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import React from "react"
1818
import { diff } from "json-diff"
19-
import { Profiles } from "madwizard"
2019
import { Icons, Loading, Tooltip } from "@kui-shell/plugin-client-common"
2120
import {
2221
Card,
@@ -46,11 +45,12 @@ import ProfileStatusWatcher from "../tray/watchers/profile/status"
4645
import UpdateFunction from "../tray/update"
4746
import { handleNew, handleDelete, handleReset } from "../controller/profile/actions"
4847

49-
import "../../web/scss/components/Dashboard/Description.scss"
5048
import "../../web/scss/components/ProfileExplorer/_index.scss"
5149

50+
type Profile = import("madwizard").Profiles.Profile[]
51+
5252
type Props = {
53-
onSelectProfile?(profile: string, profiles?: import("madwizard").Profiles.Profile[]): void
53+
onSelectProfile?(profile: string, profiles?: Profile): void
5454
onSelectGuidebook?(guidebook: string): void
5555
}
5656

@@ -63,7 +63,7 @@ type State = Partial<Diff> & {
6363
watcher: ProfileWatcher
6464
statusWatcher: ProfileStatusWatcher
6565
selectedProfile?: string
66-
profiles?: Profiles.Profile[]
66+
profiles?: Profile
6767
catastrophicError?: unknown
6868

6969
/** To help with re-rendering */
@@ -112,7 +112,7 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
112112

113113
private updateDebouncer: null | ReturnType<typeof setTimeout> = null
114114

115-
private lastUsed(profiles: Profiles.Profile[]) {
115+
private lastUsed(profiles: Profile) {
116116
return profiles.slice(1).reduce((lastUsed, profile) => {
117117
if (lastUsed.lastUsedTime < profile.lastUsedTime) {
118118
return profile
@@ -190,6 +190,8 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
190190

191191
private async init() {
192192
try {
193+
const { Profiles } = await import("madwizard")
194+
Profiles.createIfNeeded()
193195
const watcher = await new ProfileWatcher(
194196
this.profileWatcherUpdateFn,
195197
await Profiles.profilesPath({}, true)
@@ -242,7 +244,7 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
242244
type ProfileCardProps = Partial<Diff> &
243245
Pick<Props, "onSelectGuidebook"> & {
244246
profile: string
245-
profiles: Profiles.Profile[]
247+
profiles: Profile
246248
onSelectProfile: (profile: string | null) => void
247249

248250
profileReadiness: string

Diff for: plugins/plugin-madwizard/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^1.5.0",
26+
"madwizard": "^1.6.0",
2727
"@guidebooks/store": "^0.14.3"
2828
}
2929
}

0 commit comments

Comments
 (0)