-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Added error handling for github auth urls #4749
Conversation
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.
you'll need to copy the error setState hook and html in the same places as GitHubRepositoryForm
const [error, setError] = useState('');
{error && (
<p className="notice error margin-bottom-sm">
<button className="pull-right icon" onClick={() => setError('')}>
<i className="fa fa-times" />
</button>
{error}
</p>
)}
tuck it just inside the closing form tag
I appreciate that. I've gone ahead and added the code. I tested it locally and both errors show and appear to look fine. Not sure if you'd like me to change the text, as it might be better to go with a more clear definitive |
...ui/components/modals/git-repository-settings-modal/github-repository-settings-form-group.tsx
Outdated
Show resolved
Hide resolved
@@ -368,20 +376,30 @@ const GitHubSignInForm = ({ token }: GitHubSignInFormProps) => { | |||
}); | |||
|
|||
command(dispatch); | |||
} else { | |||
setError('It appears the URL that you entered is incomplete'); |
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.
setError('It appears the URL that you entered is incomplete'); | |
setError('Missing URL'); |
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.
Is "Missing URL" correct? It will only show this error if there is a valid url, howevever the state
or code
query params are missing
Perhaps Incomplete URL
would be better?
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.
Ah yes I had misread because of the nested if statements perhaps you can use guard pattern to clear up the misunderstanding.
const hasCodeAndState = typeof code === 'string' && typeof state === 'string'
if(!hasCodeAndState) {
setError('Incomplete URL');
return;
}
const command = newCommand(COMMAND_GITHUB_OAUTH_AUTHENTICATE, {
code,
state,
});
command(dispatch);
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.
Gotcha. I've moved that logic up as requested and changed the error text, though I implemented it without the hasCodeAndState
variable.
Is it still readable or would you prefer an additional variable to make it easier to understand when glancing over the code?
Changed conditional to follow guard pattern
Changelog(Improvements): Improved error messages for Github Sync
I'm not sure how best show these errors to the user, but I feel that instead of these two
console.error
's that I added there should be some kind of error modal or something like that, but I'm not sure how best to do that in this project