-
Notifications
You must be signed in to change notification settings - Fork 12
/
utils.js
52 lines (46 loc) · 1.55 KB
/
utils.js
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
import React from 'react';
import {
Cancel as FailedIcon,
CheckCircle as SuccessIcon,
HourglassFull as PendingIcon,
Replay as RetryIcon,
PanTool as RevokedIcon,
Timer as ReceivedIcon,
} from '@mui/icons-material';
import { CircularProgress } from '@mui/material';
import { get } from 'lodash';
import { ERROR_RED, GREEN, ORANGE, DARKGRAY, BLUE } from '../../common/constants';
const COLORS = {
failure: ERROR_RED, success: GREEN, pending: ORANGE, retry: BLUE, started: BLUE,
revoked: DARKGRAY, received: BLUE
};
const getIcon = (status, rest) => {
if(!status)
return;
const state = status.toLowerCase();
const color = COLORS[state];
const width = get(rest, 'width', '20px');
const height = get(rest, 'height', '20px');
if(state === 'failure')
return <FailedIcon style={{color: color}} {...rest} />;
if(state === 'success')
return <SuccessIcon style={{color: color}} {...rest} />;
if(state === 'pending')
return <PendingIcon style={{color: color}} {...rest} />;
if(state === 'retry')
return <RetryIcon style={{color: color}} {...rest} />;
if(state === 'started')
return <CircularProgress style={{color: BLUE, width: width, height: height}} {...rest} />;
if(state === 'revoked')
return <RevokedIcon style={{color: color}} {...rest} />;
if(state === 'received')
return <ReceivedIcon style={{color: color}} {...rest} />;
}
export const getTaskIconDetails = (status, rest) => {
const icon = getIcon(status, rest);
return {
icon: icon,
status: status,
color: COLORS[status.toLowerCase()]
}
}