Assemblies: UX improvements around foreign file imports (#6159)

* WIP: Add point-and-click Import for geometry
Will eventually fix #6120
Right now the whole loop is there but the codemod doesn't work yet

* Better pathToNOde, log on non-working cm dispatch call

* Add workaround to updateModelingState not working

* Back to updateModelingState with a skip flag

* Better todo

* Change working from Import to Insert, cleanups

* Sister command in kclCommands to populate file options

* Improve path selector

* Unsure: move importAstMod to kclCommands onSubmit 😶

* Add e2e test

* Clean up for review

* Add native file menu entry and test

* No await yo lint said so

* WIP: UX improvements around foreign file imports
Fixes #6152

* @lrev-Dev's suggestion to remove a comment

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>

* Update to scene.settled(cmdBar)

* Add partNNN default name for alias

* Lint

* Lint

* Fix unit tests

* Add sad path insert test
Thanks @Irev-Dev for the suggestion

* Add step insert test

* Lint

* Add test for second foreign import thru file tree click

* Add default value for local name alias

* Aligning tests

* Fix tests

* Add padding for filenames starting with a digit

---------

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
This commit is contained in:
Pierre Jacquier
2025-04-09 07:47:57 -04:00
committed by GitHub
parent ae9d8be4e4
commit e78100eaac
12 changed files with 454 additions and 104 deletions

View File

@ -1,6 +1,7 @@
import type { SourceRange } from '@rust/kcl-lib/bindings/SourceRange'
import { topLevelRange } from '@src/lang/util'
import {
getInVariableCase,
hasDigitsLeftOfDecimal,
hasLeadingZero,
isClockwise,
@ -1308,3 +1309,24 @@ describe('testing isClockwise', () => {
expect(isClockwise(counterClockwiseTriangle)).toBe(true)
})
})
describe('testing getInVariableCase', () => {
it('properly parses cylinder into cylinder', () => {
expect(getInVariableCase('cylinder')).toBe('cylinder')
})
it('properly parses my-ugly_Cased_Part123 into myUglyCasedPart', () => {
expect(getInVariableCase('my-ugly_Cased_Part123')).toBe(
'myUglyCasedPart123'
)
})
it('properly parses PascalCase into pascalCase', () => {
expect(getInVariableCase('PascalCase')).toBe('pascalCase')
})
it('properly parses my/File/Path into myFilePath', () => {
expect(getInVariableCase('my/File/Path')).toBe('myFilePath')
})
it('properly parses prefixes 1120t74-pipe.step', () => {
expect(getInVariableCase('1120t74-pipe')).toBe('m1120T74Pipe')
expect(getInVariableCase('1120t74-pipe', 'p')).toBe('p1120T74Pipe')
})
})