-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathutils.ts
More file actions
125 lines (117 loc) · 3.6 KB
/
utils.ts
File metadata and controls
125 lines (117 loc) · 3.6 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
/*
* Copyright (c) 2024. Devtron Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TIMELINE_STATUS } from '@Shared/constants'
import { WorkflowStatusEnum } from '@Shared/types'
import { IconName, IconsProps } from '../Icon'
import { StatusType } from './types'
export const getIconName = (status: string, showAnimatedIcon: boolean): IconName => {
switch (status) {
case 'queued':
case 'pending':
return 'ic-clock'
case 'failed':
return 'ic-failure'
case 'error':
case 'not-ready':
return 'ic-error'
case 'cancelled':
return 'ic-cancelled'
case 'aborted':
return 'ic-aborted'
case 'healthy':
return 'ic-heart-green'
case 'ready':
case 'synced':
case 'sync.ok':
case 'succeeded':
return 'ic-success'
case 'drifted':
return 'ic-out-of-sync'
case 'missing':
return 'ic-missing'
case 'unknown':
return 'ic-unknown'
case 'not-triggered':
case 'not-deployed':
case 'notdeployed':
case 'not-available':
return 'ic-close-small'
case 'suspended':
return 'ic-suspended'
case 'degraded':
return showAnimatedIcon ? 'ic-heart-red-animated' : 'ic-heart-red'
case 'initiating':
case 'progressing':
case 'running':
case 'request_accepted':
case 'starting':
case 'waiting-to-start':
return 'ic-circle-loader'
case 'inprogress':
return 'ic-in-progress'
case 'hibernating':
case 'hibernated':
return 'ic-hibernate'
case 'timedout':
case 'timed_out':
return 'ic-timeout-dash'
default:
return null
}
}
export const getIconColor = (status: string): IconsProps['color'] => {
switch (status) {
case 'not-triggered':
case 'not-deployed':
case 'notdeployed':
case 'not-available':
case 'queued':
case 'pending':
return 'N600'
case 'initiating':
case 'progressing':
case 'running':
case 'request_accepted':
case 'starting':
return 'O500'
case 'timedout':
case 'timed_out':
return 'R500'
default:
return null
}
}
export const getDeploymentStatusFromStatus = (status: string): string => {
const deploymentStatus = status?.toUpperCase()
switch (deploymentStatus) {
case TIMELINE_STATUS.ABORTED:
return StatusType.ABORTED
case TIMELINE_STATUS.DEGRADED:
return StatusType.FAILED
case TIMELINE_STATUS.HEALTHY:
return StatusType.SUCCEEDED
case TIMELINE_STATUS.INPROGRESS:
return StatusType.INPROGRESS
default:
return status
}
}
export const getJobStatusFromStatus = (status: string): string => {
if (status === WorkflowStatusEnum.WAITING_TO_START) {
return 'Waiting to start'
}
return status
}