Chore: separate out projectMachine from Home route (#4109)
* Rename `homeMachine` and accessories to `projectsMachine` * Separate out `/home` route from `projectsMachine` * Add logic to navigate out from deleted or renamed project * Show a warning in the command palette for deleting a project * Make it navigate when you create a project * Update "New project" button to use command bar flow Closes #2585 * More explicit warning message text * Make projects watching code not run in web * Tests first version: nested loops * Tests second version: flattened * Remove console logs * Fix tsc * @jtran feedback, use the type guard util * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Fix tests that relied on one-click, no-navigation project creation * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)" This reverts commit7545b61b49. * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)" This reverts commit3d2e48732c. * Add a mask to the state indicator to client-side scale test * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Fix lint * Fix tsc * Fix a couple stray tests that still relied on the old way of creating projects * De-flake another text that could be thrown off by toast-based selectors * FMT * Dumb test error because I was rushing * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Ahhh more flaky toasts, they're everywhere! * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Re-run CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Re-run CI * Fix one test added since this PR was made * Fix a few tests that failed due to changes since PR was made * Prevent double selector issue in Ubuntu test * Prevent *a different* double selector issue --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
		@ -1,7 +1,8 @@
 | 
			
		||||
import { CommandBarOverwriteWarning } from 'components/CommandBarOverwriteWarning'
 | 
			
		||||
import { StateMachineCommandSetConfig } from 'lib/commandTypes'
 | 
			
		||||
import { homeMachine } from 'machines/homeMachine'
 | 
			
		||||
import { projectsMachine } from 'machines/projectsMachine'
 | 
			
		||||
 | 
			
		||||
export type HomeCommandSchema = {
 | 
			
		||||
export type ProjectsCommandSchema = {
 | 
			
		||||
  'Read projects': {}
 | 
			
		||||
  'Create project': {
 | 
			
		||||
    name: string
 | 
			
		||||
@ -18,9 +19,9 @@ export type HomeCommandSchema = {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const homeCommandBarConfig: StateMachineCommandSetConfig<
 | 
			
		||||
  typeof homeMachine,
 | 
			
		||||
  HomeCommandSchema
 | 
			
		||||
export const projectsCommandBarConfig: StateMachineCommandSetConfig<
 | 
			
		||||
  typeof projectsMachine,
 | 
			
		||||
  ProjectsCommandSchema
 | 
			
		||||
> = {
 | 
			
		||||
  'Open project': {
 | 
			
		||||
    icon: 'arrowRight',
 | 
			
		||||
@ -53,6 +54,11 @@ export const homeCommandBarConfig: StateMachineCommandSetConfig<
 | 
			
		||||
    icon: 'close',
 | 
			
		||||
    description: 'Delete a project',
 | 
			
		||||
    needsReview: true,
 | 
			
		||||
    reviewMessage: ({ argumentsToSubmit }) =>
 | 
			
		||||
      CommandBarOverwriteWarning({
 | 
			
		||||
        heading: 'Are you sure you want to delete?',
 | 
			
		||||
        message: `This will permanently delete the project "${argumentsToSubmit.name}" and all its contents.`,
 | 
			
		||||
      }),
 | 
			
		||||
    args: {
 | 
			
		||||
      name: {
 | 
			
		||||
        inputType: 'options',
 | 
			
		||||
@ -111,6 +111,9 @@ export function createMachineCommand<
 | 
			
		||||
  if ('displayName' in commandConfig) {
 | 
			
		||||
    command.displayName = commandConfig.displayName
 | 
			
		||||
  }
 | 
			
		||||
  if ('reviewMessage' in commandConfig) {
 | 
			
		||||
    command.reviewMessage = commandConfig.reviewMessage
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return command
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user