-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathindex.jsx
More file actions
145 lines (139 loc) · 5.91 KB
/
index.jsx
File metadata and controls
145 lines (139 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import PropTypes from 'prop-types'
import {Helmet} from 'react-helmet'
import {Box, Button, Flex, Heading, IconButton, Stack, Text} from '@chakra-ui/react'
import {BrandLogo, FileIcon} from '../icons'
import {withChakraUI} from '../with-chakra-ui'
// <Error> is rendered when:
//
// 1. A user requests a page that is not routable from `app/routes.jsx`.
// 2. A routed component throws an error in `getProps()`.
// 3. A routed component throws an error in `render()`.
//
// It must not throw an error. Keep it as simple as possible.
const Error = (props) => {
const {message, stack} = props
const title = "This page isn't working"
return (
<Flex id="sf-app" flex="1" direction="column" minWidth="375px">
<Helmet>
<title>{title}</title>
</Helmet>
<Box as="header" width="full" boxShadow="base" backgroundColor="white">
<Box
maxWidth="container.xxxl"
marginLeft="auto"
marginRight="auto"
px={['4', '4', '6', '8']}
paddingTop={['1', '1', '2', '4']}
paddingBottom={['3', '3', '2', '4']}
>
<IconButton
aria-label="logo"
marginBottom={['1', '1', '2', '0']}
variant="unstyled"
// We need to use window.location.href here rather than history
// as the application is in an error state. We need to force a
// hard navigation to get back to the normal state.
onClick={() => (window.location.href = '/')}
>
<BrandLogo width={{base: '8', lg: '12'}} height={{base: '6', lg: '8'}} />
</IconButton>
</Box>
</Box>
<Box
as="main"
id="app-main"
role="main"
layerStyle="page"
padding={{lg: '8', md: '6', sm: '0', base: '0'}}
flex="1"
>
<Flex
direction={'column'}
justify="center"
px={{base: '4', md: '6', lg: '50'}}
py={{base: '20', md: '24'}}
>
<Flex align="center" direction="column">
<FileIcon boxSize={['30px', '32px']} mb="8" />
<Heading as="h2" fontSize={['xl', '2xl', '2xl', '3xl']} mb="2">
{title}
</Heading>
<Box maxWidth="440px" marginBottom="8">
<Text align="center">
An error has occurred. Try refreshing the page or if you need
immediate help please contact support.
</Text>
{message && (
<Box
as="pre"
mt="4"
padding="4"
fontSize="sm"
background="gray.50"
borderColor="gray.200"
borderStyle="solid"
borderWidth="1px"
overflow="auto"
>
{message}
</Box>
)}
</Box>
<Stack direction={['column', 'row']} gap="4" width={['100%', 'auto']}>
<Button
variant="outline"
bg="white"
as="a"
borderColor={'gray.200'}
target="_blank"
href="https://help.salesforce.com/s/support"
>
Contact Support
</Button>
<Button onClick={() => window.location.reload()}>
Refresh the page
</Button>
</Stack>
</Flex>
{stack && (
<Box marginTop="20">
<Text fontWeight="bold" fontSize="md">
Stack Trace
</Text>
<Box
as="pre"
mt="4"
fontSize="sm"
background="gray.50"
borderColor="gray.200"
borderStyle="solid"
borderWidth="1px"
overflow="auto"
padding="4"
>
{stack}
</Box>
</Box>
)}
</Flex>
</Box>
</Flex>
)
}
Error.propTypes = {
// JavaScript error stack trace: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack
stack: PropTypes.string,
// HTTP status code: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
status: PropTypes.number,
// A description of the error, if available
message: PropTypes.string
}
export default withChakraUI(Error)