Refactor: decouple command palette actor from React (#5108)
* Convert commandBarMachine to standalone actor * Switch all uses of CommandBarProvider pattern to use actor and selector snapshots directly
This commit is contained in:
@ -68,10 +68,6 @@ interface TextToKclProps {
|
||||
data?: unknown
|
||||
) => unknown
|
||||
navigate: NavigateFunction
|
||||
commandBarSend: (
|
||||
type: EventFrom<typeof commandBarMachine>,
|
||||
data?: unknown
|
||||
) => unknown
|
||||
context: ContextFrom<typeof fileMachine>
|
||||
token?: string
|
||||
settings: {
|
||||
@ -84,7 +80,6 @@ export async function submitAndAwaitTextToKcl({
|
||||
trimmedPrompt,
|
||||
fileMachineSend,
|
||||
navigate,
|
||||
commandBarSend,
|
||||
context,
|
||||
token,
|
||||
settings,
|
||||
@ -96,7 +91,6 @@ export async function submitAndAwaitTextToKcl({
|
||||
ToastTextToCadError({
|
||||
toastId,
|
||||
message,
|
||||
commandBarSend,
|
||||
prompt: trimmedPrompt,
|
||||
}),
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { CustomIconName } from 'components/CustomIcon'
|
||||
import { DEV } from 'env'
|
||||
import { commandBarMachine } from 'machines/commandBarMachine'
|
||||
import { commandBarActor, commandBarMachine } from 'machines/commandBarMachine'
|
||||
import {
|
||||
canRectangleOrCircleTool,
|
||||
isClosedSketch,
|
||||
@ -21,7 +21,6 @@ type ToolbarMode = {
|
||||
export interface ToolbarItemCallbackProps {
|
||||
modelingState: StateFrom<typeof modelingMachine>
|
||||
modelingSend: (event: EventFrom<typeof modelingMachine>) => void
|
||||
commandBarSend: (event: EventFrom<typeof commandBarMachine>) => void
|
||||
sketchPathId: string | false
|
||||
}
|
||||
|
||||
@ -84,8 +83,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
'break',
|
||||
{
|
||||
id: 'extrude',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Extrude', groupId: 'modeling' },
|
||||
}),
|
||||
@ -98,8 +97,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
},
|
||||
{
|
||||
id: 'revolve',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Revolve', groupId: 'modeling' },
|
||||
}),
|
||||
@ -119,8 +118,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
},
|
||||
{
|
||||
id: 'sweep',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Sweep', groupId: 'modeling' },
|
||||
}),
|
||||
@ -139,8 +138,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
},
|
||||
{
|
||||
id: 'loft',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Loft', groupId: 'modeling' },
|
||||
}),
|
||||
@ -160,8 +159,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
'break',
|
||||
{
|
||||
id: 'fillet3d',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Fillet', groupId: 'modeling' },
|
||||
}),
|
||||
@ -174,8 +173,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
},
|
||||
{
|
||||
id: 'chamfer3d',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Chamfer', groupId: 'modeling' },
|
||||
}),
|
||||
@ -188,8 +187,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
},
|
||||
{
|
||||
id: 'shell',
|
||||
onClick: ({ commandBarSend }) => {
|
||||
commandBarSend({
|
||||
onClick: () => {
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Shell', groupId: 'modeling' },
|
||||
})
|
||||
@ -269,8 +268,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
[
|
||||
{
|
||||
id: 'plane-offset',
|
||||
onClick: ({ commandBarSend }) => {
|
||||
commandBarSend({
|
||||
onClick: () => {
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Offset plane', groupId: 'modeling' },
|
||||
})
|
||||
@ -301,8 +300,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
[
|
||||
{
|
||||
id: 'text-to-cad',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Text-to-CAD', groupId: 'modeling' },
|
||||
}),
|
||||
@ -319,8 +318,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
},
|
||||
{
|
||||
id: 'prompt-to-edit',
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: { name: 'Prompt-to-edit', groupId: 'modeling' },
|
||||
}),
|
||||
@ -593,8 +592,8 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
{
|
||||
id: 'constraint-length',
|
||||
disabled: (state) => !state.matches({ Sketch: 'SketchIdle' }),
|
||||
onClick: ({ commandBarSend }) =>
|
||||
commandBarSend({
|
||||
onClick: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
data: {
|
||||
name: 'Constrain length',
|
||||
|
||||
Reference in New Issue
Block a user