Allow point-and-click Insert to suggest nested files (#7130)
* fix: saving off code * fix: saving off progress * chore: implemented kcl sample assembly unique sub dir creation * fix: removing testing console logs * fix: cleaning up old comment * fix: add to file always does subdir/main.kcl now for single files * fix: auto fmt * fix: delete project and folder from ttc * fix: fixed deleting projects and subdirs * fix: if statement logic fixed for deleting project or subdir * fix: TTC isProjectNew makes main.kcl not a subdir. * fix: fixing e2e test * fix: this should pass now * pierremtb/make-insert-take-over-the-import-world * Add test that doesn't work locally yet :( * Fix test 🤦 * Change splice for push * Fix up windows path --------- Co-authored-by: Kevin Nadro <kevin@zoo.dev> Co-authored-by: Kevin Nadro <nadr0@users.noreply.github.com>
This commit is contained in:
@ -70,22 +70,28 @@ test.describe('Point-and-click assemblies tests', () => {
|
|||||||
await test.step('Setup parts and expect empty assembly scene', async () => {
|
await test.step('Setup parts and expect empty assembly scene', async () => {
|
||||||
const projectName = 'assembly'
|
const projectName = 'assembly'
|
||||||
await context.folderSetupFn(async (dir) => {
|
await context.folderSetupFn(async (dir) => {
|
||||||
const bracketDir = path.join(dir, projectName)
|
const projDir = path.join(dir, projectName)
|
||||||
await fsp.mkdir(bracketDir, { recursive: true })
|
const nestedProjDir = path.join(dir, projectName, 'nested', 'twice')
|
||||||
|
await fsp.mkdir(projDir, { recursive: true })
|
||||||
|
await fsp.mkdir(nestedProjDir, { recursive: true })
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fsp.copyFile(
|
fsp.copyFile(
|
||||||
executorInputPath('cylinder.kcl'),
|
executorInputPath('cylinder.kcl'),
|
||||||
path.join(bracketDir, 'cylinder.kcl')
|
path.join(projDir, 'cylinder.kcl')
|
||||||
|
),
|
||||||
|
fsp.copyFile(
|
||||||
|
executorInputPath('cylinder.kcl'),
|
||||||
|
path.join(nestedProjDir, 'main.kcl')
|
||||||
),
|
),
|
||||||
fsp.copyFile(
|
fsp.copyFile(
|
||||||
executorInputPath('e2e-can-sketch-on-chamfer.kcl'),
|
executorInputPath('e2e-can-sketch-on-chamfer.kcl'),
|
||||||
path.join(bracketDir, 'bracket.kcl')
|
path.join(projDir, 'bracket.kcl')
|
||||||
),
|
),
|
||||||
fsp.copyFile(
|
fsp.copyFile(
|
||||||
testsInputPath('cube.step'),
|
testsInputPath('cube.step'),
|
||||||
path.join(bracketDir, 'cube.step')
|
path.join(projDir, 'cube.step')
|
||||||
),
|
),
|
||||||
fsp.writeFile(path.join(bracketDir, 'main.kcl'), ''),
|
fsp.writeFile(path.join(projDir, 'main.kcl'), ''),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
await page.setBodyDimensions({ width: 1000, height: 500 })
|
await page.setBodyDimensions({ width: 1000, height: 500 })
|
||||||
@ -167,6 +173,25 @@ test.describe('Point-and-click assemblies tests', () => {
|
|||||||
await expect(
|
await expect(
|
||||||
page.getByText('This file is already imported')
|
page.getByText('This file is already imported')
|
||||||
).toBeVisible()
|
).toBeVisible()
|
||||||
|
await cmdBar.closeCmdBar()
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Insert a nested kcl part', async () => {
|
||||||
|
await insertPartIntoAssembly(
|
||||||
|
'nested/twice/main.kcl',
|
||||||
|
'main',
|
||||||
|
toolbar,
|
||||||
|
cmdBar,
|
||||||
|
page
|
||||||
|
)
|
||||||
|
await toolbar.openPane('code')
|
||||||
|
await page.waitForTimeout(10000)
|
||||||
|
await editor.expectEditor.toContain(
|
||||||
|
`
|
||||||
|
import "nested/twice/main.kcl" as main
|
||||||
|
`,
|
||||||
|
{ shouldNormalise: true }
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -441,39 +441,46 @@ export const FileMachineProvider = ({
|
|||||||
)
|
)
|
||||||
useMenuListener(cb)
|
useMenuListener(cb)
|
||||||
|
|
||||||
const kclCommandMemo = useMemo(
|
const kclCommandMemo = useMemo(() => {
|
||||||
() =>
|
const providedOptions = []
|
||||||
kclCommands({
|
if (isDesktop() && project?.children && file?.path) {
|
||||||
authToken: token ?? '',
|
const projectPath = project.path
|
||||||
projectData,
|
const filePath = file.path
|
||||||
settings: {
|
let children = project.children
|
||||||
defaultUnit:
|
while (children.length > 0) {
|
||||||
settings.modeling.defaultUnit.current ??
|
const v = children.pop()
|
||||||
DEFAULT_DEFAULT_LENGTH_UNIT,
|
if (!v) {
|
||||||
},
|
continue
|
||||||
specialPropsForInsertCommand: {
|
}
|
||||||
providedOptions: (isDesktop() && project?.children
|
|
||||||
? project.children
|
if (v.children) {
|
||||||
: []
|
children.push(...v.children)
|
||||||
).flatMap((v) => {
|
continue
|
||||||
// TODO: add support for full tree traversal when KCL support subdir imports
|
}
|
||||||
const relativeFilePath = v.path.replace(
|
|
||||||
project?.path + window.electron.sep,
|
const relativeFilePath = v.path.replace(
|
||||||
''
|
projectPath + window.electron.sep,
|
||||||
)
|
''
|
||||||
const isDirectory = v.children
|
)
|
||||||
const isCurrentFile = v.path === file?.path
|
const isCurrentFile = v.path === filePath
|
||||||
return isDirectory || isCurrentFile
|
if (!isCurrentFile) {
|
||||||
? []
|
providedOptions.push({
|
||||||
: {
|
name: relativeFilePath.replaceAll(window.electron.sep, '/'),
|
||||||
name: relativeFilePath,
|
value: relativeFilePath.replaceAll(window.electron.sep, '/'),
|
||||||
value: relativeFilePath,
|
})
|
||||||
}
|
}
|
||||||
}),
|
}
|
||||||
},
|
}
|
||||||
}),
|
return kclCommands({
|
||||||
[codeManager, kclManager, send, project, file]
|
authToken: token ?? '',
|
||||||
)
|
projectData,
|
||||||
|
settings: {
|
||||||
|
defaultUnit:
|
||||||
|
settings.modeling.defaultUnit.current ?? DEFAULT_DEFAULT_LENGTH_UNIT,
|
||||||
|
},
|
||||||
|
specialPropsForInsertCommand: { providedOptions },
|
||||||
|
})
|
||||||
|
}, [codeManager, kclManager, send, project, file])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
commandBarActor.send({
|
commandBarActor.send({
|
||||||
|
Reference in New Issue
Block a user