Add pluralization to Send to Dashboard button

pull/4229/head
Alirie Gray 2018-08-17 11:27:56 -07:00
parent 4ff3d719cd
commit c9e07d72a7
1 changed files with 7 additions and 4 deletions

View File

@ -48,7 +48,10 @@ class SendToDashboardOverlay extends PureComponent<Props, State> {
public render() { public render() {
const {onCancel} = this.props const {onCancel} = this.props
const {hasQuery, name} = this.state const {hasQuery, name, selectedIDs} = this.state
const numberDashboards = selectedIDs.length > 1 ? selectedIDs.length : ''
const pluralizer = selectedIDs.length > 1 ? 's' : ''
return ( return (
<OverlayContainer> <OverlayContainer>
@ -64,7 +67,7 @@ class SendToDashboardOverlay extends PureComponent<Props, State> {
onChange={this.handleChangeName} onChange={this.handleChangeName}
/> />
</Form.Element> </Form.Element>
<Form.Element> <Form.Element label="Choose 1 or more Dashboards">
<MultiSelectDropdown <MultiSelectDropdown
onChange={this.handleSelect} onChange={this.handleSelect}
selectedIDs={this.state.selectedIDs} selectedIDs={this.state.selectedIDs}
@ -84,10 +87,10 @@ class SendToDashboardOverlay extends PureComponent<Props, State> {
<button <button
className="button button-md button-success" className="button button-md button-success"
style={{margin: 5}} style={{margin: 5}}
disabled={!hasQuery} disabled={!hasQuery || selectedIDs.length === 0}
onClick={this.sendToDashboard} onClick={this.sendToDashboard}
> >
Send to Dashboard {`Send to ${numberDashboards} Dashboard${pluralizer}`}
</button> </button>
</div> </div>
</Form.Footer> </Form.Footer>