Badge for events instead of inline approach
Summary: Instead of showing events as inline attributes, just show a badge with the number of it. Event details will be displayed with other means: - Hover - Dedicated tab - Other Reviewed By: mweststrate Differential Revision: D43946575 fbshipit-source-id: 762a241040d7fc6afb2c86d129a620ff2bb15feb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ed4903576a
commit
d349135683
@@ -31,9 +31,9 @@ import {
|
|||||||
} from 'flipper-plugin';
|
} from 'flipper-plugin';
|
||||||
import {plugin} from '../index';
|
import {plugin} from '../index';
|
||||||
import {Glyph} from 'flipper';
|
import {Glyph} from 'flipper';
|
||||||
import {groupBy, head, isEqual, last} from 'lodash';
|
import {head, isEqual, last} from 'lodash';
|
||||||
import {reverse} from 'lodash/fp';
|
import {reverse} from 'lodash/fp';
|
||||||
import {Dropdown, Menu, Typography} from 'antd';
|
import {Badge, Dropdown, Menu, Typography} from 'antd';
|
||||||
import {UIDebuggerMenuItem} from './util/UIDebuggerMenuItem';
|
import {UIDebuggerMenuItem} from './util/UIDebuggerMenuItem';
|
||||||
|
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
@@ -232,6 +232,11 @@ function TreeItemContainer({
|
|||||||
onCollapseNode: (node: Id) => void;
|
onCollapseNode: (node: Id) => void;
|
||||||
onHoverNode: (node: Id) => void;
|
onHoverNode: (node: Id) => void;
|
||||||
}) {
|
}) {
|
||||||
|
let events = frameworkEvents.get(treeNode.id);
|
||||||
|
if (events) {
|
||||||
|
events = events.filter((e) => frameworkEventsMonitoring.get(e.type));
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{treeNode.indentGuide != null && (
|
{treeNode.indentGuide != null && (
|
||||||
@@ -253,7 +258,8 @@ function TreeItemContainer({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
onSelectNode(treeNode.id);
|
onSelectNode(treeNode.id);
|
||||||
}}
|
}}
|
||||||
item={treeNode}>
|
item={treeNode}
|
||||||
|
style={{overflow: 'visible'}}>
|
||||||
<ExpandedIconOrSpace
|
<ExpandedIconOrSpace
|
||||||
expanded={treeNode.isExpanded}
|
expanded={treeNode.isExpanded}
|
||||||
showIcon={treeNode.children.length > 0}
|
showIcon={treeNode.children.length > 0}
|
||||||
@@ -266,18 +272,32 @@ function TreeItemContainer({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{nodeIcon(treeNode)}
|
{nodeIcon(treeNode)}
|
||||||
<HighlightedText text={treeNode.name} />
|
{events ? (
|
||||||
<InlineAttributes attributes={treeNode.inlineAttributes} />
|
<Badge
|
||||||
<MonitoredEventSummary
|
key={treeNode.id}
|
||||||
node={treeNode}
|
count={events.length}
|
||||||
frameworkEvents={frameworkEvents}
|
size="small"
|
||||||
frameworkEventsMonitoring={frameworkEventsMonitoring}
|
color={theme.primaryColor}
|
||||||
/>
|
offset={[10, 5]}>
|
||||||
|
<TreeItemRowContent treeNode={treeNode} />
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<TreeItemRowContent treeNode={treeNode} />
|
||||||
|
)}
|
||||||
</TreeItemRow>
|
</TreeItemRow>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TreeItemRowContent({treeNode}: {treeNode: TreeNode}) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<HighlightedText text={treeNode.name} />
|
||||||
|
<InlineAttributes attributes={treeNode.inlineAttributes} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const TreeAttributeContainer = styled(Text)({
|
const TreeAttributeContainer = styled(Text)({
|
||||||
color: theme.textColorSecondary,
|
color: theme.textColorSecondary,
|
||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
@@ -285,35 +305,6 @@ const TreeAttributeContainer = styled(Text)({
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
});
|
});
|
||||||
|
|
||||||
function MonitoredEventSummary({
|
|
||||||
node,
|
|
||||||
frameworkEvents,
|
|
||||||
frameworkEventsMonitoring,
|
|
||||||
}: {
|
|
||||||
node: UINode;
|
|
||||||
frameworkEvents: Map<Id, FrameworkEvent[]>;
|
|
||||||
frameworkEventsMonitoring: Map<FrameworkEventType, boolean>;
|
|
||||||
}) {
|
|
||||||
const events = frameworkEvents.get(node.id);
|
|
||||||
if (events) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{Object.entries(groupBy(events, (e) => e.type))
|
|
||||||
.filter(([type]) => frameworkEventsMonitoring.get(type))
|
|
||||||
.map(([key, values]) => (
|
|
||||||
<TreeAttributeContainer key={key}>
|
|
||||||
<span style={{color: theme.errorColor}}>
|
|
||||||
{last(key.split(':'))}
|
|
||||||
</span>
|
|
||||||
<span>={values.length}</span>
|
|
||||||
</TreeAttributeContainer>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function InlineAttributes({attributes}: {attributes: Record<string, string>}) {
|
function InlineAttributes({attributes}: {attributes: Record<string, string>}) {
|
||||||
const highlightManager: HighlightManager = useHighlighter();
|
const highlightManager: HighlightManager = useHighlighter();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user