* 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 * Add menu item to share link to file * Forward query params while redirecting to /home or /file * Add (broken) event logic and command triggering logic * 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) * Side quest: Only register commands once, power their disabled status while selecting commands via optional actor * Get query-triggered command working in browser too * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Tests always run on localhost, don't expect the prod origin * rerun CI * wip * wip * Everything's pretty much done but url.zoo.dev has been broken and we need to think about how to test reliably * Merge branch 'main' into franknoirot/4088/create-file-url * Add useCreateFileLinkQuery on Home page * Get primary user flow working on desktop * Rework to open browser app first, then send along to the desktop app if asked * Styling updates to OpenInDesktopAppHandler * Clean up unecessary file * Merge branch 'main' into franknoirot/4088/create-file-url * Separate creating `createFileUrl` and shortlink so it is unit testable * Add E2E test for importing file from URL * Add a couple component tests for OpenInDesktopAppHandler * Fix the "existing project" user flow * Add E2E test for "add to existing project" user flow * Undo mistaken or unecessary changes * Lints, fmt, tsc * Fix unit test * Fix broken rename and delete project commands Something about the `optionsFromContext` config no longer works with file I/O-related commands. I suspect this has to do with our read/write loop patching * Fix unit test, use kebab-case for url query param * Use dev urls everywhere when configured that way I think we were just using some constants that ended up returning bad values for dev, it seemed to return a working shortlink when I went through the flow. * Clean up unneeded PROD_TOKEN * Fix browser command flow, because we had made the projectMachine desktop-only on main * Make the test executor a bit more patient (#5004) * Fix so that all artifact commands are returned regardless of caching (#5005) * Fix so that all artifact commands are returned regardless of caching * Add some more docs and fix up old ones * Add new lint to disallow use of confusing isNaN (#4999) * Point-and-click Sweep (first PR) (#4989) * Refactor 'Delete selection' as actor Will fix #4662 * WIP logging * WIP: working Solid3dGetExtrusionFaceInfo for loft * Working wall deletion of loft * Add offset plane deletion * Add feature tree deletion of shell * Clean up * Revert "Clean up" This reverts commit214763cc2b
. * Clean up rust changes, taking the sketch with the most paths * Working cap selection and deletion * Clean up * Add test for loft and offset plane deletion via selection * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-macos-8-cores) * Set reenter: false as it was originally * Passing test * Add shell deletion via feature tree test * Revert the migration to promise actor * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Trigger CI * Use cmd.id as solid_id after latest engine merge * Add feature tree deletion of offset plane and fix lint * Add feature tree deletion of loft * Clean up * Better comment * Lint fix * Remove sketch sorting * WIP: sweep point-and-click * Working sweep * Add test * Make sweep a development command * Fix tsc error * Clean up for review --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Upgrade typescript-eslint from 5.62.0 to 8.19.1 and remove eslint-config-react-app (#5006) * Fix lost lints and add new ones (#5011) * Add eslint-plugin-jsx-a11y dependency * Add jsx-a11y lint * Add eslint-plugin-react-hooks dependency * Add react hooks lints * Ignore new react hooks lint in tests * Add eslint-plugin-testing-library dependency * Add testing-library lint * Fix yarn lint to use all files recursively * Developer workflow: added auto generated workspace file from vitest extension in vscode (#4997) * chore: added auto generated workspace file from vitest extension in vscode * fix: auto fmt fixes * Change Dependabot PRs to always be made on Mondays (#5025) * Add packages to Dependabot updates (#5024) * Bump @lezer/generator from 1.7.1 to 1.7.2 (#5018) Bumps [@lezer/generator](https://github.com/lezer-parser/generator) from 1.7.1 to 1.7.2. - [Changelog](https://github.com/lezer-parser/generator/blob/main/CHANGELOG.md) - [Commits](https://github.com/lezer-parser/generator/compare/1.7.1...1.7.2) --- updated-dependencies: - dependency-name: "@lezer/generator" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump handlebars from 6.2.0 to 6.3.0 in /src/wasm-lib (#5012) Bumps [handlebars](https://github.com/sunng87/handlebars-rust) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/sunng87/handlebars-rust/releases) - [Changelog](https://github.com/sunng87/handlebars-rust/blob/master/CHANGELOG.md) - [Commits](https://github.com/sunng87/handlebars-rust/compare/v6.2.0...v6.3.0) --- updated-dependencies: - dependency-name: handlebars dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump syn from 2.0.95 to 2.0.96 in /src/wasm-lib (#5015) Bumps [syn](https://github.com/dtolnay/syn) from 2.0.95 to 2.0.96. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/2.0.95...2.0.96) --- updated-dependencies: - dependency-name: syn dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix artifact types to be more accurate (#5022) * Fix Cargo.lock to not have changes (#5034) * Upgrade all wasm-bindgen dependencies together (#5037) * Disable auto-updater on non-versioned builds (#5042) * turns on helix from edge (#5036) * updates for new lib Signed-off-by: Jess Frazelle <github@jessfraz.com> * autocomplete Signed-off-by: Jess Frazelle <github@jessfraz.com> * bump version Signed-off-by: Jess Frazelle <github@jessfraz.com> * bump all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * new samples Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> * ci: Add yarn test of packages/codemirror-lang-kcl (#5035) * ci: Add yarn test of packages/codemirror-lang-kcl * Fix CI error running tests * Fix postcss config error * Bump xstate from 5.17.4 to 5.19.2 (#5027) * Hook up chamfer UI with AST-mod (#4694) * button * config * hook up with ast * cmd bar test * button states fix and test * little naming fix * xState action to actor * remove button state test updates * fixture-based approach * nightly Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com> * Update src/lib/toolbar.ts Co-authored-by: Frank Noirot <frank@zoo.dev> --------- Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com> Co-authored-by: Frank Noirot <frank@zoo.dev> * Remove Redundant Fillet Button State Test (#5009) delete obsolete test * Bump @types/node from 20.14.9 to 22.10.6 in /packages/codemirror-lsp-client (#5041) * custom axis and origin example for helix (#5057) * custom axis and origin for helix Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * empty --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Bump typescript from 5.7.2 to 5.7.3 (#5021) Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.7.2 to 5.7.3. - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/microsoft/TypeScript/compare/v5.7.2...v5.7.3) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Refactor: break out `copyFileShareLink` into standalone function * Add "Share file" to command palette * Update dumb use of site URL instead of prod app URL * fmt * @lf94 nit * @pierremtb spinner feedback * Hide share link command and disable menu item for now * Just comment out the command config for now --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: 49lf <ircsurfer33@gmail.com> Co-authored-by: Adam Sunderland <iterion@gmail.com> Co-authored-by: Adam Sunderland <adam@kittycad.io> Co-authored-by: Jonathan Tran <jonnytran@gmail.com> Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com> Co-authored-by: Kevin Nadro <nadr0@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com> Co-authored-by: max <margorskyi@gmail.com>
202 lines
6.1 KiB
TypeScript
202 lines
6.1 KiB
TypeScript
import { ActionFunction, LoaderFunction, redirect } from 'react-router-dom'
|
|
import { FileLoaderData, HomeLoaderData, IndexLoaderData } from './types'
|
|
import { getProjectMetaByRouteId, PATHS } from './paths'
|
|
import { isDesktop } from './isDesktop'
|
|
import { BROWSER_PATH } from 'lib/paths'
|
|
import {
|
|
BROWSER_FILE_NAME,
|
|
BROWSER_PROJECT_NAME,
|
|
PROJECT_ENTRYPOINT,
|
|
} from 'lib/constants'
|
|
import { loadAndValidateSettings } from './settings/settingsUtils'
|
|
import makeUrlPathRelative from './makeUrlPathRelative'
|
|
import { codeManager } from 'lib/singletons'
|
|
import { fileSystemManager } from 'lang/std/fileSystemManager'
|
|
import { getProjectInfo } from './desktop'
|
|
import { createSettings } from './settings/initialSettings'
|
|
import { normalizeLineEndings } from 'lib/codeEditor'
|
|
import { OnboardingStatus } from 'wasm-lib/kcl/bindings/OnboardingStatus'
|
|
|
|
// The root loader simply resolves the settings and any errors that
|
|
// occurred during the settings load
|
|
export const settingsLoader: LoaderFunction = async ({
|
|
params,
|
|
}): Promise<
|
|
ReturnType<typeof createSettings> | ReturnType<typeof redirect>
|
|
> => {
|
|
let { settings, configuration } = await loadAndValidateSettings()
|
|
|
|
// I don't love that we have to read the settings again here,
|
|
// but we need to get the project path to load the project settings
|
|
if (params.id) {
|
|
const projectPathData = await getProjectMetaByRouteId(
|
|
params.id,
|
|
configuration
|
|
)
|
|
if (projectPathData) {
|
|
const { projectPath } = projectPathData
|
|
const { settings: s } = await loadAndValidateSettings(
|
|
projectPath || undefined
|
|
)
|
|
return s
|
|
}
|
|
}
|
|
|
|
return settings
|
|
}
|
|
|
|
export const telemetryLoader: LoaderFunction = async ({
|
|
params,
|
|
}): Promise<null> => {
|
|
return null
|
|
}
|
|
|
|
// Redirect users to the appropriate onboarding page if they haven't completed it
|
|
export const onboardingRedirectLoader: ActionFunction = async (args) => {
|
|
const { settings } = await loadAndValidateSettings()
|
|
const onboardingStatus: OnboardingStatus =
|
|
settings.app.onboardingStatus.current || ''
|
|
const notEnRouteToOnboarding = !args.request.url.includes(
|
|
PATHS.ONBOARDING.INDEX
|
|
)
|
|
// '' is the initial state, 'completed' and 'dismissed' are the final states
|
|
const hasValidOnboardingStatus =
|
|
onboardingStatus.length === 0 ||
|
|
!(onboardingStatus === 'completed' || onboardingStatus === 'dismissed')
|
|
const shouldRedirectToOnboarding =
|
|
notEnRouteToOnboarding && hasValidOnboardingStatus
|
|
|
|
if (shouldRedirectToOnboarding) {
|
|
return redirect(
|
|
makeUrlPathRelative(PATHS.ONBOARDING.INDEX) + onboardingStatus.slice(1)
|
|
)
|
|
}
|
|
|
|
return settingsLoader(args)
|
|
}
|
|
|
|
export const fileLoader: LoaderFunction = async (
|
|
routerData
|
|
): Promise<FileLoaderData | Response> => {
|
|
const { params } = routerData
|
|
let { configuration } = await loadAndValidateSettings()
|
|
|
|
const projectPathData = await getProjectMetaByRouteId(
|
|
params.id,
|
|
configuration
|
|
)
|
|
const isBrowserProject = params.id === decodeURIComponent(BROWSER_PATH)
|
|
|
|
let code = ''
|
|
|
|
if (!isBrowserProject && projectPathData) {
|
|
const { projectName, projectPath, currentFileName, currentFilePath } =
|
|
projectPathData
|
|
|
|
const urlObj = new URL(routerData.request.url)
|
|
|
|
if (!urlObj.pathname.endsWith('/settings')) {
|
|
const fallbackFile = isDesktop()
|
|
? (await getProjectInfo(projectPath)).default_file
|
|
: ''
|
|
let fileExists = isDesktop()
|
|
if (currentFilePath && fileExists) {
|
|
try {
|
|
await window.electron.stat(currentFilePath)
|
|
} catch (e) {
|
|
if (e === 'ENOENT') {
|
|
fileExists = false
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!fileExists || !currentFileName || !currentFilePath || !projectName) {
|
|
return redirect(
|
|
`${PATHS.FILE}/${encodeURIComponent(
|
|
isDesktop() ? fallbackFile : params.id + '/' + PROJECT_ENTRYPOINT
|
|
)}${new URL(routerData.request.url).search || ''}`
|
|
)
|
|
}
|
|
|
|
code = await window.electron.readFile(currentFilePath, {
|
|
encoding: 'utf-8',
|
|
})
|
|
code = normalizeLineEndings(code)
|
|
|
|
// If persistCode in localStorage is present, it'll persist that code
|
|
// through *anything*. INTENDED FOR TESTS.
|
|
if (window.electron.process.env.IS_PLAYWRIGHT) {
|
|
code = codeManager.localStoragePersistCode() || code
|
|
}
|
|
|
|
// Update both the state and the editor's code.
|
|
// We explicitly do not write to the file here since we are loading from
|
|
// the file system and not the editor.
|
|
codeManager.updateCurrentFilePath(currentFilePath)
|
|
// We pass true on the end here to clear the code editor history.
|
|
// This way undo and redo are not super weird when opening new files.
|
|
codeManager.updateCodeStateEditor(code, true)
|
|
}
|
|
|
|
// Set the file system manager to the project path
|
|
// So that WASM gets an updated path for operations
|
|
fileSystemManager.dir = projectPath
|
|
|
|
const defaultProjectData = {
|
|
name: projectName || 'unnamed',
|
|
path: projectPath,
|
|
children: [],
|
|
kcl_file_count: 0,
|
|
directory_count: 0,
|
|
metadata: null,
|
|
default_file: projectPath,
|
|
}
|
|
|
|
const maybeProjectInfo = isDesktop()
|
|
? await getProjectInfo(projectPath)
|
|
: null
|
|
|
|
const projectData: IndexLoaderData = {
|
|
code,
|
|
project: maybeProjectInfo ?? defaultProjectData,
|
|
file: {
|
|
name: currentFileName || '',
|
|
path: currentFilePath || '',
|
|
children: [],
|
|
},
|
|
}
|
|
|
|
return {
|
|
...projectData,
|
|
}
|
|
}
|
|
|
|
return {
|
|
code,
|
|
project: {
|
|
name: BROWSER_PROJECT_NAME,
|
|
path: '/' + BROWSER_PROJECT_NAME,
|
|
children: [],
|
|
},
|
|
file: {
|
|
name: BROWSER_FILE_NAME,
|
|
path: decodeURIComponent(BROWSER_PATH),
|
|
children: [],
|
|
},
|
|
}
|
|
}
|
|
|
|
// Loads the settings and by extension the projects in the default directory
|
|
// and returns them to the Home route, along with any errors that occurred
|
|
export const homeLoader: LoaderFunction = async ({
|
|
request,
|
|
}): Promise<HomeLoaderData | Response> => {
|
|
const url = new URL(request.url)
|
|
if (!isDesktop()) {
|
|
return redirect(
|
|
PATHS.FILE + '/%2F' + BROWSER_PROJECT_NAME + (url.search || '')
|
|
)
|
|
}
|
|
return {}
|
|
}
|