File tree 2 files changed +7
-8
lines changed
screens/DatabaseScreen/QueryResultViewer/TableCell 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
1
import BaseType from './BaseType' ;
2
2
import deepEqual from 'deep-equal' ;
3
3
4
- export default class JsonType implements BaseType < object > {
5
- protected value ?: object | null ;
4
+ export default class JsonType implements BaseType < object | string > {
5
+ protected value ?: object | string | null ;
6
6
7
7
constructor ( value ?: object | string | null ) {
8
8
if ( typeof value === 'object' ) this . value = value ;
9
9
else if ( typeof value === 'string' ) {
10
10
try {
11
11
this . value = JSON . parse ( value ) ;
12
12
} catch {
13
- this . value = undefined ;
13
+ this . value = value ;
14
14
}
15
15
} else {
16
16
this . value = value ;
@@ -69,7 +69,7 @@ export default class JsonType implements BaseType<object> {
69
69
return stringValue . includes ( search ) ;
70
70
}
71
71
72
- getValue ( ) : object | null | undefined {
72
+ getValue ( ) : object | string | null | undefined {
73
73
return this . value ;
74
74
}
75
75
}
Original file line number Diff line number Diff line change @@ -66,13 +66,12 @@ function TableCellJsonEditor({
66
66
) ;
67
67
}
68
68
69
- function TableCellJsonContent ( { value } : TableEditableContentProps ) {
69
+ function TableCellJsonContent ( { value } : TableEditableContentProps < JsonType > ) {
70
70
return (
71
71
< TableCellContent
72
- value = { value }
72
+ value = { value . toNullableString ( ) }
73
73
badge = "json"
74
74
mono
75
- displayString = { value ? JSON . stringify ( value ) : undefined }
76
75
/>
77
76
) ;
78
77
}
@@ -88,7 +87,7 @@ const TableCellJson = createTableCellType({
88
87
return new JsonType ( null ) ;
89
88
} ,
90
89
onCopy : ( value : JsonType ) => {
91
- return JSON . stringify ( value ) ;
90
+ return value . toString ( ) ;
92
91
} ,
93
92
onPaste : ( value : string ) => {
94
93
return { accept : true , value : new JsonType ( value ) } ;
You can’t perform that action at this time.
0 commit comments