-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #783 from open-formulieren/feature/5033-service-un…
…available-error-message ✨ [open-formulieren/open-forms#5033] User friendly error in case of 503
- Loading branch information
Showing
4 changed files
with
145 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# ViteJS based | ||
VITE_VERSION=latest | ||
VITE_MUTE_ERROR_BOUNDARY_LOG=false | ||
VITE_BASE_API_URL=http://localhost:8000/api/v2/ | ||
VITE_FORM_ID=93c09209-5fb9-4105-b6bb-9d9f0aa6782c | ||
VITE_USE_HASH_ROUTING=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import {MemoryRouter} from 'react-router'; | ||
|
||
import {PermissionDenied, ServiceUnavailable, UnprocessableEntity} from 'errors'; | ||
|
||
import ErrorBoundary from './ErrorBoundary'; | ||
|
||
const Nested = ({error}) => { | ||
throw error; | ||
}; | ||
|
||
const render = ({useCard, errorType, errorCode}) => { | ||
const error = new errorType('some error', 500, 'some error', errorCode); | ||
return ( | ||
<ErrorBoundary useCard={useCard}> | ||
<Nested error={error} /> | ||
</ErrorBoundary> | ||
); | ||
}; | ||
|
||
export default { | ||
title: 'Private API / ErrorBoundary', | ||
component: ErrorBoundary, | ||
render, | ||
argTypes: { | ||
useCard: {control: {type: 'boolean'}}, | ||
errorType: { | ||
table: { | ||
options: [PermissionDenied, ServiceUnavailable, UnprocessableEntity], | ||
control: {type: 'radio'}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const GenericError = { | ||
args: { | ||
useCard: true, | ||
errorType: Error, | ||
errorCode: 'generic', | ||
}, | ||
}; | ||
|
||
export const PermissionDeniedError = { | ||
decorators: [ | ||
Story => ( | ||
<MemoryRouter initialEntries={['/']}> | ||
<Story /> | ||
</MemoryRouter> | ||
), | ||
], | ||
args: { | ||
useCard: true, | ||
errorType: PermissionDenied, | ||
}, | ||
}; | ||
|
||
export const UnprocessableEntityErrorInactive = { | ||
args: { | ||
useCard: true, | ||
errorType: UnprocessableEntity, | ||
errorCode: 'form-inactive', | ||
}, | ||
}; | ||
|
||
export const UnprocessableEntityErrorGeneric = { | ||
args: { | ||
useCard: true, | ||
errorType: UnprocessableEntity, | ||
errorCode: 'generic', | ||
}, | ||
}; | ||
|
||
export const ServiceUnavailableErrorMaintenance = { | ||
args: { | ||
useCard: true, | ||
errorType: ServiceUnavailable, | ||
errorCode: 'form-maintenance', | ||
}, | ||
}; | ||
|
||
export const ServiceUnavailableErrorMaxSubmissions = { | ||
args: { | ||
useCard: true, | ||
errorType: ServiceUnavailable, | ||
errorCode: 'form-maximum-submissions', | ||
}, | ||
}; | ||
|
||
export const ServiceUnavailableError = { | ||
args: { | ||
useCard: true, | ||
errorType: ServiceUnavailable, | ||
errorCode: 'service_unavailable', | ||
}, | ||
}; | ||
|
||
export const ServiceUnavailableErrorGeneric = { | ||
args: { | ||
useCard: true, | ||
errorType: ServiceUnavailable, | ||
errorCode: 'generic', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {FormattedMessage, useIntl} from 'react-intl'; | ||
|
||
import ErrorMessage from 'components/Errors/ErrorMessage'; | ||
|
||
const FormUnavailable = ({wrapper: Wrapper}) => { | ||
const intl = useIntl(); | ||
// Wrapper may be a DOM element, which can't handle <FormattedMessage /> | ||
const title = intl.formatMessage({ | ||
description: 'Open Forms service unavailable error title', | ||
defaultMessage: 'Form unavailable', | ||
}); | ||
return ( | ||
<Wrapper title={title}> | ||
<ErrorMessage modifier="error"> | ||
<FormattedMessage | ||
description="Open Forms service unavailable error message" | ||
defaultMessage="Unfortunately, this form is currently unavailable due to an outage. Please try again later." | ||
/> | ||
</ErrorMessage> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default FormUnavailable; |