Skip to content

Commit 43a59d7

Browse files
committed
reload and redirect exposed from errorScreenManager
1 parent 295597a commit 43a59d7

File tree

7 files changed

+49
-18
lines changed

7 files changed

+49
-18
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.0.81-beta-7",
3+
"version": "0.0.81-beta-8",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Icon/ic-open-in-new.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Common/ErrorPage.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ 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 }: ErrorPageType) => {
7+
const ErrorPage = ({ code, image, title, subTitle, imageType, heightToDeduct, redirectURL, reload }: ErrorPageType) => {
88
const { push } = useHistory()
99
const redirectToHome = () => {
10-
push(`/${ROUTES.APP_LIST}`)
10+
push(redirectURL || `/${ROUTES.APP_LIST}`)
11+
}
12+
13+
const handleRefresh = () => {
14+
if (reload) {
15+
reload()
16+
} else {
17+
refresh()
18+
}
1119
}
1220

1321
const getErrorPageProps = (
@@ -29,7 +37,11 @@ const ErrorPage = ({ code, image, title, subTitle, imageType, heightToDeduct }:
2937
case ERROR_STATUS_CODE.BAD_REQUEST:
3038
case ERROR_STATUS_CODE.BAD_GATEWAY:
3139
case ERROR_STATUS_CODE.SERVICE_TEMPORARY_UNAVAILABLE:
32-
return { onClick: refresh, renderButtonText: ERROR_EMPTY_SCREEN.TRY_AGAIN, isButtonAvailable: true }
40+
return {
41+
onClick: handleRefresh,
42+
renderButtonText: ERROR_EMPTY_SCREEN.TRY_AGAIN,
43+
isButtonAvailable: true,
44+
}
3345
default:
3446
return { onClick: noop, renderButtonText: '', isButtonAvailable: false }
3547
}

src/Common/ErrorScreenManager.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ 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,
16+
}: ErrorScreenManagerProps) => {
1017
const getMessage = () => {
1118
switch (code) {
1219
case ERROR_STATUS_CODE.BAD_REQUEST:
@@ -18,6 +25,7 @@ const ErrorScreenManager = ({ code, reload, subtitle, reloadClass, heightToDeduc
1825
image={badRequest}
1926
imageType={ImageType.Large}
2027
heightToDeduct={heightToDeduct}
28+
reload={reload}
2129
/>
2230
)
2331
case ERROR_STATUS_CODE.UNAUTHORIZED:
@@ -51,6 +59,7 @@ const ErrorScreenManager = ({ code, reload, subtitle, reloadClass, heightToDeduc
5159
image={notFound}
5260
imageType={ImageType.Large}
5361
heightToDeduct={heightToDeduct}
62+
redirectURL={redirectURL}
5463
/>
5564
)
5665
case ERROR_STATUS_CODE.INTERNAL_SERVER_ERROR:
@@ -73,6 +82,7 @@ const ErrorScreenManager = ({ code, reload, subtitle, reloadClass, heightToDeduc
7382
image={badRequest}
7483
imageType={ImageType.Large}
7584
heightToDeduct={heightToDeduct}
85+
reload={reload}
7686
/>
7787
)
7888
case ERROR_STATUS_CODE.SERVICE_TEMPORARY_UNAVAILABLE:
@@ -84,6 +94,7 @@ const ErrorScreenManager = ({ code, reload, subtitle, reloadClass, heightToDeduc
8494
image={badRequest}
8595
imageType={ImageType.Large}
8696
heightToDeduct={heightToDeduct}
97+
reload={reload}
8798
/>
8899
)
89100
default:

src/Common/TippyCustomized.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Tippy from '@tippyjs/react'
33
import { ReactComponent as CloseIcon } from '../Assets/Icon/ic-cross.svg'
44
import { ReactComponent as Help } from '../Assets/Icon/ic-help.svg'
55
import { ReactComponent as ICHelpOutline } from '../Assets/Icon/ic-help-outline.svg'
6+
import { ReactComponent as ICOpenInNew } from '../Assets/Icon/ic-open-in-new.svg'
67
import 'tippy.js/animations/shift-toward-subtle.css'
78
import { TippyCustomizedProps, TippyTheme } from './Types'
89
import { not, stopPropagation } from './Helper'
@@ -140,10 +141,11 @@ export const TippyCustomized = (props: TippyCustomizedProps) => {
140141
href={documentationLink}
141142
target="_blank"
142143
rel="noreferrer noopener"
143-
className="fs-13 cb-5"
144+
className="fs-13 cb-5 flex left"
144145
onClick={closeTippy}
145146
>
146147
{documentationLinkText || 'Learn more'}
148+
<ICOpenInNew className="icon-dim-14 ml-4" />
147149
</a>
148150
</div>
149151
)}

src/Common/Types.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ export interface ErrorPageType
142142
extends Pick<GenericEmptyStateType, 'image' | 'title' | 'subTitle' | 'renderButton' | 'imageType'> {
143143
code: number
144144
heightToDeduct?: number
145+
redirectURL?: string
146+
reload?: () => void
145147
}
146148

147149
export interface ErrorScreenManagerProps {
@@ -150,6 +152,7 @@ export interface ErrorScreenManagerProps {
150152
subtitle?: React.ReactChild
151153
reloadClass?: string
152154
heightToDeduct?: number
155+
redirectURL?: string
153156
}
154157

155158
export interface ErrorScreenNotAuthorizedProps {
@@ -869,18 +872,18 @@ export interface DeploymentWindowProfileMetaData {
869872
}
870873

871874
export interface EnvironmentListHelmResult {
872-
clusterId: number
873-
clusterName: string
874-
environments: EnvironmentHelmResult[]
875+
clusterId: number
876+
clusterName: string
877+
environments: EnvironmentHelmResult[]
875878
}
876879

877880
export interface EnvironmentHelmResult {
878-
environmentId: number
879-
environmentName: string
880-
namespace: string
881-
environmentIdentifier: string
882-
isVirtualEnvironment?: boolean // Need to confirm for not full mode
883-
allowedDeploymentTypes?: DeploymentAppTypes[]
881+
environmentId: number
882+
environmentName: string
883+
namespace: string
884+
environmentIdentifier: string
885+
isVirtualEnvironment?: boolean // Need to confirm for not full mode
886+
allowedDeploymentTypes?: DeploymentAppTypes[]
884887
}
885888

886-
export type EnvironmentListHelmResponse = ResponseType<EnvironmentListHelmResult[]>
889+
export type EnvironmentListHelmResponse = ResponseType<EnvironmentListHelmResult[]>

0 commit comments

Comments
 (0)