fix: enforce mandatory chart name on save and edit (#10482)

* fix: show empty charts as empty in chart list view

* migrate ControlLabel to FormLabel and enforce requred fields

* lint

* reorder buttons
This commit is contained in:
Ville Brofeldt 2020-07-31 19:30:02 +03:00 committed by GitHub
parent 6243a46ca6
commit 9eab29aeaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -262,18 +262,18 @@ function PropertiesModal({ slice, onHide, onSave }: InternalProps) {
</Row>
</Modal.Body>
<Modal.Footer>
<Button type="button" bsSize="sm" onClick={onHide}>
{t('Cancel')}
</Button>
<Button
type="submit"
bsSize="sm"
bsStyle="primary"
className="m-r-5"
disabled={!owners || submitting}
disabled={!owners || submitting || !name}
>
{t('Save')}
</Button>
<Button type="button" bsSize="sm" onClick={onHide}>
{t('Cancel')}
</Button>
<Dialog ref={errorDialog} />
</Modal.Footer>
</form>

View File

@ -25,10 +25,10 @@ import {
Button,
FormControl,
FormGroup,
ControlLabel,
Modal,
Radio,
} from 'react-bootstrap';
import FormLabel from 'src/components/FormLabel';
import { CreatableSelect } from 'src/components/Select/SupersetStyledSelect';
import { t } from '@superset-ui/translation';
import ReactMarkdown from 'react-markdown';
@ -176,7 +176,7 @@ class SaveModal extends React.Component {
</FormGroup>
<hr />
<FormGroup>
<ControlLabel>{t('Chart name')}</ControlLabel>
<FormLabel required>{t('Chart name')}</FormLabel>
<FormControl
name="new_slice_name"
type="text"
@ -187,7 +187,7 @@ class SaveModal extends React.Component {
/>
</FormGroup>
<FormGroup>
<ControlLabel>{t('Add to dashboard')}</ControlLabel>
<FormLabel required>{t('Add to dashboard')}</FormLabel>
<CreatableSelect
id="dashboard-creatable-select"
className="save-modal-selector"
@ -224,7 +224,11 @@ class SaveModal extends React.Component {
type="button"
id="btn_modal_save_goto_dash"
bsSize="sm"
disabled={canNotSaveToDash || !this.state.newDashboardName}
disabled={
canNotSaveToDash ||
!this.state.newSliceName ||
!this.state.newDashboardName
}
onClick={this.saveOrOverwrite.bind(this, true)}
>
{t('Save & go to dashboard')}
@ -235,6 +239,7 @@ class SaveModal extends React.Component {
bsSize="sm"
bsStyle="primary"
onClick={this.saveOrOverwrite.bind(this, false)}
disabled={!this.state.newSliceName}
>
{t('Save')}
</Button>