@@ -5,23 +5,23 @@ import Skeleton from "@material-ui/lab/Skeleton"
5
5
import { Stack } from "components/Stack/Stack"
6
6
import { FC } from "react"
7
7
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
8
+ import * as TypesGen from "../../api/typesGenerated"
8
9
9
10
export const Language = {
10
11
of : "of" ,
11
- workspaceUsed : "workspace used " ,
12
- workspacesUsed : "workspaces used " ,
12
+ workspace : "workspace" ,
13
+ workspaces : "workspaces" ,
13
14
}
14
15
15
16
export interface WorkspaceQuotaProps {
16
- count ?: number
17
- limit ?: number
17
+ quota ?: TypesGen . UserWorkspaceQuota
18
18
}
19
19
20
- export const WorkspaceQuota : FC < WorkspaceQuotaProps > = ( { count , limit } ) => {
20
+ export const WorkspaceQuota : FC < WorkspaceQuotaProps > = ( { quota } ) => {
21
21
const styles = useStyles ( )
22
22
23
23
// loading state
24
- if ( count === undefined || limit === undefined ) {
24
+ if ( quota === undefined ) {
25
25
return (
26
26
< Box >
27
27
< Stack spacing = { 1 } className = { styles . stack } >
@@ -34,9 +34,14 @@ export const WorkspaceQuota: FC<WorkspaceQuotaProps> = ({ count, limit }) => {
34
34
)
35
35
}
36
36
37
- let value = Math . round ( ( count / limit ) * 100 )
37
+ // don't show if limit is 0, this means the feature is disabled.
38
+ if ( quota . limit === 0 ) {
39
+ return ( < > </ > )
40
+ }
41
+
42
+ let value = Math . round ( ( quota . count / quota . limit ) * 100 )
38
43
// we don't want to round down to zero if the count is > 0
39
- if ( count > 0 && value === 0 ) {
44
+ if ( quota . count > 0 && value === 0 ) {
40
45
value = 1
41
46
}
42
47
@@ -45,8 +50,8 @@ export const WorkspaceQuota: FC<WorkspaceQuotaProps> = ({ count, limit }) => {
45
50
< Stack spacing = { 1 } className = { styles . stack } >
46
51
< LinearProgress value = { value } variant = "determinate" color = "primary" />
47
52
< div className = { styles . label } >
48
- { count } { Language . of } { limit } { " " }
49
- { limit === 1 ? Language . workspaceUsed : Language . workspacesUsed }
53
+ { quota . count } { Language . of } { quota . limit } { " " }
54
+ { quota . limit === 1 ? Language . workspace : Language . workspaces } { " used" }
50
55
</ div >
51
56
</ Stack >
52
57
</ Box >
0 commit comments