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
@@ -9,7 +9,7 @@ import * as React from 'react';
|
|||||||
import FlexColumn from './FlexColumn.js';
|
import FlexColumn from './FlexColumn.js';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
type MenuTemplate = Array<Electron$MenuItemOptions>;
|
export type MenuTemplate = Array<Electron$MenuItemOptions>;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
/** List of items in the context menu. Used for static menus. */
|
/** List of items in the context menu. Used for static menus. */
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import type {
|
|||||||
TableOnAddFilter,
|
TableOnAddFilter,
|
||||||
} from './types.js';
|
} from './types.js';
|
||||||
|
|
||||||
|
import type {MenuTemplate} from '../ContextMenu.js';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from '../../styled/index.js';
|
import styled from '../../styled/index.js';
|
||||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||||
@@ -106,6 +108,10 @@ export type ManagedTableProps = {|
|
|||||||
* Rows that are highlighted initially.
|
* Rows that are highlighted initially.
|
||||||
*/
|
*/
|
||||||
highlightedRows?: Set<string>,
|
highlightedRows?: Set<string>,
|
||||||
|
/**
|
||||||
|
* Allows to create context menu items for rows
|
||||||
|
*/
|
||||||
|
buildContextMenuItems?: () => MenuTemplate,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
type ManagedTableState = {|
|
type ManagedTableState = {|
|
||||||
@@ -541,7 +547,11 @@ class ManagedTable extends React.Component<
|
|||||||
) : (
|
) : (
|
||||||
<AutoSizer>
|
<AutoSizer>
|
||||||
{({width, height}) => (
|
{({width, height}) => (
|
||||||
<ContextMenu buildItems={this.buildContextMenuItems}>
|
<ContextMenu
|
||||||
|
buildItems={
|
||||||
|
this.props.buildContextMenuItems ||
|
||||||
|
this.buildContextMenuItems
|
||||||
|
}>
|
||||||
<List
|
<List
|
||||||
itemCount={rows.length}
|
itemCount={rows.length}
|
||||||
itemSize={index =>
|
itemSize={index =>
|
||||||
|
|||||||
Reference in New Issue
Block a user