Repository navigation
Toolbar: show a running profile save and disable what it would refuse - #121
Conversation
Profiles reports when a save, launch or delete starts and ends. ipc sends it as vm:profileWork, and profileWork() returns the ones already running when a window opens.
While a profile save, launch or delete runs on the selected VM, its status reads Saving profile (or Launching/Deleting), and Power on, Suspend, Resume, Save state, Restart, Shut down and Clone are disabled with a tooltip saying why. Force off stays enabled as the way out. Ctrl+Enter and Delete are held back the same way. The mock backend reports it too.
A21-devs
left a comment
There was a problem hiding this comment.
The toolbar side is right: every button the backend refuses during a profile operation is now disabled with a reason, Force off is left alone, and onWork is called from exclusive's finally, so a failed save can't leave the toolbar stuck disabled.
One gap in the same spirit, inline below: the Hardware tab still only looks at status.
|
|
||
| export default function VmDetail(props: Props) { | ||
| const { vm, isDraft, status, host, onSave, onCancelDraft, onDelete, onDirtyChange } = props | ||
| const { vm, isDraft, status, work, host, onSave, onCancelDraft, onDelete, onDirtyChange } = props |
There was a problem hiding this comment.
work gets as far as the status text, but the Hardware tab still uses locked={status !== 'off'} and canSave only checks status === 'off'. A disk-only profile save (VM off) or the off stretch of a launch leaves the form, Save, Ctrl+S and Delete enabled, and save / remove then fail with "busy with a profile". Lock them on work !== null too.
| if (s.status === 'off') setUsage(({ [s.name]: _gone, ...rest }) => rest) | ||
| if (s.status === 'off') setHibernating((cur) => (cur.has(s.name) ? new Set([...cur].filter((n) => n !== s.name)) : cur)) | ||
| }) | ||
| window.vmm.profileWork().then(setProfileWork) |
There was a problem hiding this comment.
Minor, no change needed: if a vm:profileWork event lands before this reply, the reply overwrites it. Same pattern as states() above it. The worst case is the toolbar staying enabled until the next event, which is what we had before this PR.
|
Fixed the Hardware tab in 1708651: VmDetail now locks it on Left the |
A disk-only profile save, or a launch rolling the disk back, runs while the VM is off, so the form, Save, Ctrl+S and Delete stayed enabled and then failed with busy with a profile. The notice above the form says why it is locked.
A21-devs
left a comment
There was a problem hiding this comment.
Checked 1708651 against the earlier comment. locked now covers both cases and feeds the fieldset, Revert, Save, Delete and canSave, so Ctrl+S follows it too. The notice text matches the toolbar tooltip. The port forward check (checkPorts={!locked}) also pauses during a profile operation, which is fine since the form can't be edited then anyway. Nothing else to raise.
Closes #117
Since #115 the backend refuses Save state and the power actions while a profile save runs, but the toolbar only found out when you clicked. Now it knows ahead of time.
Backend
Profilestakes an optionalonWork(vm, work)callback and calls it when a save, launch or delete starts and ends ('saving' | 'launching' | 'removing', ornull).profiles.work()returns the ones running now.vm:profileWork. NewprofileWork()/onProfileWork()on the API so a window that opens mid-save gets it too.VmRuntimeState: the runner doesn't know about profiles, and a save goes through off and starting again while it's running.UI
Testing
npm run typecheck,npm test(139 passed),npm run buildonWorkgetssavingthennulleven when the save fails, andwork()is empty after.