Skip to content

Commit fb85114

Browse files
committed
fix: add redirectURL for Error screen manager
1 parent 9218d44 commit fb85114

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/Common/ErrorPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import GenericEmptyState from './EmptyState/GenericEmptyState'
44
import { ErrorPageType } from './Types'
55
import { noop, refresh, reportIssue } from './Helper'
66

7-
const ErrorPage = ({ code, image, title, subTitle, imageType, heightToDeduct, reload }: ErrorPageType) => {
7+
const ErrorPage = ({ code, image, title, subTitle, imageType, heightToDeduct, reload, redirectURL }: ErrorPageType) => {
88
const { push } = useHistory()
99
const redirectToHome = () => {
10-
push(`/${ROUTES.APP_LIST}`)
10+
push(redirectURL || `/${ROUTES.APP_LIST}`)
1111
}
1212

1313
const getErrorPageProps = (

src/Common/ErrorScreenManager.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import notFound from '../Assets/Img/ic-not-found.svg'
22
import badRequest from '../Assets/Img/ic-page-not-found.svg'
33
import unauthorized from '../Assets/Img/ic-not-authorized.svg'
4-
import { ERROR_STATUS_CODE, ERROR_EMPTY_SCREEN } from './Constants'
4+
import { ERROR_STATUS_CODE, ERROR_EMPTY_SCREEN, ROUTES } from './Constants'
55
import Reload from './Reload'
66
import ErrorPage from './ErrorPage'
77
import { ErrorScreenManagerProps, ImageType } from './Types'
88

9-
const ErrorScreenManager = ({ code, reload, subtitle, reloadClass, heightToDeduct }: ErrorScreenManagerProps) => {
9+
const ErrorScreenManager = ({
10+
code,
11+
reload,
12+
subtitle,
13+
reloadClass,
14+
heightToDeduct,
15+
redirectURL = ROUTES.APP_LIST,
16+
}: ErrorScreenManagerProps) => {
1017
const getMessage = () => {
1118
switch (code) {
1219
case ERROR_STATUS_CODE.BAD_REQUEST:
@@ -19,6 +26,7 @@ const ErrorScreenManager = ({ code, reload, subtitle, reloadClass, heightToDeduc
1926
imageType={ImageType.Large}
2027
heightToDeduct={heightToDeduct}
2128
reload={reload}
29+
redirectURL={redirectURL}
2230
/>
2331
)
2432
case ERROR_STATUS_CODE.UNAUTHORIZED:

src/Common/Types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export interface GenericEmptyStateType {
139139
}
140140

141141
export interface ErrorPageType
142-
extends Pick<GenericEmptyStateType, 'image' | 'title' | 'subTitle' | 'renderButton' | 'imageType'>, Pick<ErrorScreenManagerProps, 'reload'> {
142+
extends Pick<GenericEmptyStateType, 'image' | 'title' | 'subTitle' | 'renderButton' | 'imageType'>, Pick<ErrorScreenManagerProps, 'reload' | 'redirectURL'> {
143143
code: number
144144
heightToDeduct?: number
145145
}
@@ -150,6 +150,11 @@ export interface ErrorScreenManagerProps {
150150
subtitle?: React.ReactChild
151151
reloadClass?: string
152152
heightToDeduct?: number
153+
/**
154+
* Would be used to redirect URL in case of 404
155+
* @default - APP_LIST
156+
*/
157+
redirectURL?: string
153158
}
154159

155160
export interface ErrorScreenNotAuthorizedProps {

0 commit comments

Comments
 (0)