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

Javalab: warn about overwrite to backpack when committing code #42268

Merged
merged 6 commits into from Sep 3, 2021

Conversation

bencodeorg
Copy link
Contributor

@bencodeorg bencodeorg commented Aug 31, 2021

Provides a warning if you want to commit a file that has the same name as a file in your backpack:

image

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.

@bencodeorg bencodeorg requested a review from a team as a code owner August 31, 2021 18:58
@bencodeorg
Copy link
Contributor Author

Rerunning Drone, but failing test is unrelated to these code changes.

@bencodeorg bencodeorg requested a review from a team August 31, 2021 23:16
Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a 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 Show resolved Hide resolved
apps/src/javalab/CommitDialog.jsx Outdated Show resolved Hide resolved
apps/src/javalab/CommitDialog.jsx Outdated Show resolved Hide resolved
Comment on lines 118 to 180
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
});
}
);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

apps/src/javalab/CommitDialog.jsx Outdated Show resolved Hide resolved
Copy link
Contributor

@molly-moen molly-moen left a 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

apps/src/javalab/CommitDialog.jsx Show resolved Hide resolved
apps/src/javalab/CommitDialog.jsx Outdated Show resolved Hide resolved
notes: PropTypes.string,
onToggleFile: PropTypes.func.isRequired,
onChangeNotes: PropTypes.func.isRequired
};

export function CommitDialogFile({file, onToggleFile}) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

@bencodeorg bencodeorg Sep 2, 2021

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:

https://codedotorg.atlassian.net/browse/CSA-791

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good!

@bencodeorg
Copy link
Contributor Author

@molly-moen @sanchitmalhotra126 thanks for the great feedback, think it's a lot cleaner now! Take another look when you have a moment :).

Copy link
Contributor

@molly-moen molly-moen left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

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

LGTM!

@bencodeorg bencodeorg merged commit 54ce2c9 into staging Sep 3, 2021
@bencodeorg bencodeorg deleted the ben/javalab-backpack-warn-on-commit branch September 3, 2021 17:48
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.

None yet

3 participants