@@ -27,15 +27,22 @@ import ArrowUpFromLineIcon from '@gravity-ui/icons/svgs/arrow-up-from-line.svg';
27
27
28
28
import './JsonViewer.scss' ;
29
29
30
- interface JsonViewerProps {
31
- value : UnipikaValue ;
30
+ interface JsonViewerCommonProps {
32
31
unipikaSettings ?: UnipikaSettings ;
33
32
extraTools ?: React . ReactNode ;
34
33
tableSettings ?: DT100 . Settings ;
35
34
search ?: boolean ;
36
35
collapsedInitially ?: boolean ;
37
36
}
38
37
38
+ interface JsonViewerProps extends JsonViewerCommonProps {
39
+ value : UnipikaValue | { _error : string } ;
40
+ }
41
+
42
+ interface JsonViewerComponentProps extends JsonViewerCommonProps {
43
+ value : UnipikaValue ;
44
+ }
45
+
39
46
interface State {
40
47
flattenResult : FlattenUnipikaResult ;
41
48
value : JsonViewerProps [ 'value' ] ;
@@ -88,14 +95,26 @@ function calculateState(
88
95
) ;
89
96
}
90
97
91
- export function JsonViewer ( {
98
+ function isUnipikaValue ( value : UnipikaValue | { _error : string } ) : value is UnipikaValue {
99
+ return ! ( '_error' in value ) ;
100
+ }
101
+
102
+ export function JsonViewer ( props : JsonViewerProps ) {
103
+ const { value} = props ;
104
+ if ( ! isUnipikaValue ( value ) ) {
105
+ return value . _error ;
106
+ }
107
+ return < JsonViewerComponent { ...props } value = { value } /> ;
108
+ }
109
+
110
+ function JsonViewerComponent ( {
92
111
tableSettings,
93
112
value,
94
113
unipikaSettings,
95
114
search = true ,
96
115
extraTools,
97
116
collapsedInitially,
98
- } : JsonViewerProps ) {
117
+ } : JsonViewerComponentProps ) {
99
118
const [ caseSensitiveSearch , setCaseSensitiveSearch ] = useSetting (
100
119
CASE_SENSITIVE_JSON_SEARCH ,
101
120
false ,
0 commit comments