From a033f583d1bbe08c8b2aca9c82d00f27d869dcdd Mon Sep 17 00:00:00 2001 From: Paulo Pinheiro Date: Wed, 9 Jan 2019 03:50:29 -0800 Subject: [PATCH] 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 --- src/ui/components/ContextMenu.js | 2 +- src/ui/components/table/ManagedTable.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ui/components/ContextMenu.js b/src/ui/components/ContextMenu.js index 604ee6893..1aae92bbd 100644 --- a/src/ui/components/ContextMenu.js +++ b/src/ui/components/ContextMenu.js @@ -9,7 +9,7 @@ import * as React from 'react'; import FlexColumn from './FlexColumn.js'; import PropTypes from 'prop-types'; -type MenuTemplate = Array; +export type MenuTemplate = Array; type Props = { /** List of items in the context menu. Used for static menus. */ diff --git a/src/ui/components/table/ManagedTable.js b/src/ui/components/table/ManagedTable.js index 544422935..44c1ca507 100644 --- a/src/ui/components/table/ManagedTable.js +++ b/src/ui/components/table/ManagedTable.js @@ -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, + /** + * Allows to create context menu items for rows + */ + buildContextMenuItems?: () => MenuTemplate, |}; type ManagedTableState = {| @@ -541,7 +547,11 @@ class ManagedTable extends React.Component< ) : ( {({width, height}) => ( - +