Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
No data available
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lblasa authored and facebook-github-bot committed Nov 18, 2022
1 parent 6268c7b commit 1adcf2b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
RowStyle,
TextAttributeValueStyle,
} from './Styles';
import {Glyph} from 'flipper';

const NumberValue = styled.span(NumberAttributeValueStyle);
const TextValue = styled.span(TextAttributeValueStyle);
Expand Down Expand Up @@ -207,23 +208,37 @@ export const AttributesInspector: React.FC<Props> = ({
mode,
rawDisplayEnabled = false,
}) => {
const keys = Object.keys(node.attributes);
const sections = keys
.map(function (key, _) {
const metadataId: number = Number(key);
/**
* The node top-level attributes refer to the displayable panels.
* The panel name is obtained by querying the metadata.
* The inspectable contains the actual attributes belonging to each panel.
*/
return createSection(
mode,
metadata,
metadata.get(metadataId)?.name ?? '',
node.attributes[metadataId] as InspectableObject,
);
})
.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 (
<>
{Object.keys(node.attributes).map(function (key, _) {
const metadataId: number = Number(key);
/**
* The node top-level attributes refer to the displayable panels.
* The panel name is obtained by querying the metadata.
* The inspectable contains the actual attributes belonging to each panel.
*/
return createSection(
mode,
metadata,
metadata.get(metadataId)?.name ?? '',
node.attributes[metadataId] as InspectableObject,
);
})}
{rawDisplayEnabled ?? (
{...sections}
{rawDisplayEnabled && (
<Panel key="Raw" title="Raw Data" collapsed>
<DataInspector data={node.attributes} />
</Panel>
Expand Down
5 changes: 3 additions & 2 deletions desktop/static/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@
16
],
"stop": [
16
16,
24
],
"target": [
12,
Expand Down Expand Up @@ -658,4 +659,4 @@
"square-ruler": [
16
]
}
}

0 comments on commit 1adcf2b

Please sign in to comment.