Add context menu item to remove watch expression
Summary: See https://github.com/facebook/flipper/issues/1185 Reviewed By: jknoxville Differential Revision: D21882508 fbshipit-source-id: 584c8b6eb01c821afe421d1b816fa77842c502fd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f981a772ec
commit
579172fa39
@@ -173,15 +173,8 @@ export default class LogWatcher extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onKeyDown = (e: React.KeyboardEvent) => {
|
onKeyDown = (e: React.KeyboardEvent) => {
|
||||||
if (
|
if (e.key === 'Delete' || e.key === 'Backspace') {
|
||||||
(e.key === 'Delete' || e.key === 'Backspace') &&
|
this.handleDelete();
|
||||||
this.state.highlightedRow != null
|
|
||||||
) {
|
|
||||||
this.props.onChange(
|
|
||||||
this.props.counters.filter(
|
|
||||||
({label}) => label !== this.state.highlightedRow,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,6 +184,16 @@ export default class LogWatcher extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleDelete = () => {
|
||||||
|
if (this.state.highlightedRow != null) {
|
||||||
|
this.props.onChange(
|
||||||
|
this.props.counters.filter(
|
||||||
|
({label}) => label !== this.state.highlightedRow,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<FlexColumn grow={true} tabIndex={-1} onKeyDown={this.onKeyDown}>
|
<FlexColumn grow={true} tabIndex={-1} onKeyDown={this.onKeyDown}>
|
||||||
@@ -220,6 +223,9 @@ export default class LogWatcher extends PureComponent<Props, State> {
|
|||||||
autoHeight={true}
|
autoHeight={true}
|
||||||
floating={false}
|
floating={false}
|
||||||
zebra={false}
|
zebra={false}
|
||||||
|
buildContextMenuItems={() => {
|
||||||
|
return [{label: 'Delete', click: this.handleDelete}];
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</WatcherPanel>
|
</WatcherPanel>
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
|
|||||||
Reference in New Issue
Block a user