Skip to content

Commit

Permalink
SDA-4774 - Display dynamic status message (#2246)
Browse files Browse the repository at this point in the history
* SDA-4774 - Display dynamic status message

* SDA-4774 - Update snapshot file

* SDA-4774 - Update message
  • Loading branch information
KiranNiranjan authored Jan 7, 2025
1 parent e4fc421 commit 80519f5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion spec/__snapshots__/aboutApp.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports[`about app should render correctly 1`] = `
<p
className="AboutApp-copyright-text"
>
Copyright © 2024 Symphony
Copyright © 2025 Symphony
</p>
</div>
</div>
Expand Down
13 changes: 9 additions & 4 deletions src/app/main-api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ const loadPodUrl = (() => {
}

isRetryInProgress = false;
setLoginRetryState(isRetryInProgress);
setLoginRetryState(isRetryInProgress, false);
retryTimeoutId = null;
} catch (error: any) {
if (
Expand Down Expand Up @@ -867,7 +867,7 @@ const loadPodUrl = (() => {
'main-api-handler: Retry attempts exhausted. Endpoint unreachable.',
);
isRetryInProgress = false;
setLoginRetryState(isRetryInProgress);
setLoginRetryState(isRetryInProgress, true);
}
}
} finally {
Expand All @@ -880,7 +880,7 @@ const loadPodUrl = (() => {
// Start the retry logic only if it's not already in progress
if (!isRetryInProgress) {
isRetryInProgress = true;
setLoginRetryState(isRetryInProgress);
setLoginRetryState(isRetryInProgress, false);
attemptFetch();
} else {
logger.info(
Expand All @@ -897,12 +897,17 @@ const loadPodUrl = (() => {
* This message is used to update the UI accordingly.
*
* @param {boolean} isRetryInProgress - A boolean indicating whether a login retry is in progress.
* @param {boolean} retryFailed - A boolean indicating a failure of retry mechanism
*/
const setLoginRetryState = (isRetryInProgress: boolean) => {
const setLoginRetryState = (
isRetryInProgress: boolean,
retryFailed: boolean = false,
) => {
const mainWebContents = windowHandler.getMainWebContents();
if (mainWebContents && !mainWebContents.isDestroyed()) {
mainWebContents.send('welcome', {
isRetryInProgress,
retryFailed,
});
}
};
2 changes: 2 additions & 0 deletions src/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@
"Welcome": {
"Continue": "Continue",
"Enable Single Sign On": "Enable Single Sign On",
"Establishing a secure connection.": "Establishing a secure connection.",
"Unable to establish a secure connection.": "Unable to establish a secure connection.",
"Find your pod URL in your invitation email.": "Find your pod URL in your invitation email.",
"Welcome to the largest global community in financial services with over": "Welcome to the largest global community in financial services with over",
" half a million users": " half a million users",
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@
"Welcome": {
"Continue": "Continue",
"Enable Single Sign On": "Enable Single Sign On",
"Establishing a secure connection.": "Establishing a secure connection.",
"Unable to establish a secure connection.": "Unable to establish a secure connection.",
"Find your pod URL in your invitation email.": "Find your pod URL in your invitation email.",
"Welcome to the largest global community in financial services with over": "Welcome to the largest global community in financial services with over",
" half a million users": " half a million users",
Expand Down
36 changes: 32 additions & 4 deletions src/renderer/components/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface IState {
browserLoginAutoConnect: boolean;
isLoading: boolean;
isRetryInProgress: boolean;
retryFailed: boolean;
}

const WELCOME_NAMESPACE = 'Welcome';
Expand All @@ -39,6 +40,7 @@ export default class Welcome extends React.Component<{}, IState> {
browserLoginAutoConnect: false,
isLoading: false,
isRetryInProgress: false,
retryFailed: false,
};
this.updateState = this.updateState.bind(this);
}
Expand All @@ -55,6 +57,7 @@ export default class Welcome extends React.Component<{}, IState> {
isBrowserLoginEnabled,
isFirstTimeLaunch,
isRetryInProgress,
retryFailed,
} = this.state;
return (
<div className='Welcome' lang={i18n.getLocale()}>
Expand Down Expand Up @@ -120,10 +123,10 @@ export default class Welcome extends React.Component<{}, IState> {
{isBrowserLoginEnabled && (
<div className='Welcome-redirect-info-text-container'>
<span>
{i18n.t(
'You’ll momentarily be redirected to your web browser.',
WELCOME_NAMESPACE,
)()}
{this.getConnectionStatusMessage(
isRetryInProgress,
retryFailed,
)}
</span>
{isLoading && (
<button
Expand Down Expand Up @@ -392,4 +395,29 @@ export default class Welcome extends React.Component<{}, IState> {
</svg>
);
}

/**
* Gets the appropriate connection status message based on retry status.
* @param {boolean} isRetryInProgress Whether a retry is currently in progress.
* @param {boolean} retryFailed Whether the retry attempt failed.
* @returns {string} The connection status message.
*/
private getConnectionStatusMessage = (
isRetryInProgress: boolean,
retryFailed: boolean,
): string => {
if (isRetryInProgress) {
return i18n.t('Establishing a secure connection.', WELCOME_NAMESPACE)();
} else if (retryFailed) {
return i18n.t(
'Unable to establish a secure connection.',
WELCOME_NAMESPACE,
)();
} else {
return i18n.t(
'You’ll momentarily be redirected to your web browser.',
WELCOME_NAMESPACE,
)();
}
};
}
2 changes: 1 addition & 1 deletion src/renderer/styles/welcome.less
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ body {
border: none;
cursor: pointer;
padding: 0;
margin: 0 8px;
margin: 0 4px;
font-size: 14px;
text-align: center;
display: inline-block;
Expand Down

0 comments on commit 80519f5

Please sign in to comment.