2023-08-28 20:31:49 -04:00
|
|
|
import { assign, createMachine } 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 { HomeCommandSchema } from 'lib/commandBarConfigs/homeCommandConfig'
|
2024-04-25 00:13:09 -07:00
|
|
|
import { Project } from 'wasm-lib/kcl/bindings/Project'
|
2023-08-28 20:31:49 -04:00
|
|
|
|
|
|
|
export const homeMachine = createMachine(
|
|
|
|
{
|
|
|
|
/** @xstate-layout N4IgpgJg5mDOIC5QAkD2BbMACdBDAxgBYCWAd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MiSmvQ-HwKcnL6WA6FOf2k3mESMRDA4RpUm4U4qf6gSEt0QIvvqfjOCaiyrtF6zZPQXWQ+GWFlUEsbmNMf1TV9NLeXDcqRIySnNaaYPEzC5M9vl-b+IyFCjupryPF9jKWP5Kks-cbMWLERHRNt0LFntkgU2NLk4dqsz43YsTK++Kk2C+MbTOOcxzOMrhqzFxTgZ1Qba1dd6BUE1jGsLMxxK9KlDNqm3tMLUQvqYlgO5QhlsTubsFXesTTUuPTfHExshDS0RftRftGgEnTZtHbX9Zr+QJ-2S4Y3qnmTC+4tMyp1EfeOnmeQqdOhyXQrFOXXCV1hCkmLDOnBJYvRRDSsyRzGjiKj0lKdAkANAA */
|
|
|
|
id: 'Home machine',
|
|
|
|
|
|
|
|
initial: 'Reading projects',
|
|
|
|
|
|
|
|
context: {
|
2024-04-25 00:13:09 -07:00
|
|
|
projects: [] as Project[],
|
2023-08-28 20:31:49 -04:00
|
|
|
defaultProjectName: '',
|
|
|
|
defaultDirectory: '',
|
|
|
|
},
|
|
|
|
|
|
|
|
on: {
|
|
|
|
assign: {
|
|
|
|
actions: assign((_, event) => ({
|
|
|
|
...event.data,
|
|
|
|
})),
|
|
|
|
target: '.Reading projects',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
states: {
|
|
|
|
'Has no projects': {
|
|
|
|
on: {
|
|
|
|
'Create project': {
|
|
|
|
target: 'Creating project',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Has projects': {
|
|
|
|
on: {
|
|
|
|
'Rename project': {
|
|
|
|
target: 'Renaming project',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Create project': {
|
|
|
|
target: 'Creating project',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Delete project': {
|
|
|
|
target: 'Deleting project',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Open project': {
|
|
|
|
target: 'Opening project',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Creating project': {
|
|
|
|
invoke: {
|
|
|
|
id: 'create-project',
|
|
|
|
src: 'createProject',
|
|
|
|
onDone: [
|
|
|
|
{
|
|
|
|
target: 'Reading projects',
|
|
|
|
actions: ['toastSuccess'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onError: [
|
|
|
|
{
|
|
|
|
target: 'Reading projects',
|
|
|
|
actions: ['toastError'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Renaming project': {
|
|
|
|
invoke: {
|
|
|
|
id: 'rename-project',
|
|
|
|
src: 'renameProject',
|
|
|
|
onDone: [
|
|
|
|
{
|
|
|
|
target: '#Home machine.Reading projects',
|
|
|
|
actions: ['toastSuccess'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onError: [
|
|
|
|
{
|
|
|
|
target: '#Home machine.Reading projects',
|
|
|
|
actions: ['toastError'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Deleting project': {
|
|
|
|
invoke: {
|
|
|
|
id: 'delete-project',
|
|
|
|
src: 'deleteProject',
|
|
|
|
onDone: [
|
|
|
|
{
|
|
|
|
actions: ['toastSuccess'],
|
|
|
|
target: '#Home machine.Reading projects',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onError: {
|
|
|
|
actions: ['toastError'],
|
|
|
|
target: '#Home machine.Has projects',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Reading projects': {
|
|
|
|
invoke: {
|
|
|
|
id: 'read-projects',
|
|
|
|
src: 'readProjects',
|
|
|
|
onDone: [
|
|
|
|
{
|
|
|
|
cond: 'Has at least 1 project',
|
|
|
|
target: 'Has projects',
|
|
|
|
actions: ['setProjects'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: 'Has no projects',
|
|
|
|
actions: ['setProjects'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onError: [
|
|
|
|
{
|
|
|
|
target: 'Has no projects',
|
|
|
|
actions: ['toastError'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Opening project': {
|
|
|
|
entry: ['navigateToProject'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
schema: {
|
|
|
|
events: {} as
|
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
|
|
|
| { type: 'Open project'; data: HomeCommandSchema['Open project'] }
|
|
|
|
| { type: 'Rename project'; data: HomeCommandSchema['Rename project'] }
|
|
|
|
| { type: 'Create project'; data: HomeCommandSchema['Create project'] }
|
|
|
|
| { type: 'Delete project'; data: HomeCommandSchema['Delete project'] }
|
2023-08-28 20:31:49 -04:00
|
|
|
| { type: 'navigate'; data: { name: string } }
|
|
|
|
| {
|
|
|
|
type: 'done.invoke.read-projects'
|
2024-04-25 00:13:09 -07:00
|
|
|
data: Project[]
|
2023-08-28 20:31:49 -04:00
|
|
|
}
|
|
|
|
| { type: 'assign'; data: { [key: string]: any } },
|
|
|
|
},
|
|
|
|
|
|
|
|
predictableActionArguments: true,
|
|
|
|
preserveActionOrder: true,
|
|
|
|
tsTypes: {} as import('./homeMachine.typegen').Typegen0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actions: {
|
|
|
|
setProjects: assign((_, event) => {
|
2024-04-25 00:13:09 -07:00
|
|
|
return { projects: event.data as Project[] }
|
2023-08-28 20:31:49 -04:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|