1
1
import React from 'react' ;
2
2
import { useAppContext } from './Context' ;
3
3
import QueryAdvise from './QueryAdvise' ;
4
+ import Queries from './Queries' ;
4
5
5
- import { getExpression , getFieldName , getQueryAdvise } from '../lib' ;
6
-
7
- function Section ( { children } ) {
8
- return < div className = "space-y-3" > { children } </ div > ;
9
- }
10
-
11
- function Heading ( { children } ) {
12
- return < h3 className = "font-bold text-xs" > { children } </ h3 > ;
13
- }
14
-
15
- function Field ( { method, data } ) {
16
- const { jsEditorRef, parsed } = useAppContext ( ) ;
17
-
18
- const isActive = parsed . expression ?. method === method ;
19
- const field = getFieldName ( method ) ;
20
- const value = data [ field ] ;
21
-
22
- const handleClick = value
23
- ? ( ) => {
24
- const expr = getExpression ( { method, data } ) ;
25
- jsEditorRef . current . setValue ( expr ) ;
26
- }
27
- : undefined ;
28
-
29
- return (
30
- < div
31
- className = { `text-xs field ${ isActive ? 'active' : '' } ` }
32
- data-clickable = { ! ! handleClick }
33
- onClick = { handleClick }
34
- >
35
- < div className = "text-gray-800 font-light" > { field } </ div >
36
- < div className = "truncate" >
37
- { value || < span className = "text-gray-400" > n/a</ span > }
38
- </ div >
39
- </ div >
40
- ) ;
41
- }
6
+ import { getQueryAdvise } from '../lib' ;
42
7
43
8
// for inputs, the role will only work if there is also a type attribute
44
9
function ElementInfo ( ) {
@@ -60,29 +25,7 @@ function ElementInfo() {
60
25
61
26
< div className = "my-6 border-b" />
62
27
63
- < div className = "grid grid-cols-2 gap-4" >
64
- < Section >
65
- < Heading > 1. Queries Accessible to Everyone</ Heading >
66
- < Field method = "getByRole" data = { data } />
67
- < Field method = "getByLabelText" data = { data } />
68
- < Field method = "getByPlaceholderText" data = { data } />
69
- < Field method = "getByText" data = { data } />
70
- < Field method = "getByDisplayValue" data = { data } />
71
- </ Section >
72
-
73
- < div className = "space-y-8" >
74
- < Section >
75
- < Heading > 2. Semantic Queries</ Heading >
76
- < Field method = "getByAltText" data = { data } />
77
- < Field method = "getByTitle" data = { data } />
78
- </ Section >
79
-
80
- < Section >
81
- < Heading > 3. TestId</ Heading >
82
- < Field method = "getByTestId" data = { data } />
83
- </ Section >
84
- </ div >
85
- </ div >
28
+ { ! parsed . error && < Queries data = { data } /> }
86
29
</ div >
87
30
) ;
88
31
}
0 commit comments