Fix NetworkMachineIndicator and machines dynamically showing in CommandBar (#4311)
This commit is contained in:
@ -7,6 +7,7 @@ import {
|
||||
} from 'lib/commandTypes'
|
||||
import { Selections } from 'lib/selections'
|
||||
import { getCommandArgumentKclValuesOnly } from 'lib/commandUtils'
|
||||
import { MachineManager } from 'components/MachineManagerProvider'
|
||||
|
||||
export type CommandBarContext = {
|
||||
commands: Command[]
|
||||
@ -14,6 +15,7 @@ export type CommandBarContext = {
|
||||
currentArgument?: CommandArgument<unknown> & { name: string }
|
||||
selectionRanges: Selections
|
||||
argumentsToSubmit: { [x: string]: unknown }
|
||||
machineManager: MachineManager
|
||||
}
|
||||
|
||||
export type CommandBarMachineEvent =
|
||||
@ -71,6 +73,7 @@ export type CommandBarMachineEvent =
|
||||
type: 'Change current argument'
|
||||
data: { [x: string]: CommandArgumentWithName<unknown> }
|
||||
}
|
||||
| { type: 'Set machine manager'; data: MachineManager }
|
||||
|
||||
export const commandBarMachine = setup({
|
||||
types: {
|
||||
@ -90,6 +93,12 @@ export const commandBarMachine = setup({
|
||||
}
|
||||
},
|
||||
}),
|
||||
'Set machine manager': assign({
|
||||
machineManager: ({ event, context }) => {
|
||||
if (event.type !== 'Set machine manager') return context.machineManager
|
||||
return event.data
|
||||
},
|
||||
}),
|
||||
'Execute command': ({ context, event }) => {
|
||||
const { selectedCommand } = context
|
||||
if (!selectedCommand) return
|
||||
@ -339,6 +348,13 @@ export const commandBarMachine = setup({
|
||||
codeBasedSelections: [],
|
||||
},
|
||||
argumentsToSubmit: {},
|
||||
machineManager: {
|
||||
machines: [],
|
||||
machineApiIp: null,
|
||||
currentMachine: null,
|
||||
setCurrentMachine: () => {},
|
||||
noMachinesReason: () => undefined,
|
||||
},
|
||||
},
|
||||
id: 'Command Bar',
|
||||
initial: 'Closed',
|
||||
@ -520,6 +536,11 @@ export const commandBarMachine = setup({
|
||||
},
|
||||
},
|
||||
on: {
|
||||
'Set machine manager': {
|
||||
reenter: false,
|
||||
actions: 'Set machine manager',
|
||||
},
|
||||
|
||||
Close: {
|
||||
target: '.Closed',
|
||||
},
|
||||
|
Reference in New Issue
Block a user