Skip to content

Commit

Permalink
AXON-72: added error logging when invalid sign in flow
Browse files Browse the repository at this point in the history
  • Loading branch information
cabella-dot committed Feb 14, 2025
1 parent 383c248 commit 4131cad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/lib/ipc/fromUI/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum OnboardingActionType {
ViewPullRequest = 'viewPullRequest',
ClosePage = 'closePage',
OpenSettings = 'openSettings',
Error = 'error',
}

export type OnboardingAction =
Expand All @@ -25,6 +26,7 @@ export type OnboardingAction =
| ReducerAction<OnboardingActionType.ViewPullRequest>
| ReducerAction<OnboardingActionType.ClosePage>
| ReducerAction<OnboardingActionType.OpenSettings, OpenSettingsAction>
| ReducerAction<OnboardingActionType.Error, { error: Error }>
| CommonAction;

export interface AuthAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ export class OnboardingWebviewController implements WebviewController<SectionCha
this._analytics.fireMoreSettingsButtonEvent(id);
break;
}

case OnboardingActionType.Error: {
this._logger.error(msg.error);
this.postMessage({ type: CommonMessageType.Error, reason: formatError(msg.error, 'Onboarding Error') });
break;
}
case CommonActionType.SendAnalytics:
case CommonActionType.CopyLink:
case CommonActionType.OpenJiraIssue:
Expand Down
17 changes: 12 additions & 5 deletions src/react/atlascode/onboarding/OnboardingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { AnalyticsView } from 'src/analyticsTypes';
import { Features } from 'src/util/featureFlags';
import { CommonMessageType } from 'src/lib/ipc/toUI/common';
import { JiraBitbucketOnboarding } from './JiraBitbucketOnboarding';
import { OnboardingActionType } from 'src/lib/ipc/fromUI/onboarding';

const useStyles = makeStyles((theme: Theme) => ({
root: {
Expand Down Expand Up @@ -61,7 +62,7 @@ export const OnboardingPage: React.FunctionComponent = () => {
const [useAuthUI, setUseAuthUI] = React.useState(false);
const [jiraSignInText, setJiraSignInText] = useState('Sign In to Jira Cloud');
const [bitbucketSignInText, setBitbucketSignInText] = useState('Sign In to Bitbucket Cloud');
const [jiraSignInFlow, setJiraSignInFlow] = useState('jira-setup-radio-cloud');
const [jiraSignInFlow, setJiraSignInFlow] = useState('error');
const [bitbucketSignInFlow, setBitbucketSignInFlow] = useState('bitbucket-setup-radio-cloud');

React.useEffect(() => {
Expand Down Expand Up @@ -157,10 +158,13 @@ export const OnboardingPage: React.FunctionComponent = () => {
handleNext();
break;
default:
console.log('Invalid Bitbucket sign in flow: %s', bitbucketSignInFlow);
controller.postMessage({
type: OnboardingActionType.Error,
error: new Error(`Invalid Bitbucket sign in flow ${bitbucketSignInFlow}`),
});
break;
}
}, [bitbucketSignInFlow, handleCloudSignIn, handleNext, handleServerSignIn]);
}, [bitbucketSignInFlow, controller, handleCloudSignIn, handleNext, handleServerSignIn]);

const executeJiraSignInFlow = useCallback(() => {
console.log(jiraSignInFlow);
Expand All @@ -176,10 +180,13 @@ export const OnboardingPage: React.FunctionComponent = () => {
handleNext();
break;
default:
console.log('Invalid Jira sign in flow: %s', jiraSignInFlow);
controller.postMessage({
type: OnboardingActionType.Error,
error: new Error(`Invalid Jira sign in flow ${jiraSignInFlow}`),
});
break;
}
}, [jiraSignInFlow, handleCloudSignIn, handleServerSignIn, handleNext]);
}, [jiraSignInFlow, handleCloudSignIn, handleServerSignIn, handleNext, controller]);

const handleJiraOptionChange = useCallback((value: string) => {
setJiraSignInFlow(value);
Expand Down

0 comments on commit 4131cad

Please sign in to comment.