1
- import CircularProgress from "@mui/material/CircularProgress"
2
- import ErrorIcon from "@mui/icons-material/ErrorOutline"
3
- import StopIcon from "@mui/icons-material/StopOutlined"
4
- import PlayIcon from "@mui/icons-material/PlayArrowOutlined"
5
- import QueuedIcon from "@mui/icons-material/HourglassEmpty"
6
- import { Workspace , WorkspaceBuild } from "api/typesGenerated"
1
+ import { Workspace } from "api/typesGenerated"
7
2
import { Pill } from "components/Pill/Pill"
8
- import i18next from "i18next"
9
3
import { FC , PropsWithChildren } from "react"
10
4
import { makeStyles } from "@mui/styles"
11
5
import { combineClasses } from "utils/combineClasses"
@@ -14,82 +8,7 @@ import {
14
8
ImpendingDeletionBadge ,
15
9
ImpendingDeletionText ,
16
10
} from "components/WorkspaceDeletion"
17
-
18
- const LoadingIcon : FC = ( ) => {
19
- return < CircularProgress size = { 10 } style = { { color : "#FFF" } } />
20
- }
21
-
22
- export const getStatus = ( buildStatus : WorkspaceBuild [ "status" ] ) => {
23
- const { t } = i18next
24
-
25
- switch ( buildStatus ) {
26
- case undefined :
27
- return {
28
- text : t ( "workspaceStatus.loading" , { ns : "common" } ) ,
29
- icon : < LoadingIcon /> ,
30
- } as const
31
- case "running" :
32
- return {
33
- type : "success" ,
34
- text : t ( "workspaceStatus.running" , { ns : "common" } ) ,
35
- icon : < PlayIcon /> ,
36
- } as const
37
- case "starting" :
38
- return {
39
- type : "success" ,
40
- text : t ( "workspaceStatus.starting" , { ns : "common" } ) ,
41
- icon : < LoadingIcon /> ,
42
- } as const
43
- case "stopping" :
44
- return {
45
- type : "warning" ,
46
- text : t ( "workspaceStatus.stopping" , { ns : "common" } ) ,
47
- icon : < LoadingIcon /> ,
48
- } as const
49
- case "stopped" :
50
- return {
51
- type : "warning" ,
52
- text : t ( "workspaceStatus.stopped" , { ns : "common" } ) ,
53
- icon : < StopIcon /> ,
54
- } as const
55
- case "deleting" :
56
- return {
57
- type : "warning" ,
58
- text : t ( "workspaceStatus.deleting" , { ns : "common" } ) ,
59
- icon : < LoadingIcon /> ,
60
- } as const
61
- case "deleted" :
62
- return {
63
- type : "error" ,
64
- text : t ( "workspaceStatus.deleted" , { ns : "common" } ) ,
65
- icon : < ErrorIcon /> ,
66
- } as const
67
- case "canceling" :
68
- return {
69
- type : "warning" ,
70
- text : t ( "workspaceStatus.canceling" , { ns : "common" } ) ,
71
- icon : < LoadingIcon /> ,
72
- } as const
73
- case "canceled" :
74
- return {
75
- type : "warning" ,
76
- text : t ( "workspaceStatus.canceled" , { ns : "common" } ) ,
77
- icon : < ErrorIcon /> ,
78
- } as const
79
- case "failed" :
80
- return {
81
- type : "error" ,
82
- text : t ( "workspaceStatus.failed" , { ns : "common" } ) ,
83
- icon : < ErrorIcon /> ,
84
- } as const
85
- case "pending" :
86
- return {
87
- type : "info" ,
88
- text : t ( "workspaceStatus.pending" , { ns : "common" } ) ,
89
- icon : < QueuedIcon /> ,
90
- } as const
91
- }
92
- }
11
+ import { getDisplayWorkspaceStatus } from "utils/workspace"
93
12
94
13
export type WorkspaceStatusBadgeProps = {
95
14
workspace : Workspace
@@ -99,7 +18,9 @@ export type WorkspaceStatusBadgeProps = {
99
18
export const WorkspaceStatusBadge : FC <
100
19
PropsWithChildren < WorkspaceStatusBadgeProps >
101
20
> = ( { workspace, className } ) => {
102
- const { text, icon, type } = getStatus ( workspace . latest_build . status )
21
+ const { text, icon, type } = getDisplayWorkspaceStatus (
22
+ workspace . latest_build . status ,
23
+ )
103
24
return (
104
25
< ChooseOne >
105
26
{ /* <ImpendingDeletionBadge/> determines its own visibility */ }
@@ -117,7 +38,9 @@ export const WorkspaceStatusText: FC<
117
38
PropsWithChildren < WorkspaceStatusBadgeProps >
118
39
> = ( { workspace, className } ) => {
119
40
const styles = useStyles ( )
120
- const { text, type } = getStatus ( workspace . latest_build . status )
41
+ const { text, type } = getDisplayWorkspaceStatus (
42
+ workspace . latest_build . status ,
43
+ )
121
44
122
45
return (
123
46
< ChooseOne >
0 commit comments