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
Javalab: warn about overwrite to backpack when committing code #42268
Conversation
Rerunning Drone, but failing test is unrelated to these code changes. |
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.
Looks good overall! Couple things I noticed but nothing major
apps/src/javalab/CommitDialog.jsx
Outdated
this.setState({ | ||
hasBackpackSaveError: false, | ||
backpackSaveInProgress: false, | ||
filesToBackpack: [] | ||
}); | ||
|
||
this.props.backpackApi.getFileList( | ||
this.handleBackpackLoadError, | ||
filenames => { | ||
this.setState({ | ||
hasBackpackSaveError: false, | ||
hasBackpackLoadError: false, | ||
backpackSaveInProgress: false, | ||
filesToBackpack: [], | ||
existingBackpackFiles: filenames | ||
}); | ||
} | ||
); |
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.
Hmm...I'm wondering if it would be better to keep the previous state update to clear errors and saving in progress state before calling the backpack API? That way, if there's an error loading files, it might be a bit clearer that the file did successfully save, but there was a separate server error reloading the files? Not sure though, because it would also mean back to back state updates.
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.
Great point, check out the updated version and let me know what you think.
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.
Looks good, just a couple comments
notes: PropTypes.string, | ||
onToggleFile: PropTypes.func.isRequired, | ||
onChangeNotes: PropTypes.func.isRequired | ||
}; | ||
|
||
export function CommitDialogFile({file, onToggleFile}) { |
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'm not super up on the react patterns, should this be its own file? Mainly because this file is getting long and it seems like a clean thing to factor out.
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.
Yeah probably should, we have another sub-component already in this file so I felt like I should either factor both out or neither.
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.
makes sense, feel free to do as a separate pr if that's easier
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.
Think I'll do this as a follow-up if that's ok, item here:
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.
sounds good!
@molly-moen @sanchitmalhotra126 thanks for the great feedback, think it's a lot cleaner now! Take another look when you have a moment :). |
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.
Nice!
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.
LGTM!
Provides a warning if you want to commit a file that has the same name as a file in your backpack:
Testing story
Tested manually, and added unit tests. Also tested the error case manually that we show an error message if the files API cannot get the list of files in the backpack currently.