Enable override of context menu on ManagedTable. (#352)
Summary: This patch add a new prop on ManageTabled called buildContextMenuItems. It allows to override the current context menu when right click on the ManagedTable rows. Pull Request resolved: https://github.com/facebook/flipper/pull/352 Reviewed By: danielbuechele Differential Revision: D13590258 Pulled By: passy fbshipit-source-id: a90887a97136818611102a2628361c84988efeac
This commit is contained in:
committed by
Facebook Github Bot
parent
6d4728c41f
commit
a033f583d1
@@ -16,6 +16,8 @@ import type {
|
||||
TableOnAddFilter,
|
||||
} from './types.js';
|
||||
|
||||
import type {MenuTemplate} from '../ContextMenu.js';
|
||||
|
||||
import React from 'react';
|
||||
import styled from '../../styled/index.js';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
@@ -106,6 +108,10 @@ export type ManagedTableProps = {|
|
||||
* Rows that are highlighted initially.
|
||||
*/
|
||||
highlightedRows?: Set<string>,
|
||||
/**
|
||||
* Allows to create context menu items for rows
|
||||
*/
|
||||
buildContextMenuItems?: () => MenuTemplate,
|
||||
|};
|
||||
|
||||
type ManagedTableState = {|
|
||||
@@ -541,7 +547,11 @@ class ManagedTable extends React.Component<
|
||||
) : (
|
||||
<AutoSizer>
|
||||
{({width, height}) => (
|
||||
<ContextMenu buildItems={this.buildContextMenuItems}>
|
||||
<ContextMenu
|
||||
buildItems={
|
||||
this.props.buildContextMenuItems ||
|
||||
this.buildContextMenuItems
|
||||
}>
|
||||
<List
|
||||
itemCount={rows.length}
|
||||
itemSize={index =>
|
||||
|
||||
Reference in New Issue
Block a user