Skip to content

Commit

Permalink
Merge pull request #7181 from tdesveaux/tds/react-base/fix_end_build_…
Browse files Browse the repository at this point in the history
…crash

www-react: Fix crash on build ending
  • Loading branch information
p12tic committed Nov 7, 2023
2 parents 637fe76 + 8e0ef21 commit 114c8cc
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 4 deletions.
10 changes: 10 additions & 0 deletions www/react-base/src/components/RawData/RawData.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ describe('RawData component', function() {
float: 123.4,
boolean: true,
array: [321, "string", true],
null: null,
undefined: undefined,
}

assertRenderSnapshot(obj);
Expand All @@ -61,6 +63,8 @@ describe('RawData component', function() {
float: 123.4,
boolean: true,
array: observable([321, "string", true]),
null: null,
undefined: undefined,
});

assertRenderSnapshot(obj);
Expand All @@ -73,6 +77,8 @@ describe('RawData component', function() {
{int: 123},
{float: 123.4},
{boolean: true},
{null: null},
{undefined: undefined},
],
};

Expand All @@ -86,6 +92,8 @@ describe('RawData component', function() {
{int: 123},
{float: 123.4},
{boolean: true},
{null: null},
{undefined: undefined},
],
};

Expand All @@ -99,6 +107,8 @@ describe('RawData component', function() {
observable({int: 123}),
observable({float: 123.4}),
observable({boolean: true}),
observable({null: null}),
observable({undefined: undefined}),
],
});

Expand Down
9 changes: 7 additions & 2 deletions www/react-base/src/components/RawData/RawData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ export const RawData = ({data}: RawDataProps) => {
}

const renderDataElement = (value: any) => {
if (!isObjectRaw(value) && !isArrayOfObjectsRaw(value)) {
return <dd>{value === null ? "null" : value.toString()}&nbsp;</dd>;
if (value === null) {
return <dd>{"null"}&nbsp;</dd>;
}
if (value === undefined) {
return <dd>{"undefined"}&nbsp;</dd>;
}
if (isArrayOfObjectsRaw(value)) {
return (
Expand All @@ -71,6 +74,8 @@ export const RawData = ({data}: RawDataProps) => {
</dd>
)
}

return <dd>{value.toString()}&nbsp;</dd>;
}

const renderElements = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`RawData component object with array of objects 1`] = `
/>
</svg>
<span>
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true}]
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true},{"null":null},{}]
</span>
</dd>
</div>
Expand Down Expand Up @@ -139,6 +139,40 @@ exports[`RawData component object with array of objects expanded 1`] = `
</div>
</dl>
</li>
<li>
<dl
className="dl-horizontal"
>
<div
className="bb-raw-data-key-value"
>
<dt>
null
</dt>
<dd>
null
 
</dd>
</div>
</dl>
</li>
<li>
<dl
className="dl-horizontal"
>
<div
className="bb-raw-data-key-value"
>
<dt>
undefined
</dt>
<dd>
undefined
 
</dd>
</div>
</dl>
</li>
</ul>
</dd>
</div>
Expand Down Expand Up @@ -204,6 +238,28 @@ exports[`RawData component observable object 1`] = `
 
</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
null
</dt>
<dd>
null
 
</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
undefined
</dt>
<dd>
undefined
 
</dd>
</div>
</dl>
`;

Expand Down Expand Up @@ -239,7 +295,7 @@ exports[`RawData component observable object with array of objects 1`] = `
/>
</svg>
<span>
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true}]
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true},{"null":null},{}]
</span>
</dd>
</div>
Expand Down Expand Up @@ -305,5 +361,27 @@ exports[`RawData component simple object 1`] = `
 
</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
null
</dt>
<dd>
null
 
</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
undefined
</dt>
<dd>
undefined
 
</dd>
</div>
</dl>
`;

0 comments on commit 114c8cc

Please sign in to comment.