Show tooltip when no plugins are selected

Summary: Shows tooltip when no plugins are selected. Before it used to select all the plugins

Reviewed By: jknoxville

Differential Revision: D19537054

fbshipit-source-id: 567b90f981a2a2ddcf68a1dce902db0a9d6214d2
This commit is contained in:
Pritesh Nandgaonkar
2020-01-23 10:03:27 -08:00
committed by Facebook Github Bot
parent dc60d33b3a
commit f61d578b26
2 changed files with 18 additions and 16 deletions

View File

@@ -76,12 +76,6 @@ class ExportDataPluginSheet extends Component<Props, State> {
}; };
} }
componentDidMount() {
if (this.props.plugins.selectedPlugins.length <= 0) {
this.props.setSelectedPlugins(this.state.availablePluginsToExport);
}
}
render() { render() {
const {onHide} = this.props; const {onHide} = this.props;
const onHideWithUnsettingShare = () => { const onHideWithUnsettingShare = () => {
@@ -119,13 +113,7 @@ class ExportDataPluginSheet extends Component<Props, State> {
} }
}} }}
onChange={selectedArray => { onChange={selectedArray => {
if (selectedArray.length > 0) { this.props.setSelectedPlugins(selectedArray);
this.props.setSelectedPlugins(selectedArray);
} else {
this.props.setSelectedPlugins(
this.state.availablePluginsToExport,
);
}
}} }}
elements={this.state.availablePluginsToExport} elements={this.state.availablePluginsToExport}
selectedElements={new Set(this.props.plugins.selectedPlugins)} selectedElements={new Set(this.props.plugins.selectedPlugins)}

View File

@@ -17,6 +17,7 @@ import {
Checkbox, Checkbox,
colors, colors,
View, View,
Tooltip,
} from '../ui'; } from '../ui';
import React, {Component} from 'react'; import React, {Component} from 'react';
@@ -169,9 +170,22 @@ export default class ListView extends Component<Props, State> {
<Button compact padded onClick={this.props.onHide}> <Button compact padded onClick={this.props.onHide}>
Close Close
</Button> </Button>
<Button compact padded type="primary" onClick={onSubmit}> <Tooltip
Submit title={
</Button> this.state.selectedElements.size <= 0
? `Please select atleast one plugin`
: null
}
options={{position: 'toRight'}}>
<Button
compact
padded
type="primary"
onClick={onSubmit}
disabled={this.state.selectedElements.size <= 0}>
Submit
</Button>
</Tooltip>
</FlexRow> </FlexRow>
</Padder> </Padder>
)} )}