Skip to content

Commit

Permalink
Merge pull request #1 from tdesveaux/tds/react-base/fix_end_build_crash
Browse files Browse the repository at this point in the history
 www-react: Fix crash on build ending
  • Loading branch information
tdesveaux authored Oct 26, 2023
2 parents 3bc2181 + dcbeb7f commit c78ceb5
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 6 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
13 changes: 9 additions & 4 deletions www/react-base/src/components/RawData/RawData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,30 @@ 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 (isArrayOfObjectsRaw(value)) {
else if (value === undefined) {
return <dd>{"undefined"}&nbsp;</dd>;
}
else if (isArrayOfObjectsRaw(value)) {
return (
<dd>
<ArrowExpander isExpanded={isExpanded} setIsExpanded={setIsExpanded}/>
{isExpanded ? renderArrayElements(value as any[]) : <span>{JSON.stringify(value)}</span>}
</dd>
);
}
if (isObjectRaw(value)) {
else if (isObjectRaw(value)) {
return (
<dd>
<ArrowExpander isExpanded={isExpanded} setIsExpanded={setIsExpanded}/>
{isExpanded ? <div><RawData data={value}/></div> : <></>}
</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 c78ceb5

Please sign in to comment.