File tree Expand file tree Collapse file tree 1 file changed +25
-35
lines changed
Expand file tree Collapse file tree 1 file changed +25
-35
lines changed Original file line number Diff line number Diff line change 1- import { Component } from 'react' ;
21import styled from '@emotion/styled' ;
32
43import Alert from 'sentry/components/alert' ;
54import Button from 'sentry/components/button' ;
65import { Panel } from 'sentry/components/panels' ;
76import { t } from 'sentry/locale' ;
87
9- type DefaultProps = {
10- message : React . ReactNode ;
11- } ;
12-
13- type Props = DefaultProps & {
8+ type Props = {
149 className ?: string ;
10+ message ?: React . ReactNode ;
1511 onRetry ?: ( ) => void ;
1612} ;
1713
1814/**
19- * Renders an Alert box of type "error". Renders a "Retry" button only if a `onRetry` callback is defined.
15+ * Renders an Alert box of type "error". Renders a "Retry" button only if a
16+ * `onRetry` callback is defined.
2017 */
21- class LoadingError extends Component < Props > {
22- static defaultProps : DefaultProps = {
23- message : t ( 'There was an error loading data.' ) ,
24- } ;
25-
26- shouldComponentUpdate ( ) {
27- return false ;
28- }
29-
30- render ( ) {
31- const { message, onRetry, className} = this . props ;
32- return (
33- < StyledAlert
34- type = "error"
35- showIcon
36- className = { className }
37- trailingItems = {
38- onRetry && (
39- < Button onClick = { onRetry } type = "button" priority = "default" size = "small" >
40- { t ( 'Retry' ) }
41- </ Button >
42- )
43- }
44- >
45- { message }
46- </ StyledAlert >
47- ) ;
48- }
18+ function LoadingError ( {
19+ className,
20+ onRetry,
21+ message = t ( 'There was an error loading data.' ) ,
22+ } : Props ) {
23+ return (
24+ < StyledAlert
25+ type = "error"
26+ showIcon
27+ className = { className }
28+ trailingItems = {
29+ onRetry && (
30+ < Button onClick = { onRetry } type = "button" priority = "default" size = "small" >
31+ { t ( 'Retry' ) }
32+ </ Button >
33+ )
34+ }
35+ >
36+ { message }
37+ </ StyledAlert >
38+ ) ;
4939}
5040
5141export default LoadingError ;
You can’t perform that action at this time.
0 commit comments