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

reload Eula State #578

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const resources: CommonTranslationsFile = {
LOADING: '正在加载……',
REQUEST_ERROR: '抱歉,发送您的请求时出现了程序错误。',
PASSWORD_REQUIRED_ERROR: '密码为必填项',
RETRY: '重试',
},
FORMS: {
FIRST_NAME: '名',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const resources: CommonTranslationsFile = {
LOADING: 'Loading...',
REQUEST_ERROR: 'Sorry, there was a problem sending your request.',
PASSWORD_REQUIRED_ERROR: 'Password Required',
RETRY: 'Retry',
},
FORMS: {
FIRST_NAME: 'First Name',
Expand Down
1 change: 1 addition & 0 deletions login-workflow/src/contexts/SharedDictionaries/french.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const resources: CommonTranslationsFile = {
LOADING: 'le chargement...',
REQUEST_ERROR: `Désolé, un problème est survenu lors de l'envoi de votre demande.`,
PASSWORD_REQUIRED_ERROR: 'Mot de passe requis',
RETRY: 'Recommencez',
},
FORMS: {
FIRST_NAME: 'Prénom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const resources: CommonTranslationsFile = {
LOADING: 'A carregar...',
REQUEST_ERROR: 'Pedimos desculpa, existe um problema ao submeter o seu pedido',
PASSWORD_REQUIRED_ERROR: 'Senha requerida',
RETRY: 'Tentar novamente',
},
FORMS: {
FIRST_NAME: 'Primeiro Nome',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const resources: CommonTranslationsFile = {
LOADING: 'Cargando...',
REQUEST_ERROR: 'Lo sentimos, hubo un problema al enviar su solicitud.',
PASSWORD_REQUIRED_ERROR: 'Se requiere contraseña',
RETRY: 'Rever',
},
FORMS: {
FIRST_NAME: 'Nombre',
Expand Down
1 change: 1 addition & 0 deletions login-workflow/src/contexts/SharedDictionaries/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type CommonTranslations = {
LOADING: string;
REQUEST_ERROR: string;
PASSWORD_REQUIRED_ERROR: string;
RETRY: string;
};
FORMS: {
FIRST_NAME: string;
Expand Down
22 changes: 13 additions & 9 deletions login-workflow/src/screens/EulaScreen/EulaScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useTranslation } from 'react-i18next';
* @param WorkflowCardInstructionProps props that will be passed to the WorkflowCardInstructions component
* @param WorkflowCardActionsProps props that will be passed to the WorkflowCardActions component
* @param errorDisplayConfig configuration for customizing how errors are displayed
* @param onRefetch used to refetch Eula content.
* @param refreshConfig used to refresh Eula content.
*
* @category Component
*/
Expand Down Expand Up @@ -162,13 +162,7 @@ export const EulaScreen: React.FC<EulaScreenProps> = (props) => {
void loadAndCacheEula();
}, [loadAndCacheEula]);

const {
checkboxProps = { ...props.checkboxProps, disabled: eulaFetchError },
onRefetch = (): void => {
setEulaFetchError(false);
void loadAndCacheEula();
},
} = props;
const { checkboxProps = { ...props.checkboxProps, disabled: eulaFetchError } } = props;

const workflowCardHeaderProps = {
title: t('bluiRegistration:REGISTRATION.STEPS.LICENSE'),
Expand All @@ -195,6 +189,16 @@ export const EulaScreen: React.FC<EulaScreenProps> = (props) => {
},
};

const {
refreshConfig = {
showRefreshButton: eulaFetchError,
onRefresh: (): void => {
setEulaFetchError(false);
void loadAndCacheEula();
},
},
} = props;

return (
<EulaScreenBase
WorkflowCardHeaderProps={workflowCardHeaderProps}
Expand All @@ -210,7 +214,7 @@ export const EulaScreen: React.FC<EulaScreenProps> = (props) => {
onEulaAcceptedChange={updateEulaAcceptedStatus}
WorkflowCardActionsProps={workflowCardActionsProps}
errorDisplayConfig={errorDisplayConfig}
onRefetch={onRefetch}
refreshConfig={refreshConfig}
{...otherEulaScreenProps}
/>
);
Expand Down
12 changes: 7 additions & 5 deletions login-workflow/src/screens/EulaScreen/EulaScreenBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import DOMPurify from 'dompurify';
import ErrorManager from '../../components/Error/ErrorManager';
import { Typography } from '@mui/material';
import ReplaySharpIcon from '@mui/icons-material/ReplaySharp';
import { useTranslation } from 'react-i18next';

/**
* Component that renders a screen displaying the EULA and requests acceptance via a checkbox.
Expand All @@ -29,7 +30,7 @@ import ReplaySharpIcon from '@mui/icons-material/ReplaySharp';
* @param WorkflowCardInstructionProps props that will be passed to the WorkflowCardInstructions component
* @param WorkflowCardActionsProps props that will be passed to the WorkflowCardActions component
* @param errorDisplayConfig configuration for customizing how errors are displayed
* @param onRefetch used to refetch Eula content.
* @param onRefresh used to refresh Eula content.
*
* @category Component
*/
Expand All @@ -43,9 +44,10 @@ export const EulaScreenBase: React.FC<EulaScreenProps> = (props) => {
initialCheckboxValue,
checkboxProps,
errorDisplayConfig,
onRefetch,
refreshConfig,
} = props;

const { t } = useTranslation();
const cardBaseProps = props.WorkflowCardBaseProps || {};
const headerProps = props.WorkflowCardHeaderProps || {};
const instructionsProps = props.WorkflowCardInstructionProps || {};
Expand All @@ -71,7 +73,7 @@ export const EulaScreenBase: React.FC<EulaScreenProps> = (props) => {
<WorkflowCardHeader {...headerProps} />
{Object.keys(instructionsProps).length !== 0 && <WorkflowCardInstructions {...instructionsProps} />}
<WorkflowCardBody sx={{ pt: 2 }}>
{checkboxProps?.disabled ? (
{refreshConfig?.showRefreshButton ? (
<Box
sx={{
display: 'flex',
Expand All @@ -89,11 +91,11 @@ export const EulaScreenBase: React.FC<EulaScreenProps> = (props) => {
cursor: 'pointer',
p: 1,
}}
onClick={onRefetch}
onClick={refreshConfig?.onRefresh}
>
<ReplaySharpIcon color="primary" sx={{ width: 36, height: 36 }} />
<Typography variant="subtitle2" color="primary">
Retry
{refreshConfig?.refreshButtonLabel || t('bluiCommon:MESSAGES.RETRY')}
</Typography>
</Box>
</Box>
Expand Down
21 changes: 17 additions & 4 deletions login-workflow/src/screens/EulaScreen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,21 @@ export type EulaScreenProps = WorkflowCardProps & {
errorDisplayConfig?: ErrorManagerProps;

/**
* Function to refetch Eula content
* @returns void
*/
onRefetch?: () => void;
* used to show refresh button and refresh the Eula content
*/
refreshConfig?: {
ektaghag-eaton marked this conversation as resolved.
Show resolved Hide resolved
/**
* Function to refresh Eula content
* @returns {void}
*/
onRefresh?: () => void;
/**
* the refresh button to be rendered
*/
showRefreshButton?: boolean;
/**
* Label of refresh button
*/
refreshButtonLabel?: string;
};
};
Loading