diff --git a/src/components/DownloadAppBanner.tsx b/src/components/DownloadAppBanner.tsx index 0e4d8b159..3c2391611 100644 --- a/src/components/DownloadAppBanner.tsx +++ b/src/components/DownloadAppBanner.tsx @@ -2,11 +2,15 @@ import { Dialog } from '@headlessui/react' import { ActionButton } from './ActionButton' import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext' import { useState } from 'react' +import { useSearchParams } from 'react-router-dom' +import { CREATE_FILE_URL_PARAM } from 'lib/constants' const DownloadAppBanner = () => { + const [searchParams] = useSearchParams() + const hasCreateFileParam = searchParams.has(CREATE_FILE_URL_PARAM) const { settings } = useSettingsAuthContext() const [isBannerDismissed, setIsBannerDismissed] = useState( - settings.context.app.dismissWebBanner.current + settings.context.app.dismissWebBanner.current || hasCreateFileParam ) return ( diff --git a/src/components/ProjectSidebarMenu.tsx b/src/components/ProjectSidebarMenu.tsx index 3004eb9cc..3e3a52350 100644 --- a/src/components/ProjectSidebarMenu.tsx +++ b/src/components/ProjectSidebarMenu.tsx @@ -104,7 +104,7 @@ function ProjectMenuPopover({ const location = useLocation() const navigate = useNavigate() const filePath = useAbsoluteFilePath() - const { settings } = useSettingsAuthContext() + useSettingsAuthContext() const token = useToken() const machineManager = useContext(MachineManagerContext) const commands = useSelector(commandBarActor, commandsSelector) @@ -193,14 +193,13 @@ function ProjectMenuPopover({ { id: 'share-link', Element: 'button', - children: 'Share link to file', - disabled: IS_NIGHTLY_OR_DEBUG || !findCommand(shareCommandInfo), + children: 'Share current part (via Zoo link)', + disabled: !(IS_NIGHTLY_OR_DEBUG && findCommand(shareCommandInfo)), onClick: async () => { await copyFileShareLink({ token: token ?? '', code: codeManager.code, name: project?.name || '', - units: settings.context.modeling.defaultUnit.current, }) }, }, @@ -263,7 +262,7 @@ function ProjectMenuPopover({ as={Fragment} > diff --git a/src/components/ProjectsContextProvider.tsx b/src/components/ProjectsContextProvider.tsx index 65d4348fb..8603031d3 100644 --- a/src/components/ProjectsContextProvider.tsx +++ b/src/components/ProjectsContextProvider.tsx @@ -30,15 +30,7 @@ import { FILE_EXT, PROJECT_ENTRYPOINT, } from 'lib/constants' -import { DeepPartial } from 'lib/types' -import { Configuration } from 'wasm-lib/kcl/bindings/Configuration' -import { codeManager } from 'lib/singletons' -import { - loadAndValidateSettings, - projectConfigurationToSettingsPayload, - saveSettings, - setSettingsAtLevel, -} from 'lib/settings/settingsUtils' +import { codeManager, kclManager } from 'lib/singletons' import { Project } from 'lib/project' type MachineContext = { @@ -86,7 +78,7 @@ const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => { setSearchParams(searchParams) }, [searchParams, setSearchParams]) const { - settings: { context: settings, send: settingsSend }, + settings: { context: settings }, } = useSettingsAuthContext() const [state, send, actor] = useMachine( @@ -132,17 +124,10 @@ const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => { clearImportSearchParams() codeManager.updateCodeStateEditor(input.code || '') await codeManager.writeToFile() - - settingsSend({ - type: 'set.modeling.defaultUnit', - data: { - level: 'project', - value: input.units, - }, - }) + await kclManager.executeCode(true) return { - message: 'File and units overwritten successfully', + message: 'File overwritten successfully', fileName: input.name, projectName: '', } @@ -392,16 +377,6 @@ const ProjectsContextDesktop = ({ ? input.name : input.name + FILE_EXT let message = 'File created successfully' - const unitsConfiguration: DeepPartial = { - settings: { - project: { - directory: settings.app.projectDirectory.current, - }, - modeling: { - base_unit: input.units, - }, - }, - } const needsInterpolated = doesProjectNameNeedInterpolated(projectName) if (needsInterpolated) { @@ -414,28 +389,10 @@ const ProjectsContextDesktop = ({ // Create the project around the file if newProject if (input.method === 'newProject') { - await createNewProjectDirectory( - projectName, - input.code, - unitsConfiguration - ) + await createNewProjectDirectory(projectName, input.code) message = `Project "${projectName}" created successfully with link contents` } else { - let projectPath = window.electron.join( - settings.app.projectDirectory.current, - projectName - ) - message = `File "${fileName}" created successfully` - const existingConfiguration = await loadAndValidateSettings( - projectPath - ) - const settingsToSave = setSettingsAtLevel( - existingConfiguration.settings, - 'project', - projectConfigurationToSettingsPayload(unitsConfiguration) - ) - await saveSettings(settingsToSave, projectPath) } // Create the file diff --git a/src/hooks/useCreateFileLinkQueryWatcher.ts b/src/hooks/useCreateFileLinkQueryWatcher.ts index 4f70d977e..35b7a95ec 100644 --- a/src/hooks/useCreateFileLinkQueryWatcher.ts +++ b/src/hooks/useCreateFileLinkQueryWatcher.ts @@ -6,7 +6,6 @@ import { useSettingsAuthContext } from './useSettingsAuthContext' import { isDesktop } from 'lib/isDesktop' import { FileLinkParams } from 'lib/links' import { ProjectsCommandSchema } from 'lib/commandBarConfigs/projectsCommandConfig' -import { baseUnitsUnion } from 'lib/settings/settingsTypes' // For initializing the command arguments, we actually want `method` to be undefined // so that we don't skip it in the command palette. @@ -37,13 +36,7 @@ export function useCreateFileLinkQuery( code: base64ToString( decodeURIComponent(searchParams.get('code') ?? '') ), - name: searchParams.get('name') ?? DEFAULT_FILE_NAME, - - units: - (baseUnitsUnion.find((unit) => searchParams.get('units') === unit) || - settings.context.modeling.defaultUnit.default) ?? - settings.context.modeling.defaultUnit.current, } const argDefaultValues: CreateFileSchemaMethodOptional = { @@ -55,7 +48,6 @@ export function useCreateFileLinkQuery( ? settings.context.projects.defaultProjectName.current : DEFAULT_FILE_NAME, code: params.code || '', - units: params.units, method: isDesktop() ? undefined : 'existingProject', } diff --git a/src/lib/commandBarConfigs/projectsCommandConfig.ts b/src/lib/commandBarConfigs/projectsCommandConfig.ts index 862870b74..5141ce961 100644 --- a/src/lib/commandBarConfigs/projectsCommandConfig.ts +++ b/src/lib/commandBarConfigs/projectsCommandConfig.ts @@ -1,8 +1,6 @@ -import { UnitLength_type } from '@kittycad/lib/dist/types/src/models' import { CommandBarOverwriteWarning } from 'components/CommandBarOverwriteWarning' import { StateMachineCommandSetConfig } from 'lib/commandTypes' import { isDesktop } from 'lib/isDesktop' -import { baseUnitLabels, baseUnitsUnion } from 'lib/settings/settingsTypes' import { projectsMachine } from 'machines/projectsMachine' export type ProjectsCommandSchema = { @@ -23,7 +21,6 @@ export type ProjectsCommandSchema = { 'Import file from URL': { name: string code?: string - units: UnitLength_type method: 'newProject' | 'existingProject' projectName?: string } @@ -157,15 +154,6 @@ export const projectsCommandBarConfig: StateMachineCommandSetConfig< return `${lineCount} line${lineCount === 1 ? '' : 's'}` }, }, - units: { - inputType: 'options', - required: false, - skip: true, - options: baseUnitsUnion.map((unit) => ({ - name: baseUnitLabels[unit], - value: unit, - })), - }, }, reviewMessage(commandBarContext) { return isDesktop() diff --git a/src/lib/kclCommands.ts b/src/lib/kclCommands.ts index 72430fb5f..b233595ed 100644 --- a/src/lib/kclCommands.ts +++ b/src/lib/kclCommands.ts @@ -136,7 +136,7 @@ export function kclCommands(commandProps: KclCommandConfig): Command[] { }, { name: 'share-file-link', - displayName: 'Share file', + displayName: 'Share current part (via Zoo link)', hide: IS_NIGHTLY_OR_DEBUG ? undefined : 'desktop', description: 'Create a link that contains a copy of the current file.', groupId: 'code', @@ -147,7 +147,6 @@ export function kclCommands(commandProps: KclCommandConfig): Command[] { token: commandProps.authToken, code: codeManager.code, name: commandProps.projectData.project?.name || '', - units: commandProps.settings.defaultUnit, }).catch(reportRejection) }, }, diff --git a/src/lib/links.test.ts b/src/lib/links.test.ts index c3606f602..a65dec09e 100644 --- a/src/lib/links.test.ts +++ b/src/lib/links.test.ts @@ -5,13 +5,12 @@ describe(`link creation tests`, () => { test(`createCreateFileUrl happy path`, async () => { const code = `extrusionDistance = 12` const name = `test` - const units = `mm` // Converted with external online tools const expectedEncodedCode = `ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D` - const expectedLink = `${VITE_KC_SITE_APP_URL}/?create-file=true&name=test&units=mm&code=${expectedEncodedCode}&ask-open-desktop=true` + const expectedLink = `${VITE_KC_SITE_APP_URL}/?create-file=true&name=test&code=${expectedEncodedCode}&ask-open-desktop=true` - const result = createCreateFileUrl({ code, name, units }) + const result = createCreateFileUrl({ code, name }) expect(result.toString()).toBe(expectedLink) }) }) diff --git a/src/lib/links.ts b/src/lib/links.ts index f24eb8286..2b31f46eb 100644 --- a/src/lib/links.ts +++ b/src/lib/links.ts @@ -1,4 +1,3 @@ -import { UnitLength_type } from '@kittycad/lib/dist/types/src/models' import { ASK_TO_OPEN_QUERY_PARAM, CREATE_FILE_URL_PARAM } from './constants' import { stringToBase64 } from './base64' import { VITE_KC_API_BASE_URL, VITE_KC_SITE_APP_URL } from 'env' @@ -7,7 +6,6 @@ import { err } from './trap' export interface FileLinkParams { code: string name: string - units: UnitLength_type } export async function copyFileShareLink( @@ -46,12 +44,11 @@ export async function copyFileShareLink( * With the additional step of asking the user if they want to * open the URL in the desktop app. */ -export function createCreateFileUrl({ code, name, units }: FileLinkParams) { +export function createCreateFileUrl({ code, name }: FileLinkParams) { let origin = VITE_KC_SITE_APP_URL const searchParams = new URLSearchParams({ [CREATE_FILE_URL_PARAM]: String(true), name, - units, code: stringToBase64(code), [ASK_TO_OPEN_QUERY_PARAM]: String(true), }) diff --git a/src/machines/projectsMachine.ts b/src/machines/projectsMachine.ts index 5f4b01562..f15f1490e 100644 --- a/src/machines/projectsMachine.ts +++ b/src/machines/projectsMachine.ts @@ -306,7 +306,6 @@ export const projectsMachine = setup({ return { code: '', name: '', - units: 'mm', method: 'existingProject', projects: context.projects, } @@ -314,7 +313,6 @@ export const projectsMachine = setup({ return { code: event.data.code || '', name: event.data.name, - units: event.data.units, method: event.data.method, projectName: event.data.projectName, projects: context.projects, diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index a89e2ac72..07b38ce60 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -32,7 +32,8 @@ export const PACKAGE_NAME = isDesktop() export const IS_NIGHTLY = PACKAGE_NAME.indexOf('-nightly') > -1 -export const IS_NIGHTLY_OR_DEBUG = IS_NIGHTLY || APP_VERSION === '0.0.0' +export const IS_NIGHTLY_OR_DEBUG = + IS_NIGHTLY || APP_VERSION === '0.0.0' || APP_VERSION === '11.22.33' export function getReleaseUrl(version: string = APP_VERSION) { return `https://github.com/KittyCAD/modeling-app/releases/tag/${