1
1
import type { PlaygroundFeatureSchema , PlaygroundRequestSchema } from 'openapi' ;
2
- import { Alert , IconButton , Typography , useTheme , styled } from '@mui/material' ;
2
+ import { Alert , Typography , useTheme , styled , IconButton } from '@mui/material' ;
3
3
import { PlaygroundResultChip } from '../../PlaygroundResultChip/PlaygroundResultChip' ;
4
4
import CloseOutlined from '@mui/icons-material/CloseOutlined' ;
5
5
import type React from 'react' ;
6
- import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender' ;
7
6
import {
8
7
checkForEmptyValues ,
9
8
hasCustomStrategies ,
10
9
hasOnlyCustomStrategies ,
11
10
} from './helpers' ;
12
11
13
- const StyledDivWrapper = styled ( 'div' ) ( {
12
+ const HeaderRow = styled ( 'div' ) ( {
14
13
display : 'flex' ,
15
14
justifyContent : 'space-between' ,
16
15
width : '100%' ,
17
16
} ) ;
18
17
19
- const StyledDivTitleRow = styled ( 'div ' ) ( ( { theme } ) => ( {
18
+ const HeaderGroup = styled ( 'hgroup ' ) ( ( { theme } ) => ( {
20
19
display : 'inline-flex' ,
21
20
alignItems : 'center' ,
22
21
gap : theme . spacing ( 1.5 ) ,
23
- marginTop : theme . spacing ( 1.5 ) ,
24
22
} ) ) ;
25
23
26
- const StyledDivAlertRow = styled ( 'div' ) ( ( { theme } ) => ( {
27
- margin : theme . spacing ( 1 , 0 ) ,
24
+ const StyledTypographyName = styled ( 'h3' ) ( ( { theme } ) => ( {
25
+ fontWeight : 'bold' ,
26
+ fontSize : theme . typography . subtitle1 . fontSize ,
27
+ margin : 0 ,
28
28
} ) ) ;
29
29
30
- const StyledDivDescriptionRow = styled ( 'div' ) ( ( { theme } ) => ( {
31
- margin : theme . spacing ( 1 , 0.5 ) ,
32
- } ) ) ;
33
-
34
- const StyledTypographyName = styled ( Typography ) ( ( { theme } ) => ( {
35
- fontWeight : 600 ,
36
- padding : theme . spacing ( 0.5 ) ,
37
- } ) ) ;
38
-
39
- const StyledIconButton = styled ( IconButton ) ( {
40
- textAlign : 'right' ,
41
- } ) ;
42
-
43
30
interface PlaygroundFeatureResultDetailsProps {
44
31
feature : PlaygroundFeatureSchema ;
45
32
input ?: PlaygroundRequestSchema ;
@@ -57,7 +44,7 @@ export const FeatureDetails = ({
57
44
return [
58
45
`This feature flag is True in ${ input ?. environment } because ` ,
59
46
'at least one strategy is True' ,
60
- theme . palette . success . main ,
47
+ theme . palette . success . contrastText ,
61
48
] ;
62
49
63
50
if (
@@ -67,43 +54,43 @@ export const FeatureDetails = ({
67
54
return [
68
55
`This feature flag is False in ${ input ?. environment } because ` ,
69
56
'parent dependency is not satisfied and the environment is disabled' ,
70
- theme . palette . error . main ,
57
+ theme . palette . error . contrastText ,
71
58
] ;
72
59
}
73
60
74
61
if ( ! feature . isEnabledInCurrentEnvironment )
75
62
return [
76
63
`This feature flag is False in ${ input ?. environment } because ` ,
77
64
'the environment is disabled' ,
78
- theme . palette . error . main ,
65
+ theme . palette . error . contrastText ,
79
66
] ;
80
67
81
68
if ( hasOnlyCustomStrategies ( feature ) )
82
69
return [
83
70
`This feature flag is Unknown in ${ input ?. environment } because ` ,
84
71
'no strategies could be fully evaluated' ,
85
- theme . palette . warning . main ,
72
+ theme . palette . warning . contrastText ,
86
73
] ;
87
74
88
75
if ( hasCustomStrategies ( feature ) )
89
76
return [
90
77
`This feature flag is Unknown in ${ input ?. environment } because ` ,
91
78
'not all strategies could be fully evaluated' ,
92
- theme . palette . warning . main ,
79
+ theme . palette . warning . contrastText ,
93
80
] ;
94
81
95
82
if ( feature . hasUnsatisfiedDependency ) {
96
83
return [
97
84
`This feature flag is False in ${ input ?. environment } because ` ,
98
85
'parent dependency is not satisfied' ,
99
- theme . palette . error . main ,
86
+ theme . palette . error . contrastText ,
100
87
] ;
101
88
}
102
89
103
90
return [
104
91
`This feature flag is False in ${ input ?. environment } because ` ,
105
92
'all strategies are either False or could not be fully evaluated' ,
106
- theme . palette . error . main ,
93
+ theme . palette . error . contrastText ,
107
94
] ;
108
95
} ) ( ) ;
109
96
@@ -124,61 +111,43 @@ export const FeatureDetails = ({
124
111
125
112
return (
126
113
< >
127
- < StyledDivWrapper >
128
- < StyledDivTitleRow >
129
- < StyledTypographyName variant = { 'subtitle1' } >
130
- { feature . name }
131
- </ StyledTypographyName >
132
- < ConditionallyRender
133
- condition = { feature ?. strategies ?. result !== 'unknown' }
134
- show = { ( ) => (
114
+ < HeaderRow >
115
+ < HeaderGroup >
116
+ < StyledTypographyName > { feature . name } </ StyledTypographyName >
117
+ < p >
118
+ { feature ?. strategies ?. result !== 'unknown' ? (
135
119
< PlaygroundResultChip
120
+ tabindex = { - 1 }
136
121
enabled = { feature . isEnabled }
137
122
label = { feature . isEnabled ? 'True' : 'False' }
138
123
/>
139
- ) }
140
- elseShow = { ( ) => (
124
+ ) : (
141
125
< PlaygroundResultChip
126
+ tabindex = { - 1 }
142
127
enabled = 'unknown'
143
128
label = { 'Unknown' }
144
129
showIcon = { false }
145
130
/>
146
131
) }
147
- / >
148
- </ StyledDivTitleRow >
149
- < StyledIconButton onClick = { onCloseClick } >
132
+ </ p >
133
+ </ HeaderGroup >
134
+ < IconButton aria-label = 'Close' onClick = { onCloseClick } >
150
135
< CloseOutlined />
151
- </ StyledIconButton >
152
- </ StyledDivWrapper >
153
- < StyledDivDescriptionRow >
154
- < Typography variant = 'body1' component = 'span' >
155
- { description }
156
- </ Typography >
157
- < Typography variant = 'subtitle1' color = { color } component = 'span' >
136
+ </ IconButton >
137
+ </ HeaderRow >
138
+ < p >
139
+ { description }
140
+ < Typography color = { color } component = 'span' >
158
141
{ reason }
159
142
</ Typography >
160
- < Typography variant = 'body1' component = 'span' >
161
- .
162
- </ Typography >
163
- </ StyledDivDescriptionRow >
164
- < ConditionallyRender
165
- condition = { Boolean ( noValueTxt ) }
166
- show = {
167
- < StyledDivAlertRow >
168
- < Alert color = { 'info' } > { noValueTxt } </ Alert >
169
- </ StyledDivAlertRow >
170
- }
171
- />
172
- < ConditionallyRender
173
- condition = { Boolean ( customStrategiesTxt ) }
174
- show = {
175
- < StyledDivAlertRow >
176
- < Alert severity = 'warning' color = 'info' >
177
- { customStrategiesTxt }
178
- </ Alert >
179
- </ StyledDivAlertRow >
180
- }
181
- />
143
+ .
144
+ </ p >
145
+ { noValueTxt ? < Alert color = { 'info' } > { noValueTxt } </ Alert > : null }
146
+ { customStrategiesTxt ? (
147
+ < Alert severity = 'warning' color = 'info' >
148
+ { customStrategiesTxt }
149
+ </ Alert >
150
+ ) : null }
182
151
</ >
183
152
) ;
184
153
} ;
0 commit comments