2024-09-09 19:59:36 +03:00
|
|
|
import { assign, fromPromise, setup } from 'xstate'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
import {
|
|
|
|
Command,
|
|
|
|
CommandArgument,
|
|
|
|
CommandArgumentWithName,
|
2024-02-23 11:24:22 -05:00
|
|
|
KclCommandValue,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
} from 'lib/commandTypes'
|
2024-11-21 15:04:30 +11:00
|
|
|
import { Selections__old } from 'lib/selections'
|
2024-02-23 11:24:22 -05:00
|
|
|
import { getCommandArgumentKclValuesOnly } from 'lib/commandUtils'
|
2024-10-25 19:28:10 -04:00
|
|
|
import { MachineManager } from 'components/MachineManagerProvider'
|
2024-12-10 12:11:01 -05:00
|
|
|
import toast from 'react-hot-toast'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
|
2024-03-04 16:06:43 -05:00
|
|
|
export type CommandBarContext = {
|
|
|
|
commands: Command[]
|
|
|
|
selectedCommand?: Command
|
|
|
|
currentArgument?: CommandArgument<unknown> & { name: string }
|
2024-11-21 15:04:30 +11:00
|
|
|
selectionRanges: Selections__old
|
2024-03-04 16:06:43 -05:00
|
|
|
argumentsToSubmit: { [x: string]: unknown }
|
2024-10-25 19:28:10 -04:00
|
|
|
machineManager: MachineManager
|
2024-03-04 16:06:43 -05:00
|
|
|
}
|
|
|
|
|
2024-04-19 14:24:40 -07:00
|
|
|
export type CommandBarMachineEvent =
|
|
|
|
| { type: 'Open' }
|
|
|
|
| { type: 'Close' }
|
|
|
|
| { type: 'Clear' }
|
|
|
|
| {
|
|
|
|
type: 'Select command'
|
2024-08-14 14:26:44 -04:00
|
|
|
data: { command: Command; argDefaultValues?: { [x: string]: unknown } }
|
2024-04-19 14:24:40 -07:00
|
|
|
}
|
|
|
|
| { type: 'Deselect command' }
|
2024-09-09 19:59:36 +03:00
|
|
|
| { type: 'Submit command'; output: { [x: string]: unknown } }
|
2024-04-19 14:24:40 -07:00
|
|
|
| {
|
|
|
|
type: 'Add argument'
|
|
|
|
data: { argument: CommandArgumentWithName<unknown> }
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Remove argument'
|
|
|
|
data: { [x: string]: CommandArgumentWithName<unknown> }
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Edit argument'
|
|
|
|
data: { arg: CommandArgumentWithName<unknown> }
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Add commands'
|
|
|
|
data: { commands: Command[] }
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Remove commands'
|
|
|
|
data: { commands: Command[] }
|
|
|
|
}
|
|
|
|
| { type: 'Submit argument'; data: { [x: string]: unknown } }
|
|
|
|
| {
|
2024-09-09 19:59:36 +03:00
|
|
|
type: 'xstate.done.actor.validateSingleArgument'
|
|
|
|
output: { [x: string]: unknown }
|
2024-04-19 14:24:40 -07:00
|
|
|
}
|
|
|
|
| {
|
2024-09-09 19:59:36 +03:00
|
|
|
type: 'xstate.done.actor.validateArguments'
|
|
|
|
output: { [x: string]: unknown }
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'xstate.error.actor.validateArguments'
|
|
|
|
error: { message: string; arg: CommandArgumentWithName<unknown> }
|
2024-04-19 14:24:40 -07:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Find and select command'
|
2024-08-14 14:26:44 -04:00
|
|
|
data: {
|
|
|
|
name: string
|
|
|
|
groupId: string
|
|
|
|
argDefaultValues?: { [x: string]: unknown }
|
|
|
|
}
|
2024-04-19 14:24:40 -07:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Change current argument'
|
|
|
|
data: { [x: string]: CommandArgumentWithName<unknown> }
|
|
|
|
}
|
2024-10-25 19:28:10 -04:00
|
|
|
| { type: 'Set machine manager'; data: MachineManager }
|
2024-04-19 14:24:40 -07:00
|
|
|
|
2024-09-09 19:59:36 +03:00
|
|
|
export const commandBarMachine = setup({
|
|
|
|
types: {
|
|
|
|
context: {} as CommandBarContext,
|
|
|
|
events: {} as CommandBarMachineEvent,
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
enqueueValidArgsToSubmit: assign({
|
|
|
|
argumentsToSubmit: ({ context, event }) => {
|
|
|
|
if (event.type !== 'xstate.done.actor.validateSingleArgument') return {}
|
|
|
|
const [argName, argData] = Object.entries(event.output)[0]
|
|
|
|
const { currentArgument } = context
|
|
|
|
if (!currentArgument) return {}
|
|
|
|
return {
|
|
|
|
...context.argumentsToSubmit,
|
|
|
|
[argName]: argData,
|
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
}),
|
2024-10-25 19:28:10 -04:00
|
|
|
'Set machine manager': assign({
|
|
|
|
machineManager: ({ event, context }) => {
|
|
|
|
if (event.type !== 'Set machine manager') return context.machineManager
|
|
|
|
return event.data
|
|
|
|
},
|
|
|
|
}),
|
2024-09-09 19:59:36 +03:00
|
|
|
'Execute command': ({ context, event }) => {
|
|
|
|
const { selectedCommand } = context
|
|
|
|
if (!selectedCommand) return
|
|
|
|
if (
|
|
|
|
(selectedCommand?.args && event.type === 'Submit command') ||
|
|
|
|
event.type === 'xstate.done.actor.validateArguments'
|
|
|
|
) {
|
|
|
|
const resolvedArgs = {} as { [x: string]: unknown }
|
|
|
|
for (const [argName, argValue] of Object.entries(
|
|
|
|
getCommandArgumentKclValuesOnly(event.output)
|
|
|
|
)) {
|
|
|
|
resolvedArgs[argName] =
|
|
|
|
typeof argValue === 'function' ? argValue(context) : argValue
|
|
|
|
}
|
|
|
|
selectedCommand?.onSubmit(resolvedArgs)
|
|
|
|
} else {
|
|
|
|
selectedCommand?.onSubmit()
|
|
|
|
}
|
|
|
|
},
|
2025-01-16 12:08:48 -05:00
|
|
|
'Clear selected command': assign({
|
|
|
|
selectedCommand: undefined,
|
|
|
|
}),
|
2024-09-09 19:59:36 +03:00
|
|
|
'Set current argument to first non-skippable': assign({
|
|
|
|
currentArgument: ({ context, event }) => {
|
|
|
|
const { selectedCommand } = context
|
|
|
|
if (!(selectedCommand && selectedCommand.args)) return undefined
|
|
|
|
const rejectedArg =
|
|
|
|
'data' in event && 'arg' in event.data && event.data.arg
|
|
|
|
|
|
|
|
// Find the first argument that is not to be skipped:
|
|
|
|
// that is, the first argument that is not already in the argumentsToSubmit
|
|
|
|
// or that is not undefined, or that is not marked as "skippable".
|
|
|
|
// TODO validate the type of the existing arguments
|
|
|
|
let argIndex = 0
|
|
|
|
|
|
|
|
while (argIndex < Object.keys(selectedCommand.args).length) {
|
|
|
|
const [argName, argConfig] = Object.entries(selectedCommand.args)[
|
|
|
|
argIndex
|
|
|
|
]
|
|
|
|
const argIsRequired =
|
|
|
|
typeof argConfig.required === 'function'
|
|
|
|
? argConfig.required(context)
|
|
|
|
: argConfig.required
|
|
|
|
const mustNotSkipArg =
|
|
|
|
argIsRequired &&
|
|
|
|
(!context.argumentsToSubmit.hasOwnProperty(argName) ||
|
|
|
|
context.argumentsToSubmit[argName] === undefined ||
|
|
|
|
(rejectedArg &&
|
|
|
|
typeof rejectedArg === 'object' &&
|
|
|
|
'name' in rejectedArg &&
|
|
|
|
rejectedArg.name === argName))
|
|
|
|
|
|
|
|
if (
|
|
|
|
mustNotSkipArg === true ||
|
|
|
|
argIndex + 1 === Object.keys(selectedCommand.args).length
|
|
|
|
) {
|
|
|
|
// If we have reached the end of the arguments and none are skippable,
|
|
|
|
// return the last argument.
|
|
|
|
return {
|
|
|
|
...selectedCommand.args[argName],
|
|
|
|
name: argName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argIndex++
|
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
|
2024-09-09 19:59:36 +03:00
|
|
|
// TODO: use an XState service to continue onto review step
|
|
|
|
// if all arguments are skippable and contain values.
|
|
|
|
return undefined
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
}),
|
|
|
|
'Clear current argument': assign({
|
|
|
|
currentArgument: undefined,
|
|
|
|
}),
|
|
|
|
'Remove argument': assign({
|
|
|
|
argumentsToSubmit: ({ context, event }) => {
|
|
|
|
if (event.type !== 'Remove argument') return context.argumentsToSubmit
|
|
|
|
const argToRemove = Object.values(event.data)[0]
|
|
|
|
// Extract all but the argument to remove and return it
|
|
|
|
const { [argToRemove.name]: _, ...rest } = context.argumentsToSubmit
|
|
|
|
return rest
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
}),
|
|
|
|
'Set current argument': assign({
|
|
|
|
currentArgument: ({ context, event }) => {
|
|
|
|
switch (event.type) {
|
|
|
|
case 'Edit argument':
|
|
|
|
return event.data.arg
|
|
|
|
case 'Change current argument':
|
|
|
|
return Object.values(event.data)[0]
|
|
|
|
default:
|
|
|
|
return context.currentArgument
|
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
}),
|
|
|
|
'Clear argument data': assign({
|
|
|
|
selectedCommand: undefined,
|
|
|
|
currentArgument: undefined,
|
|
|
|
argumentsToSubmit: {},
|
|
|
|
}),
|
|
|
|
'Set selected command': assign({
|
|
|
|
selectedCommand: ({ context, event }) =>
|
|
|
|
event.type === 'Select command'
|
|
|
|
? event.data.command
|
|
|
|
: context.selectedCommand,
|
|
|
|
}),
|
|
|
|
'Find and select command': assign({
|
|
|
|
selectedCommand: ({ context, event }) => {
|
|
|
|
if (event.type !== 'Find and select command')
|
|
|
|
return context.selectedCommand
|
|
|
|
const found = context.commands.find(
|
|
|
|
(cmd) =>
|
|
|
|
cmd.name === event.data.name && cmd.groupId === event.data.groupId
|
|
|
|
)
|
|
|
|
|
|
|
|
return !!found ? found : context.selectedCommand
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
}),
|
|
|
|
'Initialize arguments to submit': assign({
|
|
|
|
argumentsToSubmit: ({ context, event }) => {
|
2024-02-23 11:24:22 -05:00
|
|
|
if (
|
2024-09-09 19:59:36 +03:00
|
|
|
event.type !== 'Select command' &&
|
|
|
|
event.type !== 'Find and select command'
|
|
|
|
)
|
|
|
|
return {}
|
|
|
|
const command =
|
|
|
|
'data' in event && 'command' in event.data
|
|
|
|
? event.data.command
|
|
|
|
: context.selectedCommand
|
|
|
|
if (!command?.args) return {}
|
|
|
|
const args: { [x: string]: unknown } = {}
|
|
|
|
for (const [argName, arg] of Object.entries(command.args)) {
|
|
|
|
args[argName] =
|
|
|
|
event.data.argDefaultValues &&
|
|
|
|
argName in event.data.argDefaultValues
|
|
|
|
? event.data.argDefaultValues[argName]
|
|
|
|
: arg.skip && 'defaultValue' in arg
|
|
|
|
? arg.defaultValue
|
|
|
|
: undefined
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
}
|
2024-09-09 19:59:36 +03:00
|
|
|
return args
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
guards: {
|
|
|
|
'Command needs review': ({ context }) =>
|
|
|
|
context.selectedCommand?.needsReview || false,
|
|
|
|
'Command has no arguments': () => false,
|
|
|
|
'All arguments are skippable': () => false,
|
2025-01-16 12:08:48 -05:00
|
|
|
'Has selected command': ({ context }) => !!context.selectedCommand,
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
actors: {
|
2024-12-10 12:11:01 -05:00
|
|
|
'Validate argument': fromPromise(
|
|
|
|
({
|
|
|
|
input,
|
|
|
|
}: {
|
|
|
|
input: {
|
|
|
|
context: CommandBarContext | undefined
|
|
|
|
event: CommandBarMachineEvent | undefined
|
|
|
|
}
|
|
|
|
}) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (!input || input?.event?.type !== 'Submit argument') {
|
|
|
|
toast.error(`Unable to validate, wrong event type.`)
|
|
|
|
return reject(`Unable to validate, wrong event type`)
|
|
|
|
}
|
2024-09-09 19:59:36 +03:00
|
|
|
|
2024-12-10 12:11:01 -05:00
|
|
|
const context = input?.context
|
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
toast.error(`Unable to validate, wrong argument.`)
|
|
|
|
return reject(`Unable to validate, wrong argument`)
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = input.event.data
|
|
|
|
const argName = context.currentArgument?.name
|
|
|
|
const args = context?.selectedCommand?.args
|
|
|
|
const argConfig = args && argName ? args[argName] : undefined
|
|
|
|
// Only do a validation check if the argument, selectedCommand, and the validation function are defined
|
|
|
|
if (
|
|
|
|
context.currentArgument &&
|
|
|
|
context.selectedCommand &&
|
|
|
|
argConfig?.inputType === 'selection' &&
|
|
|
|
argConfig?.validation
|
|
|
|
) {
|
|
|
|
argConfig
|
|
|
|
.validation({ context, data })
|
|
|
|
.then((result) => {
|
|
|
|
if (typeof result === 'boolean' && result === true) {
|
|
|
|
return resolve(data)
|
|
|
|
} else {
|
|
|
|
// validation failed
|
|
|
|
if (typeof result === 'string') {
|
|
|
|
// The result of the validation is the error message
|
|
|
|
toast.error(result)
|
|
|
|
return reject(
|
|
|
|
`unable to validate ${argName}, Message: ${result}`
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
// Default message if there is not a custom one sent
|
|
|
|
toast.error(`Unable to validate ${argName}`)
|
|
|
|
return reject(`unable to validate ${argName}}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
return reject(`unable to validate ${argName}}`)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
// Missing several requirements for validate argument, just bypass
|
|
|
|
return resolve(data)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
),
|
2024-09-09 19:59:36 +03:00
|
|
|
'Validate all arguments': fromPromise(
|
|
|
|
({ input }: { input: CommandBarContext }) => {
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
return new Promise((resolve, reject) => {
|
2024-03-04 16:06:43 -05:00
|
|
|
for (const [argName, argConfig] of Object.entries(
|
2024-09-09 19:59:36 +03:00
|
|
|
input.selectedCommand!.args!
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
)) {
|
2024-09-09 19:59:36 +03:00
|
|
|
let arg = input.argumentsToSubmit[argName]
|
|
|
|
let argValue = typeof arg === 'function' ? arg(input) : arg
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
|
2024-03-04 16:06:43 -05:00
|
|
|
try {
|
|
|
|
const isRequired =
|
|
|
|
typeof argConfig.required === 'function'
|
2024-09-09 19:59:36 +03:00
|
|
|
? argConfig.required(input)
|
2024-03-04 16:06:43 -05:00
|
|
|
: argConfig.required
|
|
|
|
|
|
|
|
const resolvedDefaultValue =
|
|
|
|
'defaultValue' in argConfig
|
|
|
|
? typeof argConfig.defaultValue === 'function'
|
2024-09-09 19:59:36 +03:00
|
|
|
? argConfig.defaultValue(input)
|
2024-03-04 16:06:43 -05:00
|
|
|
: argConfig.defaultValue
|
|
|
|
: undefined
|
|
|
|
|
|
|
|
const hasMismatchedDefaultValueType =
|
|
|
|
isRequired &&
|
2024-03-14 15:56:45 -04:00
|
|
|
resolvedDefaultValue !== undefined &&
|
2024-03-04 16:06:43 -05:00
|
|
|
typeof argValue !== typeof resolvedDefaultValue &&
|
|
|
|
!(argConfig.inputType === 'kcl' || argConfig.skip)
|
|
|
|
const hasInvalidKclValue =
|
|
|
|
argConfig.inputType === 'kcl' &&
|
|
|
|
!(argValue as Partial<KclCommandValue> | undefined)?.valueAst
|
|
|
|
const hasInvalidOptionsValue =
|
|
|
|
isRequired &&
|
|
|
|
'options' in argConfig &&
|
|
|
|
!(
|
|
|
|
typeof argConfig.options === 'function'
|
2024-04-02 10:29:34 -04:00
|
|
|
? argConfig.options(
|
2024-09-09 19:59:36 +03:00
|
|
|
input,
|
2024-09-23 14:35:38 -04:00
|
|
|
argConfig.machineActor?.getSnapshot().context
|
2024-04-02 10:29:34 -04:00
|
|
|
)
|
2024-03-04 16:06:43 -05:00
|
|
|
: argConfig.options
|
|
|
|
).some((o) => o.value === argValue)
|
|
|
|
|
|
|
|
if (
|
|
|
|
hasMismatchedDefaultValueType ||
|
|
|
|
hasInvalidKclValue ||
|
|
|
|
hasInvalidOptionsValue
|
|
|
|
) {
|
|
|
|
return reject({
|
|
|
|
message: 'Argument payload is of the wrong type',
|
|
|
|
arg: {
|
|
|
|
...argConfig,
|
|
|
|
name: argName,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-04-02 10:29:34 -04:00
|
|
|
if (
|
2024-04-15 12:04:17 -04:00
|
|
|
(argConfig.inputType !== 'boolean' &&
|
|
|
|
argConfig.inputType !== 'options'
|
2024-04-02 10:29:34 -04:00
|
|
|
? !argValue
|
|
|
|
: argValue === undefined) &&
|
|
|
|
isRequired
|
|
|
|
) {
|
2024-03-04 16:06:43 -05:00
|
|
|
return reject({
|
|
|
|
message: 'Argument payload is falsy but is required',
|
|
|
|
arg: {
|
|
|
|
...argConfig,
|
|
|
|
name: argName,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Error validating argument', context, e)
|
2024-06-24 11:45:40 -04:00
|
|
|
return reject(e)
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-09 19:59:36 +03:00
|
|
|
return resolve(input.argumentsToSubmit)
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
})
|
2024-09-09 19:59:36 +03:00
|
|
|
}
|
|
|
|
),
|
|
|
|
},
|
|
|
|
}).createMachine({
|
2025-01-16 12:08:48 -05:00
|
|
|
/** @xstate-layout N4IgpgJg5mDOIC5QGED2BbdBDAdhABAEJYBOAxMgDaqxgDaADALqKgAONAlgC6eo6sQAD0QBaAIwB2AHTiAHAE45AZjkAmdcoaSArCoA0IAJ6JxDOdJ2SF4gCySHaqZIa2Avm8NpMuAsXJUYKSMLEggHLA8fAJhIgiiOgBssokKTpJqiXK2OsqJaoYm8eJqytKJ9hqq+eJW2h5eGNh4RKRkAGKcLb74tJRgAMbc+ANNviGCEVH8gnEKubK5ympVrrlyhabm0rZ5CtYM4hVq83ININ7NfqTSVDSQZADybGA4E2FTvDOxiGoMDNJMjo9H9lLYGDpKpsEModOJpA5XOIwakwcidOdLj1-LdqLQIGQAIIQAijHx4WDvdhcL4xUBxURqSTw3LzfYKZSSOQZWzQ5S1crMuTAiElRKuTFjFo4u74sgAJTA6FQADcwCMpRBKcxJjTorMxEzkhouftuXCGGpIdCpADmZJxfzJLY5Cp5pLydcSLj7gSqeE9d96Yh+TppKoXfkGKdlHloUyFIDUvMXBzbFl3J4LprWt6AMpgfpDLpQDWesgFovDMlXf2ffU-BBZZKuczWWylRRwvlM6Q2LIMZQ2QdHZQeq65245vqDbgPOuBunCEP88MqPQchwVNLKaHptTSYUuRI6f4npyJcfYm5Ylozobz8ShamRWkGhBmeTSQeJX+JXQ6H88jQnCMiugoELCpypQKJeWa3l6U6er0hazvOajPgGr4NsGH6WhYsHOkycglLCEJ7iclgaIosKSLGGgKFe0o3AA4lg3AABZgCQJb4KQUAAK7oK83CwBQHG4DAIwCSQJAiXxJCCcJODcAu2FBsuH55GGJ7irYHYqHpGzGKYWiWB2nK2Kcv6wWO8E5jibGcdxvH8UJIliQAInAqFDGWtY6h8i7vlkZREbYZg6JuwEmQgfxhnkHbiHYJ7yHYTGIU5XE8TgpZucponSISADuWBRLl+BdGwAncBWAkAEboDwClKSJanTEucS1Bk36DicDCpOYLoKHu-x9tGuhgoozKpBlk5ZS5FX5R50gAGpYJQnAQOxJZkBA-BgNIXQqqgADWh0qhtW3sWAeYlv0hKKe5KntW+YRFGi5RyOKDrZEaUW8pppTguGuwDRFEO-nNjnsdlrlPQVsBrVd228LlZDcSQqDemwlDsQAZtj6DSJdm2o7d91gI9rUvYFL4dYIH0RV9P0Zv9CiA3EwMAmCWgVHYKVwY0yE4oqKqcGAxV1Y1zU1uMdNYQzjbMpYcgQlFxFq66u6xXRALbkyg7-Bz0bQzcYsS1LxIEMttOYfWGldYcCWwQmNiRrU0Jq2GRxJCbHZqC6ahm96FuSwqSqquqtuqQrDudVs4iJhUyZtn9qjQokYKHjk6hSLsZhciH0hh1LACiEDNTHr04ZpJT6bIEXxcKp50YDRT-mGrrJbUgFDp3xfIFxAynbx1PPaJe0HUdOAnedJMozd4+IzXjuIJCLIQqUWjJS4MVFBByS7BzyJq38WTB-ZIs3sPo8VcvHlTzgh3HWdF2L3OD8qZST66upCdxUTLBJOUUHB6GFPpSQXt1CWEGpaOiv4EyD1vmPBGj9MbY2kLjAmRMF5kyXmg7+q8AFJwbjkXQEVsj5FyO3RAiQjjfi5CReYPck7iA8FmHAqAIBwEEAhXMf8la4VEMsWwgJuTTXNGYK0tC4rwkDvsAaSQ-qlAhIPPEkBBFvWEVycoFQhywUHGaHWH04Q7FUNBdc+x2FXwnDiSss5eJyzwFo2ucQIplBWHrcEVhuoFFirCeEuxsj8mWEOFYmZhZ2JvNOXyc4ICuLXggaxCJwG70AiUHQfIzHBKHGYDMJFhTFwWjlPKhDRKJJIRFGQcIFBsiOIHJw8ZIQ7CUGrY+9g9AnmKbDRaZSaaFRKmVNGpYqo1Uqe+FKYZan1PyElbJYjrB6C5CUJQ9DL5ROvN6Ep8MBlI3WvgkZEzGzyAbnkZK-wjan38UzeEzZtBswdADYupdjm4XoTIOwuwHB5HyGkYyRRdBBLosCIE6ZvpnFsVs24KD77lPgEFf+kzxRH32EyFYlpOzQjAZYV2ehTkfI4W4IAA */
|
2024-09-09 19:59:36 +03:00
|
|
|
context: {
|
|
|
|
commands: [],
|
|
|
|
selectedCommand: undefined,
|
|
|
|
currentArgument: undefined,
|
|
|
|
selectionRanges: {
|
|
|
|
otherSelections: [],
|
|
|
|
codeBasedSelections: [],
|
|
|
|
},
|
|
|
|
argumentsToSubmit: {},
|
2024-10-25 19:28:10 -04:00
|
|
|
machineManager: {
|
|
|
|
machines: [],
|
|
|
|
machineApiIp: null,
|
|
|
|
currentMachine: null,
|
|
|
|
setCurrentMachine: () => {},
|
|
|
|
noMachinesReason: () => undefined,
|
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
id: 'Command Bar',
|
|
|
|
initial: 'Closed',
|
|
|
|
states: {
|
|
|
|
Closed: {
|
|
|
|
on: {
|
|
|
|
Open: {
|
|
|
|
target: 'Selecting command',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Add commands': {
|
|
|
|
target: 'Closed',
|
|
|
|
|
|
|
|
actions: [
|
|
|
|
assign({
|
|
|
|
commands: ({ context, event }) =>
|
|
|
|
[...context.commands, ...event.data.commands].sort(
|
|
|
|
sortCommands
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
'Remove commands': {
|
|
|
|
target: 'Closed',
|
|
|
|
|
|
|
|
actions: [
|
|
|
|
assign({
|
|
|
|
commands: ({ context, event }) =>
|
|
|
|
context.commands.filter(
|
|
|
|
(c) =>
|
|
|
|
!event.data.commands.some(
|
|
|
|
(c2) => c2.name === c.name && c2.groupId === c.groupId
|
|
|
|
)
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2025-01-16 12:08:48 -05:00
|
|
|
|
|
|
|
always: {
|
|
|
|
target: 'Command selected',
|
|
|
|
guard: 'Has selected command',
|
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
'Selecting command': {
|
|
|
|
on: {
|
|
|
|
'Select command': {
|
|
|
|
target: 'Command selected',
|
|
|
|
actions: ['Set selected command', 'Initialize arguments to submit'],
|
|
|
|
},
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
|
|
|
|
'Command selected': {
|
|
|
|
always: [
|
|
|
|
{
|
|
|
|
target: 'Closed',
|
|
|
|
guard: 'Command has no arguments',
|
2025-01-16 12:08:48 -05:00
|
|
|
actions: ['Execute command', 'Clear selected command'],
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'Checking Arguments',
|
|
|
|
guard: 'All arguments are skippable',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'Gathering arguments',
|
|
|
|
actions: ['Set current argument to first non-skippable'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
'Gathering arguments': {
|
|
|
|
states: {
|
|
|
|
'Awaiting input': {
|
|
|
|
on: {
|
|
|
|
'Submit argument': {
|
|
|
|
target: 'Validating',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Validating: {
|
|
|
|
invoke: {
|
|
|
|
src: 'Validate argument',
|
|
|
|
id: 'validateSingleArgument',
|
2024-12-10 12:11:01 -05:00
|
|
|
input: ({ event, context }) => {
|
|
|
|
if (event.type !== 'Submit argument')
|
|
|
|
return { event: undefined, context: undefined }
|
|
|
|
return { event, context }
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
onDone: {
|
|
|
|
target: '#Command Bar.Checking Arguments',
|
|
|
|
actions: ['enqueueValidArgsToSubmit'],
|
|
|
|
},
|
|
|
|
onError: [
|
|
|
|
{
|
|
|
|
target: 'Awaiting input',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
initial: 'Awaiting input',
|
|
|
|
|
|
|
|
on: {
|
|
|
|
'Change current argument': {
|
|
|
|
target: 'Gathering arguments',
|
|
|
|
internal: true,
|
|
|
|
actions: ['Set current argument'],
|
|
|
|
},
|
|
|
|
|
|
|
|
'Deselect command': {
|
|
|
|
target: 'Selecting command',
|
|
|
|
actions: [
|
|
|
|
assign({
|
|
|
|
selectedCommand: (_c, _e) => undefined,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Review: {
|
|
|
|
entry: ['Clear current argument'],
|
|
|
|
on: {
|
|
|
|
'Submit command': {
|
|
|
|
target: 'Closed',
|
2025-01-16 12:08:48 -05:00
|
|
|
actions: ['Execute command', 'Clear selected command'],
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
'Add argument': {
|
|
|
|
target: 'Gathering arguments',
|
|
|
|
actions: ['Set current argument'],
|
|
|
|
},
|
|
|
|
|
|
|
|
'Remove argument': {
|
|
|
|
target: 'Review',
|
|
|
|
actions: ['Remove argument'],
|
|
|
|
},
|
|
|
|
|
|
|
|
'Edit argument': {
|
|
|
|
target: 'Gathering arguments',
|
|
|
|
actions: ['Set current argument'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Checking Arguments': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Validate all arguments',
|
|
|
|
id: 'validateArguments',
|
|
|
|
input: ({ context }) => context,
|
|
|
|
onDone: [
|
|
|
|
{
|
|
|
|
target: 'Review',
|
|
|
|
guard: 'Command needs review',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'Closed',
|
2025-01-16 12:08:48 -05:00
|
|
|
actions: ['Execute command', 'Clear selected command'],
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
],
|
|
|
|
onError: [
|
|
|
|
{
|
|
|
|
target: 'Gathering arguments',
|
|
|
|
actions: ['Set current argument to first non-skippable'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
on: {
|
2024-10-25 19:28:10 -04:00
|
|
|
'Set machine manager': {
|
|
|
|
reenter: false,
|
|
|
|
actions: 'Set machine manager',
|
|
|
|
},
|
|
|
|
|
2024-09-09 19:59:36 +03:00
|
|
|
Close: {
|
|
|
|
target: '.Closed',
|
2025-01-16 12:08:48 -05:00
|
|
|
actions: 'Clear selected command',
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
Clear: {
|
|
|
|
target: '#Command Bar',
|
|
|
|
reenter: false,
|
|
|
|
actions: ['Clear argument data'],
|
|
|
|
},
|
2025-01-16 12:08:48 -05:00
|
|
|
|
|
|
|
'Find and select command': {
|
|
|
|
target: '.Command selected',
|
|
|
|
actions: ['Find and select command', 'Initialize arguments to submit'],
|
|
|
|
},
|
2024-09-09 19:59:36 +03:00
|
|
|
},
|
|
|
|
})
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
|
|
|
|
function sortCommands(a: Command, b: Command) {
|
2024-07-12 17:48:38 -04:00
|
|
|
if (b.groupId === 'auth' && !(a.groupId === 'auth')) return -2
|
|
|
|
if (a.groupId === 'auth' && !(b.groupId === 'auth')) return 2
|
|
|
|
if (b.groupId === 'settings' && !(a.groupId === 'settings')) return -1
|
|
|
|
if (a.groupId === 'settings' && !(b.groupId === 'settings')) return 1
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
return a.name.localeCompare(b.name)
|
|
|
|
}
|