No data available

Summary: If there are no attributes for a given section, display a 'No data available' message rather than having an empty panel.

Reviewed By: antonk52

Differential Revision: D41400252

fbshipit-source-id: 0337702f638b9b917e6b3be5962838d2eb15c20d
This commit is contained in:
Lorenzo Blasa
2022-11-18 05:21:56 -08:00
committed by Facebook GitHub Bot
parent 6268c7b455
commit 1adcf2bc68
2 changed files with 33 additions and 17 deletions

View File

@@ -32,6 +32,7 @@ import {
RowStyle, RowStyle,
TextAttributeValueStyle, TextAttributeValueStyle,
} from './Styles'; } from './Styles';
import {Glyph} from 'flipper';
const NumberValue = styled.span(NumberAttributeValueStyle); const NumberValue = styled.span(NumberAttributeValueStyle);
const TextValue = styled.span(TextAttributeValueStyle); const TextValue = styled.span(TextAttributeValueStyle);
@@ -207,9 +208,9 @@ export const AttributesInspector: React.FC<Props> = ({
mode, mode,
rawDisplayEnabled = false, rawDisplayEnabled = false,
}) => { }) => {
return ( const keys = Object.keys(node.attributes);
<> const sections = keys
{Object.keys(node.attributes).map(function (key, _) { .map(function (key, _) {
const metadataId: number = Number(key); const metadataId: number = Number(key);
/** /**
* The node top-level attributes refer to the displayable panels. * The node top-level attributes refer to the displayable panels.
@@ -222,8 +223,22 @@ export const AttributesInspector: React.FC<Props> = ({
metadata.get(metadataId)?.name ?? '', metadata.get(metadataId)?.name ?? '',
node.attributes[metadataId] as InspectableObject, node.attributes[metadataId] as InspectableObject,
); );
})} })
{rawDisplayEnabled ?? ( .filter((section) => section !== undefined);
if (sections.length === 0) {
return (
<div style={{textAlign: 'center'}}>
<Glyph name="stop" size={24} style={{margin: 20}} />
<p>No data is available</p>
</div>
);
}
return (
<>
{...sections}
{rawDisplayEnabled && (
<Panel key="Raw" title="Raw Data" collapsed> <Panel key="Raw" title="Raw Data" collapsed>
<DataInspector data={node.attributes} /> <DataInspector data={node.attributes} />
</Panel> </Panel>

View File

@@ -254,7 +254,8 @@
16 16
], ],
"stop": [ "stop": [
16 16,
24
], ],
"target": [ "target": [
12, 12,