From 0ffd080141a11aebfce1845fcb3120ceaa6155e0 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 28 Jan 2020 09:27:16 -0800 Subject: [PATCH] Group selection view Summary: Added a group selection view in the support form to select the group to post the support form in. Added two groups for GraphQL's android and iOS. Also added a check to avoid selecting graphQL group unless GraphQL plugin is enabled. Reviewed By: mweststrate Differential Revision: D19538023 fbshipit-source-id: 022d592ae2aa17ed1e1b10a37b011ddc68df560a --- src/chrome/ListView.tsx | 55 ++++++++++++------- .../mainsidebar/MainSidebarUtilsSection.tsx | 4 +- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/chrome/ListView.tsx b/src/chrome/ListView.tsx index 141dba3de..dbcb94da8 100644 --- a/src/chrome/ListView.tsx +++ b/src/chrome/ListView.tsx @@ -33,11 +33,16 @@ type SubType = type: 'single'; }; +export type Element = { + label: string; + id: string; + unselectable?: {toolTipMessage: string}; +}; type Props = { onSubmit?: () => void; onChange: (elements: Array) => void; onHide: () => any; - elements: Array<{label: string; id: string}>; + elements: Array; title?: string; } & SubType; @@ -84,30 +89,36 @@ type RowComponentProps = { label: string; selected: boolean; onChange: (name: string, selected: boolean) => void; + disable: boolean; + toolTipMessage?: string; }; class RowComponent extends Component { render() { - const {id, label, selected, onChange} = this.props; + const {id, label, selected, onChange, disable, toolTipMessage} = this.props; return ( - - - {label} - - { - onChange(id, selected); - }} - /> - - - + + + + {label} + + { + onChange(id, selected); + }} + /> + + + + ); } @@ -129,9 +140,11 @@ export default class ListView extends Component { if (this.props.type === 'single') { if (!selected) { this.setState({selectedElements: selectedElements}); + this.props.onChange([...selectedElements]); } else { selectedElements.add(id); this.setState({selectedElements: selectedElements}); + this.props.onChange([...selectedElements]); } } else { if (selected) { @@ -152,7 +165,7 @@ export default class ListView extends Component { {this.props.title && {this.props.title}} - {this.props.elements.map(({id, label}) => { + {this.props.elements.map(({id, label, unselectable}) => { return ( { key={id} selected={this.state.selectedElements.has(id)} onChange={this.handleChange} + disable={unselectable != null} + toolTipMessage={unselectable?.toolTipMessage} /> ); })} diff --git a/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx b/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx index 51458a6ce..52c180c9e 100644 --- a/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx +++ b/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx @@ -93,7 +93,9 @@ function MainSidebarUtilsSection({ name={'app-dailies'} isActive={active} /> - Litho Support Request + + Litho/GraphQL Support Request + ); })()}