Skip to content

Commit 4f36157

Browse files
authored
Merge pull request #105 from ssvlabs/INTERFACES-674-invalid-status-handling
Handling of invalid status
2 parents 074352f + 3be65a3 commit 4f36157

File tree

3 files changed

+84
-54
lines changed

3 files changed

+84
-54
lines changed

src/app/common/components/Status/Status.tsx

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,43 @@ import { Skeleton } from '@material-ui/lab';
66
import { StatusProps, useStyles } from './Status.styles';
77

88
const Status = (props: StatusProps) => {
9-
const [showTooltip, setShowTooltip] = useState(false);
10-
const classes = useStyles(props);
9+
const [showTooltip, setShowTooltip] = useState(false);
10+
const classes = useStyles(props);
1111

12-
const handleMouseEnter = () => {
13-
setShowTooltip(true);
14-
};
12+
const handleMouseEnter = () => {
13+
setShowTooltip(true);
14+
};
1515

16-
const handleMouseLeave = () => {
17-
setShowTooltip(false);
18-
};
16+
const handleMouseLeave = () => {
17+
setShowTooltip(false);
18+
};
1919

20-
if (!props.entry) return <Skeleton style={{ width: 50 }} />;
21-
return (
22-
<Tooltip className={props.extendClass} open={showTooltip && props.size === 'big'} title={'Is the validator performing duties in the last 2 consecutive epochs'}>
23-
<Grid
24-
onMouseEnter={handleMouseEnter}
25-
onMouseLeave={handleMouseLeave}
26-
className={classes.Status}>
27-
{props.entry.is_deleted ? 'Deleted' : props.entry.status}
28-
</Grid>
29-
</Tooltip>
30-
);
20+
if (!props.entry) return <Skeleton style={{ width: 50 }} />;
21+
22+
let statusText = props.entry.status;
23+
if (props.entry.is_deleted) {
24+
statusText = 'Deleted';
25+
} else if (!props.entry.is_valid) {
26+
statusText = 'Invalid';
27+
}
28+
29+
return (
30+
<Tooltip
31+
className={props.extendClass}
32+
open={showTooltip && props.size === 'big'}
33+
title={
34+
'Is the validator performing duties in the last 2 consecutive epochs'
35+
}
36+
>
37+
<Grid
38+
onMouseEnter={handleMouseEnter}
39+
onMouseLeave={handleMouseLeave}
40+
className={classes.Status}
41+
>
42+
{statusText}
43+
</Grid>
44+
</Tooltip>
45+
);
3146
};
3247

3348
export default observer(Status);

src/app/components/Operator/Operator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const Operator = () => {
5656
const socialIcon = (url: string, imageSrc: string, className: string) => {
5757
return (url && (
5858
<Link href={url} target="_blank" className={className}>
59-
<img src={imageSrc} className={className} />
59+
<img alt="social" src={imageSrc} className={className} />
6060
</Link>
6161
));
6262
};
@@ -168,7 +168,7 @@ const Operator = () => {
168168
<NotFoundScreen notFound={notFound}>
169169
<Grid container className={classes.OperatorWrapper}>
170170
<Grid xs={12} sm={12} md={12} lg={3} xl={3} item className={classes.OperatorInfoWrapper}>
171-
<OperatorStatus status={operator.status} is_deleted={operator.is_deleted} />
171+
<OperatorStatus status={operator.status} is_deleted={operator.is_deleted} is_valid={operator.is_valid} />
172172
<ValidatorCount validatorCount={operator.validators_count} />
173173
<OperatorPerformance operator={operator} isLoading={isLoading} />
174174
</Grid>

src/app/components/Operator/components/OperatorStatus.tsx

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const OperatorPerformanceContainer = styled.div`
1212
border-radius: 16px;
1313
flex-direction: column;
1414
padding: 32px 20px 46px 32px;
15-
background-color: ${props => props.theme.colors.white};
15+
background-color: ${(props) => props.theme.colors.white};
1616
@media (max-width: 576px) {
1717
width: 100%;
1818
},
@@ -27,7 +27,7 @@ const DataHeader = styled.div`
2727
font-style: normal;
2828
margin-bottom: auto;
2929
font-stretch: normal;
30-
color: ${props => props.theme.colors.gray40};
30+
color: ${(props) => props.theme.colors.gray40};
3131
`;
3232

3333
const ValueContent = styled.div`
@@ -37,43 +37,58 @@ const ValueContent = styled.div`
3737
font-style: normal;
3838
font-stretch: normal;
3939
letter-spacing: -0.5px;
40-
color: ${props => props.theme.colors.gray100};
40+
color: ${(props) => props.theme.colors.gray100};
4141
`;
4242

43-
const OperatorStatus = ({ status, is_deleted }: { status: string, is_deleted?: boolean }) => {
44-
const headerTooltipStyle = { fontSize: '14px', color: 'rgb(161, 172, 190)', marginBottom: '-2px' };
45-
let textColor: string;
46-
let statusText: JSX.Element | string;
43+
const OperatorStatus = ({
44+
status,
45+
is_deleted,
46+
is_valid,
47+
}: {
48+
status: string;
49+
is_deleted?: boolean;
50+
is_valid?: boolean;
51+
}) => {
52+
const headerTooltipStyle = {
53+
fontSize: '14px',
54+
color: 'rgb(161, 172, 190)',
55+
marginBottom: '-2px',
56+
};
57+
let textColor: string;
58+
let statusText: JSX.Element | string;
4759

48-
if (is_deleted) {
49-
statusText = 'Deleted';
60+
if (is_deleted) {
61+
statusText = 'Deleted';
62+
textColor = '#ec1c26';
63+
} else if (!is_valid) {
64+
statusText = 'Invalid';
65+
textColor = '#ec1c26';
66+
} else {
67+
switch (status) {
68+
case 'Active':
69+
textColor = '#08c858';
70+
break;
71+
case 'Inactive':
5072
textColor = '#ec1c26';
51-
} else {
52-
switch (status) {
53-
case 'Active':
54-
textColor = '#08c858';
55-
break;
56-
case 'Inactive':
57-
textColor = '#ec1c26';
58-
break;
59-
default:
60-
textColor = '#808080';
61-
}
62-
statusText = !status ? <Skeleton style={{ width: 100 }} /> : status;
73+
break;
74+
default:
75+
textColor = '#808080';
6376
}
77+
statusText = !status ? <Skeleton style={{ width: 100 }} /> : status;
78+
}
6479

65-
return (
66-
<OperatorPerformanceContainer>
67-
<DataHeader>
68-
Status
69-
<InfoTooltip
70-
style={headerTooltipStyle}
71-
message="Is the operator performing duties for the majority of its validators in the last 2 epochs."
72-
/>
73-
</DataHeader>
74-
<ValueContent style={{ color: textColor }}>{statusText}</ValueContent>
75-
</OperatorPerformanceContainer>
76-
);
80+
return (
81+
<OperatorPerformanceContainer>
82+
<DataHeader>
83+
Status
84+
<InfoTooltip
85+
style={headerTooltipStyle}
86+
message="Is the operator performing duties for the majority of its validators in the last 2 epochs."
87+
/>
88+
</DataHeader>
89+
<ValueContent style={{ color: textColor }}>{statusText}</ValueContent>
90+
</OperatorPerformanceContainer>
91+
);
7792
};
7893

7994
export default observer(OperatorStatus);

0 commit comments

Comments
 (0)