Skip to content

Commit 29925fb

Browse files
Merge pull request #121 from devtron-labs/fix/error-screen
fix: error screen
2 parents e1a2c87 + f925921 commit 29925fb

18 files changed

+4071
-4208
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ src/Common/DraggableWrapper/DraggableWrapper.tsx
3838
src/Common/Drawer/Drawer.tsx
3939
src/Common/EmptyState/GenericEmptyState.tsx
4040
src/Common/Error.tsx
41-
src/Common/ErrorScreenNotFound.tsx
4241
src/Common/Grid/Grid.tsx
4342
src/Common/Helper.tsx
4443
src/Common/Hooks/UseClickOutside/UseClickOutside.tsx

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
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.77",
3+
"version": "0.0.78",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -65,7 +65,7 @@
6565
"@typeform/embed-react": "2.20.0",
6666
"react-toastify": "^8.2.0",
6767
"typescript": "^4.9.4",
68-
"vite": "^4.4.5",
68+
"vite": "^4.5.3",
6969
"vite-plugin-dts": "^3.5.1",
7070
"vite-plugin-lib-inject-css": "^1.2.0",
7171
"vite-plugin-svgr": "^2.4.0"

src/Assets/Img/ic-not-found.svg

Lines changed: 160 additions & 0 deletions
Loading

src/Assets/Img/ic-page-not-found.svg

Lines changed: 65 additions & 0 deletions
Loading

src/Common/Constants.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const FALLBACK_REQUEST_TIMEOUT = 60000
44
export const Host = window?.__ORCHESTRATOR_ROOT__ ?? '/orchestrator'
55

66
export const DOCUMENTATION_HOME_PAGE = 'https://docs.devtron.ai'
7+
export const DISCORD_LINK = 'https://discord.devtron.ai/'
78
export const DOCUMENTATION = {
89
APP_TAGS: `${DOCUMENTATION_HOME_PAGE}/v/v0.6/usage/applications/create-application#tags`,
910
APP_OVERVIEW_TAGS: `${DOCUMENTATION_HOME_PAGE}/v/v0.6/usage/applications/overview#manage-tags`,
@@ -36,6 +37,7 @@ export const ROUTES = {
3637
CD_MATERIAL_GET: 'app/cd-pipeline',
3738
DEPLOYMENT_TEMPLATE_LIST: 'app/template/list',
3839
INFRA_CONFIG_PROFILE: 'infra-config/profile',
40+
APP_LIST: 'app/list',
3941
TELEMETRY_EVENT: 'telemetry/event',
4042
SERVER_INFO_API: 'server',
4143
ATTRIBUTES_USER: 'attributes/user',
@@ -56,22 +58,51 @@ export const DEFAULT_TAG_DATA = {
5658
isSuggested: true,
5759
}
5860

61+
export enum ERROR_STATUS_CODE {
62+
BAD_REQUEST = 400,
63+
UNAUTHORIZED = 401,
64+
PERMISSION_DENIED = 403,
65+
NOT_FOUND = 404,
66+
EXPECTATION_FAILED = 417,
67+
INTERNAL_SERVER_ERROR = 500,
68+
BAD_GATEWAY = 502,
69+
SERVICE_TEMPORARY_UNAVAILABLE = 503,
70+
}
71+
5972
export const TOAST_ACCESS_DENIED = {
6073
TITLE: 'Access denied',
6174
SUBTITLE: 'You do not have required access to perform this action',
6275
}
6376

6477
// Empty state messgaes
6578
export const ERROR_EMPTY_SCREEN = {
66-
PAGE_NOT_FOUND: 'We could not find this page',
67-
PAGE_NOT_EXIST: 'This page doesn’t exist or was removed. We suggest you go back to home',
68-
TAKE_BACK_HOME: 'Take me home',
79+
PAGE_NOT_FOUND: 'Not found',
80+
PAGE_NOT_EXIST: 'Error 404: The requested resource could not be found. Please check the URL and try again.',
81+
TAKE_BACK_HOME: 'Go back home',
82+
REPORT_ISSUE: 'Report issue',
6983
ONLY_FOR_SUPERADMIN: 'Information on this page is available only to superadmin users.',
7084
NOT_AUTHORIZED: 'Not authorized',
71-
UNAUTHORIZED: 'unauthorized',
72-
FORBIDDEN: 'forbidden',
7385
REQUIRED_MANAGER_ACCESS:
7486
'Looks like you don’t have access to information on this page. Please contact your manager to request access.',
87+
BAD_REQUEST: 'Bad request',
88+
BAD_REQUEST_MESSAGE:
89+
'Error 400: The request could not be understood by the server due to malformed syntax. Please check your request and try again.',
90+
TRY_AGAIN: 'Try again',
91+
UNAUTHORIZED: 'Unauthorized',
92+
UNAUTHORIZED_MESSAGE:
93+
'Error 401: You are not authorized to access this resource. Please contact your administrator for assistance.',
94+
FORBIDDEN: 'Forbidden',
95+
FORBIDDEN_MESSAGE:
96+
'Error 403: You are not authorized to access this resource. Please contact your administrator for assistance.',
97+
INTERNAL_SERVER_ERROR: 'Internal server error',
98+
INTERNAL_SERVER_ERROR_MESSAGE:
99+
'Error 500: The server encountered an unexpected condition that prevented it from fulfilling the request. Please try again later.',
100+
BAD_GATEWAY: 'Bad gateway',
101+
BAD_GATEWAY_MESSAGE:
102+
'Error 500: The server received an invalid response from an upstream server. Please try again later.',
103+
SERVICE_TEMPORARY_UNAVAILABLE: 'Service temporary unavailable',
104+
SERVICE_TEMPORARY_UNAVAILABLE_MESSAGE:
105+
'Error 503: The server is currently unable to handle the request due to a temporary overload or maintenance. Please try again later.',
75106
}
76107
export const TOKEN_COOKIE_NAME = 'argocd.token'
77108
export const TriggerTypeMap = {
@@ -402,8 +433,6 @@ export enum SERVER_MODE {
402433
FULL = 'FULL',
403434
}
404435

405-
export const DISCORD_LINK = 'https://discord.devtron.ai/'
406-
407436
export const POSTHOG_EVENT_ONBOARDING = {
408437
PREVIEW: 'Preview',
409438
DEPLOY_CUSTOM_APP_CI_CD: 'Deploy custom app using CI/CD pipelines',

src/Common/EmptyState/GenericEmptyState.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import AppNotDeployed from '../../Assets/Img/app-not-deployed.png'
32
import { GenericEmptyStateType, ImageType } from '../Types'
43

@@ -63,12 +62,18 @@ const GenericEmptyState = ({
6362
/>
6463
)}
6564
<div
66-
className={`flex column dc__gap-10 dc__mxw-300 ${
65+
className={`flex column dc__gap-20 dc__mxw-300 ${
6766
isRowLayout ? 'dc__align-start' : ''
6867
} ${contentClassName}`}
6968
>
70-
<h4 className="title fw-6 cn-9 mt-0 mb-0 lh-1-5">{title}</h4>
71-
{subTitle && <p className={`subtitle ${isRowLayout ? 'subtitle--text-start' : ''}`}>{subTitle}</p>}
69+
<div className="flex column dc__gap-8">
70+
<h4 className="title fw-6 cn-9 mt-0 mb-0 lh-24">{title}</h4>
71+
{subTitle && (
72+
<p className={`subtitle ${isRowLayout ? 'subtitle--text-start' : ''}`}>
73+
{subTitle}
74+
</p>
75+
)}
76+
</div>
7277
{isButtonAvailable && renderButton()}
7378
{children}
7479
</div>

src/Common/EmptyState/emptyState.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
font-size: 13px;
2424
font-weight: 400;
2525
text-align: center;
26-
line-height: 1.5;
26+
line-height: 20px;
2727
margin-bottom: 6px;
2828

2929
&--text-start {

src/Common/Error.tsx

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/Common/ErrorPage.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { useHistory } from 'react-router'
2+
import { ERROR_STATUS_CODE, ERROR_EMPTY_SCREEN, ROUTES } from './Constants'
3+
import GenericEmptyState from './EmptyState/GenericEmptyState'
4+
import { ErrorPageType } from './Types'
5+
import { noop, refresh, reportIssue } from './Helper'
6+
7+
const ErrorPage = ({ code, image, title, subTitle, imageType, heightToDeduct }: ErrorPageType) => {
8+
const { push } = useHistory()
9+
const redirectToHome = () => {
10+
push(`/${ROUTES.APP_LIST}`)
11+
}
12+
13+
const getErrorPageProps = (
14+
statusCode: ERROR_STATUS_CODE,
15+
): { onClick: () => void; renderButtonText: string; isButtonAvailable: boolean } => {
16+
switch (statusCode) {
17+
case ERROR_STATUS_CODE.NOT_FOUND:
18+
return {
19+
onClick: redirectToHome,
20+
renderButtonText: ERROR_EMPTY_SCREEN.TAKE_BACK_HOME,
21+
isButtonAvailable: true,
22+
}
23+
case ERROR_STATUS_CODE.INTERNAL_SERVER_ERROR:
24+
return {
25+
onClick: reportIssue,
26+
renderButtonText: ERROR_EMPTY_SCREEN.REPORT_ISSUE,
27+
isButtonAvailable: true,
28+
}
29+
case ERROR_STATUS_CODE.BAD_REQUEST:
30+
case ERROR_STATUS_CODE.BAD_GATEWAY:
31+
case ERROR_STATUS_CODE.SERVICE_TEMPORARY_UNAVAILABLE:
32+
return { onClick: refresh, renderButtonText: ERROR_EMPTY_SCREEN.TRY_AGAIN, isButtonAvailable: true }
33+
default:
34+
return { onClick: noop, renderButtonText: '', isButtonAvailable: false }
35+
}
36+
}
37+
38+
const {
39+
onClick,
40+
renderButtonText,
41+
isButtonAvailable,
42+
}: { onClick: () => void; renderButtonText: string; isButtonAvailable: boolean } = getErrorPageProps(code)
43+
44+
const renderGenerateButton = () => (
45+
<button type="button" className="flex cta h-36" onClick={onClick} data-testid="empty-screen-take-me-home">
46+
{renderButtonText}
47+
</button>
48+
)
49+
50+
return (
51+
<GenericEmptyState
52+
image={image}
53+
title={title}
54+
subTitle={subTitle}
55+
isButtonAvailable={isButtonAvailable}
56+
renderButton={renderGenerateButton}
57+
imageType={imageType}
58+
heightToDeduct={heightToDeduct}
59+
/>
60+
)
61+
}
62+
63+
export default ErrorPage

0 commit comments

Comments
 (0)