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
This commit is contained in:
Pritesh Nandgaonkar
2020-01-28 09:27:16 -08:00
committed by Facebook Github Bot
parent 67a1c27af2
commit 0ffd080141
2 changed files with 38 additions and 21 deletions

View File

@@ -33,11 +33,16 @@ type SubType =
type: 'single'; type: 'single';
}; };
export type Element = {
label: string;
id: string;
unselectable?: {toolTipMessage: string};
};
type Props = { type Props = {
onSubmit?: () => void; onSubmit?: () => void;
onChange: (elements: Array<string>) => void; onChange: (elements: Array<string>) => void;
onHide: () => any; onHide: () => any;
elements: Array<{label: string; id: string}>; elements: Array<Element>;
title?: string; title?: string;
} & SubType; } & SubType;
@@ -84,30 +89,36 @@ type RowComponentProps = {
label: string; label: string;
selected: boolean; selected: boolean;
onChange: (name: string, selected: boolean) => void; onChange: (name: string, selected: boolean) => void;
disable: boolean;
toolTipMessage?: string;
}; };
class RowComponent extends Component<RowComponentProps> { class RowComponent extends Component<RowComponentProps> {
render() { render() {
const {id, label, selected, onChange} = this.props; const {id, label, selected, onChange, disable, toolTipMessage} = this.props;
return ( return (
<FlexColumn> <FlexColumn>
<Padder <Tooltip
paddingRight={8} title={disable ? toolTipMessage : null}
paddingTop={8} options={{position: 'toRight'}}>
paddingBottom={8} <Padder
paddingLeft={8}> paddingRight={8}
<FlexRow> paddingTop={8}
<Text> {label} </Text> paddingBottom={8}
<Spacer /> paddingLeft={8}>
<Checkbox <FlexRow>
checked={selected} <Text> {label} </Text>
onChange={selected => { <Spacer />
onChange(id, selected); <Checkbox
}} checked={selected}
/> onChange={selected => {
</FlexRow> onChange(id, selected);
</Padder> }}
<Line /> />
</FlexRow>
</Padder>
<Line />
</Tooltip>
</FlexColumn> </FlexColumn>
); );
} }
@@ -129,9 +140,11 @@ export default class ListView extends Component<Props, State> {
if (this.props.type === 'single') { if (this.props.type === 'single') {
if (!selected) { if (!selected) {
this.setState({selectedElements: selectedElements}); this.setState({selectedElements: selectedElements});
this.props.onChange([...selectedElements]);
} else { } else {
selectedElements.add(id); selectedElements.add(id);
this.setState({selectedElements: selectedElements}); this.setState({selectedElements: selectedElements});
this.props.onChange([...selectedElements]);
} }
} else { } else {
if (selected) { if (selected) {
@@ -152,7 +165,7 @@ export default class ListView extends Component<Props, State> {
<FlexColumn> <FlexColumn>
{this.props.title && <Title>{this.props.title}</Title>} {this.props.title && <Title>{this.props.title}</Title>}
<RowComponentContainer> <RowComponentContainer>
{this.props.elements.map(({id, label}) => { {this.props.elements.map(({id, label, unselectable}) => {
return ( return (
<RowComponent <RowComponent
id={id} id={id}
@@ -160,6 +173,8 @@ export default class ListView extends Component<Props, State> {
key={id} key={id}
selected={this.state.selectedElements.has(id)} selected={this.state.selectedElements.has(id)}
onChange={this.handleChange} onChange={this.handleChange}
disable={unselectable != null}
toolTipMessage={unselectable?.toolTipMessage}
/> />
); );
})} })}

View File

@@ -93,7 +93,9 @@ function MainSidebarUtilsSection({
name={'app-dailies'} name={'app-dailies'}
isActive={active} isActive={active}
/> />
<PluginName isActive={active}>Litho Support Request</PluginName> <PluginName isActive={active}>
Litho/GraphQL Support Request
</PluginName>
</ListItem> </ListItem>
); );
})()} })()}