Skip to content
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

Feat: unsaved file content #3358

Merged
merged 21 commits into from
Aug 16, 2024
Merged

Feat: unsaved file content #3358

merged 21 commits into from
Aug 16, 2024

Conversation

tofarr
Copy link
Collaborator

@tofarr tofarr commented Aug 13, 2024

Before Changes

When you make changes in the code editor, if you click into a different file, the changes are lost.
e.g.:
I write some changes:
image

But if I click into a different file, they are lost! (There is no dialog or warning to prevent this!)
image

After Changes

We store changes even after you click out of a file. Files with unsaved changes are marked with a "*", and a cancel button was added to clear changes. (My original idea was to use local storage / indexed db to store changes, but I have not implemented this for this iteration - so a page refresh will still clear edits)
image

I can click to a different file and make changes there too:
image

Clicking back to the original displays the unsaved changes:
image

Changes are only saved / cancelled when the page is refreshed or the button is clicked.

Under the hood

I added an array of fileStates to the redux state - this allows for determining whether there is unsavedContent, and displaying different UI states in the file explorer

Open Questions

I think some UI review is in order - making sure this is consistent with where we want the product to go, and that this UI is intuitive.

@tofarr tofarr marked this pull request as ready for review August 13, 2024 19:22
@tofarr tofarr changed the title Feature: unsaved file content Feat: unsaved file content Aug 14, 2024
@xingyaoww xingyaoww requested a review from amanape August 14, 2024 16:29
@amanape
Copy link
Member

amanape commented Aug 14, 2024

Sorry for the delay, I'll give it a full review tomorrow! LGTM though from a quick skim if you're in a rush

Copy link
Member

@amanape amanape left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Consider extending the test cases to serve as another form of documentation for newcomers (if you have the time of course!)

frontend/src/components/file-explorer/CodeEditor.tsx Outdated Show resolved Hide resolved
@tofarr
Copy link
Collaborator Author

tofarr commented Aug 15, 2024

Added a few more minimal test cases. TBH I think we need more test cases around editing

@tofarr tofarr merged commit eab7ea3 into main Aug 16, 2024
@tofarr tofarr deleted the feature-unsaved-file-content branch August 16, 2024 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants