Commit c2328a7 1 parent d912dc7 commit c2328a7 Copy full SHA for c2328a7
File tree 1 file changed +13
-19
lines changed
frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/ConstraintExecution
1 file changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -40,27 +40,11 @@ const ConstraintOk = () => {
40
40
) ;
41
41
} ;
42
42
43
- export const ConstraintError = ( {
44
- constraint,
45
- input,
46
- } : {
47
- constraint : PlaygroundConstraintSchema ;
48
- input ?: PlaygroundRequestSchema ;
49
- } ) => {
50
- const formatText = ( ) => {
51
- const value = input ?. context [ constraint . contextName ] ;
52
-
53
- if ( value ) {
54
- return `Constraint not met – the value in the context: { ${ value } } is not ${ constraint . operator } ${ constraint . contextName } ` ;
55
- }
56
-
57
- return `Constraint not met – no value was specified for ${ constraint . contextName } ` ;
58
- } ;
59
-
43
+ export const ConstraintError = ( { text } : { text : string } ) => {
60
44
return (
61
45
< StyledContainer variant = 'error' >
62
46
< Cancel aria-hidden = 'true' />
63
- < p > { formatText ( ) } </ p >
47
+ < p > { text } </ p >
64
48
</ StyledContainer >
65
49
) ;
66
50
} ;
@@ -71,13 +55,23 @@ export const ConstraintExecution: FC<IConstraintExecutionProps> = ({
71
55
} ) => {
72
56
if ( ! constraint ) return null ;
73
57
58
+ const errorText = ( ) => {
59
+ const value = input ?. context [ constraint . contextName ] ;
60
+
61
+ if ( value ) {
62
+ return `Constraint not met – the value in the context: { ${ value } } is not ${ constraint . operator } ${ constraint . contextName } ` ;
63
+ }
64
+
65
+ return `Constraint not met – no value was specified for ${ constraint . contextName } ` ;
66
+ } ;
67
+
74
68
return (
75
69
< >
76
70
< ConstraintItem { ...constraint } />
77
71
{ constraint . result ? (
78
72
< ConstraintOk />
79
73
) : (
80
- < ConstraintError input = { input } constraint = { constraint } />
74
+ < ConstraintError text = { errorText ( ) } />
81
75
) }
82
76
</ >
83
77
) ;
You can’t perform that action at this time.
0 commit comments