Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mitm-superset
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Machine Data
mitm-superset
Commits
56bf17f8
Unverified
Commit
56bf17f8
authored
3 months ago
by
JUST.in DO IT
Committed by
GitHub
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(sqllab): Invalid display of table column keys (#32763)
parent
b92909d6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
superset-frontend/src/components/JsonModal/JsonModal.test.tsx
+15
-0
15 additions, 0 deletions
...rset-frontend/src/components/JsonModal/JsonModal.test.tsx
superset-frontend/src/components/JsonModal/index.tsx
+13
-4
13 additions, 4 deletions
superset-frontend/src/components/JsonModal/index.tsx
with
28 additions
and
4 deletions
superset-frontend/src/components/JsonModal/JsonModal.test.tsx
+
15
−
0
View file @
56bf17f8
...
@@ -42,6 +42,21 @@ test('renders JSON object in a tree view in a modal', () => {
...
@@ -42,6 +42,21 @@ test('renders JSON object in a tree view in a modal', () => {
expect
(
getByTestId
(
'
mock-json-tree
'
)).
toBeInTheDocument
();
expect
(
getByTestId
(
'
mock-json-tree
'
)).
toBeInTheDocument
();
});
});
test
(
'
renders an object in a tree view in a modal
'
,
()
=>
{
const
jsonData
=
{
a
:
1
};
const
expected
=
JSON
.
stringify
(
jsonData
);
const
{
getByText
,
getByTestId
,
queryByTestId
}
=
render
(
<
JsonModal
jsonObject
=
{
jsonData
}
jsonValue
=
{
jsonData
}
modalTitle
=
"title"
/>,
{
useRedux
:
true
,
},
);
expect
(
queryByTestId
(
'
mock-json-tree
'
)).
not
.
toBeInTheDocument
();
const
link
=
getByText
(
expected
);
fireEvent
.
click
(
link
);
expect
(
getByTestId
(
'
mock-json-tree
'
)).
toBeInTheDocument
();
});
test
(
'
renders bigInt value in a number format
'
,
()
=>
{
test
(
'
renders bigInt value in a number format
'
,
()
=>
{
expect
(
convertBigIntStrToNumber
(
'
123
'
)).
toBe
(
'
123
'
);
expect
(
convertBigIntStrToNumber
(
'
123
'
)).
toBe
(
'
123
'
);
expect
(
convertBigIntStrToNumber
(
'
some string value
'
)).
toBe
(
expect
(
convertBigIntStrToNumber
(
'
some string value
'
)).
toBe
(
...
...
This diff is collapsed.
Click to expand it.
superset-frontend/src/components/JsonModal/index.tsx
+
13
−
4
View file @
56bf17f8
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
* under the License.
* under the License.
*/
*/
import
JSONbig
from
'
json-bigint
'
;
import
JSONbig
from
'
json-bigint
'
;
import
{
FC
}
from
'
react
'
;
import
{
FC
,
useMemo
}
from
'
react
'
;
import
{
JSONTree
}
from
'
react-json-tree
'
;
import
{
JSONTree
}
from
'
react-json-tree
'
;
import
{
useJsonTreeTheme
}
from
'
src/hooks/useJsonTreeTheme
'
;
import
{
useJsonTreeTheme
}
from
'
src/hooks/useJsonTreeTheme
'
;
import
Button
from
'
../Button
'
;
import
Button
from
'
../Button
'
;
...
@@ -46,6 +46,10 @@ import ModalTrigger from '../ModalTrigger';
...
@@ -46,6 +46,10 @@ import ModalTrigger from '../ModalTrigger';
export
function
safeJsonObjectParse
(
export
function
safeJsonObjectParse
(
data
:
unknown
,
data
:
unknown
,
):
null
|
unknown
[]
|
Record
<
string
,
unknown
>
{
):
null
|
unknown
[]
|
Record
<
string
,
unknown
>
{
if
(
typeof
data
===
'
object
'
)
{
return
data
as
null
|
unknown
[]
|
Record
<
string
,
unknown
>
;
}
// First perform a cheap proxy to avoid calling JSON.parse on data that is clearly not a
// First perform a cheap proxy to avoid calling JSON.parse on data that is clearly not a
// JSON object or array
// JSON object or array
if
(
if
(
...
@@ -78,7 +82,7 @@ function renderBigIntStrToNumber(value: string | number) {
...
@@ -78,7 +82,7 @@ function renderBigIntStrToNumber(value: string | number) {
return
<>
{
convertBigIntStrToNumber
(
value
)
}
</>;
return
<>
{
convertBigIntStrToNumber
(
value
)
}
</>;
}
}
type
CellDataType
=
string
|
number
|
null
;
type
CellDataType
=
string
|
number
|
null
|
object
;
export
interface
Props
{
export
interface
Props
{
modalTitle
:
string
;
modalTitle
:
string
;
...
@@ -88,6 +92,11 @@ export interface Props {
...
@@ -88,6 +92,11 @@ export interface Props {
export
const
JsonModal
:
FC
<
Props
>
=
({
modalTitle
,
jsonObject
,
jsonValue
})
=>
{
export
const
JsonModal
:
FC
<
Props
>
=
({
modalTitle
,
jsonObject
,
jsonValue
})
=>
{
const
jsonTreeTheme
=
useJsonTreeTheme
();
const
jsonTreeTheme
=
useJsonTreeTheme
();
const
content
=
useMemo
(
()
=>
typeof
jsonValue
===
'
object
'
?
JSON
.
stringify
(
jsonValue
)
:
jsonValue
,
[
jsonValue
],
);
return
(
return
(
<
ModalTrigger
<
ModalTrigger
...
@@ -100,11 +109,11 @@ export const JsonModal: FC<Props> = ({ modalTitle, jsonObject, jsonValue }) => {
...
@@ -100,11 +109,11 @@ export const JsonModal: FC<Props> = ({ modalTitle, jsonObject, jsonValue }) => {
}
}
modalFooter
=
{
modalFooter
=
{
<
Button
>
<
Button
>
<
CopyToClipboard
shouldShowText
=
{
false
}
text
=
{
jsonValue
}
/>
<
CopyToClipboard
shouldShowText
=
{
false
}
text
=
{
content
}
/>
</
Button
>
</
Button
>
}
}
modalTitle
=
{
modalTitle
}
modalTitle
=
{
modalTitle
}
triggerNode
=
{
<>
{
jsonValue
}
</>
}
triggerNode
=
{
<>
{
content
}
</>
}
/>
/>
);
);
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment