-
Notifications
You must be signed in to change notification settings - Fork 82
feature: Project Explorer update, first pass. #7656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… logic was not taking parent into account
@jacebrowning Whenever this gets reviewed and approved I'll need to disable these two tests I've disabled the |
@nadr0 OK, please create a GitHub issue to drop in the form to disable the tests. Or, if the "future" where we enable this is a long ways out, consider deleting the tests. They'll always be available in the Git history. |
Working through a code review in a bit, but here are a few initial UX thoughts @nadr0
|
src/lib/paths.ts
Outdated
/** | ||
* Don't pass a folder path, only files with extensions for best results. | ||
*/ | ||
export const alwaysEndFileWithEXT = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a slightly easier name would be enforceFileEXT
.
Also if ext' is null I would expect the function to return
filePathinstead of
null`. I see that null is checked agains in ProjectExplorer so that would need to be changed as well but maybe worth it? In the odd case of the file not having an extension, it could still be renamed without having an extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on who we want to have the burden of a check? This comes down to whether we support base cases?
const originalExt = getEXTWithPeriod(name)
const fileNameForcedWithOriginalExt = enforceFileEXT(
requestedName,
originalExt
)
if (!fileNameForcedWithOriginalExt) {
// TODO: OH NO!
return
}
I did this because these are paired together, when you try to get the originalExtension from something you may not get that extension so if you attempt to enforce it it could fail. That is why there is a null
check.
We really always want extensions in the codebase.
} catch (e) { | ||
console.error(e) | ||
} | ||
await window.electron.writeFile(input.requestedAbsolutePath, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think writeFile
can throw so maybe it's worth putting inside the try block as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already caught properly, within the systemIOMachine.ts
. Anything that is explicitly not try/catched will be caught and handled with the onError
workflow of the actor.
The reason why I try catch the thing above is if you window.electron.stat
something and it doesn't exist it will throw an error which is what we want. We want it to say "Yeah you don't have a file" to make sure we can then do the create file.
We don't always need to try/catch handle every statement since the parent workflow in the machine will handle the onError.
invoke: {
id: SystemIOMachineActors.createBlankFile,
src: SystemIOMachineActors.createBlankFile,
input: ({ context, event, self }) => {
assertEvent(event, SystemIOMachineEvents.createBlankFile)
return {
context,
requestedAbsolutePath: event.data.requestedAbsolutePath,
rootContext: self.system.get('root').getSnapshot().context,
}
},
onDone: {
target: SystemIOMachineStates.readingFolders,
actions: [SystemIOMachineActions.toastSuccess],
},
onError: { <--- Handled!!
target: SystemIOMachineStates.idle,
actions: [SystemIOMachineActions.toastError], <-- will toast error!
},
console.error(e) | ||
} | ||
} | ||
await window.electron.mkdir(input.requestedAbsolutePath, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here, or maybe there is a reason it is outside the try-catch ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reason as above, the try catch is handled on the systemIOMachine.ts
onError
definition of the actor being invoked.
@@ -43,6 +45,9 @@ export function ContextMenu({ | |||
}) | |||
const handleContextMenu = useCallback( | |||
(e: globalThis.MouseEvent) => { | |||
if (callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
short one liner I usually use is callback?.(e)
instead of the if
but just mentioning it, it may be less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have settled this debate internally of shorthands.
if (something)
doSomething()
yup && yup()
^-- stuff like this
I think it is less readable seeing callback?.(e)
. Curious if anyone has strong opinions on this?
list.push(content) | ||
|
||
// if a FileEntry has no children stop | ||
if (f.children === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably doesn't matter but in cases like this I just usually check for falsiness, that handles if for any reasons children becomes undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type is of children: Array<FileEntry> | null
. I kinda want stuff to shit the bed if the value is actually undefined
?
If we are worried about this we may need some runtime verification on the types to ensure that object is generated without any undefined.
I was going to mention that but it seems even on |
Going through comments, i'll come up with a TODO list for this pass of review. |
@@ -97,48 +97,3 @@ jobs: | |||
git commit -am "Look at this (photo)Graph *in the voice of Nickelback*" || true | |||
git push | |||
git push origin ${{ github.head_ref }} | |||
|
|||
npm-test-unit-components: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All jest unit test component stuff is merged into vitest
since it is compatible and supports more of our repository level configurations.
@@ -134,8 +134,7 @@ | |||
"test": "vitest --mode=development", | |||
"test:rust": "(cd rust && just test && just lint)", | |||
"test:snapshots": "cross-env TARGET=web NODE_ENV=development playwright test --config=playwright.config.ts --grep=@snapshot --trace=on", | |||
"test:unit": "vitest run --mode=development --exclude **/jest-component-unit-tests/*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, deleted the jest runtime stuff since vitest automatically supports the component testing as is.
@@ -0,0 +1,175 @@ | |||
import React, { useEffect, useMemo } from 'react' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file could be migrated into another files in the future.
It is useful at the moment since it is the largest component when loading the modeling page. It allows us to initialize a few things.
I'd say okay for the time being.
@@ -0,0 +1,347 @@ | |||
// @ts-nocheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since jest
had a different configuration setup this file is failing several static checkers. The configurations that were used in jest
are different from our repository level configurations.
I've added some no checks to make the static checker happy. Any new .test.tsx
will be good though.
…first file and press left arrow
I've implemented the functionality that will close your current folder if you are in a folder and in the first position of the folder. It moves up and then closes the folder like VSCode. |
#7592 got out of hand with the optimizations with little planning on my end.
Opening a fresh PR without this to see if this passes to do my optimizations within another body of work.