mirror of https://github.com/apache/superset.git
removes unused state values and redundant presence checks (#8130)
This commit is contained in:
parent
149d6344ac
commit
7f17ba7ee2
|
@ -125,8 +125,8 @@ class ScheduleQueryButton extends React.PureComponent {
|
|||
onDescriptionChange(e) {
|
||||
this.setState({ description: e.target.value });
|
||||
}
|
||||
toggleSchedule(e) {
|
||||
this.setState({ target: e.target, showSchedule: !this.state.showSchedule });
|
||||
toggleSchedule() {
|
||||
this.setState({ showSchedule: !this.state.showSchedule });
|
||||
}
|
||||
renderModalBody() {
|
||||
return (
|
||||
|
@ -170,9 +170,7 @@ class ScheduleQueryButton extends React.PureComponent {
|
|||
{this.props.scheduleQueryWarning && (
|
||||
<Row>
|
||||
<Col md={12}>
|
||||
<small>
|
||||
{this.props.scheduleQueryWarning}
|
||||
</small>
|
||||
<small>{this.props.scheduleQueryWarning}</small>
|
||||
</Col>
|
||||
</Row>
|
||||
)}
|
||||
|
@ -183,7 +181,9 @@ class ScheduleQueryButton extends React.PureComponent {
|
|||
return (
|
||||
<span className="ScheduleQueryButton">
|
||||
<ModalTrigger
|
||||
ref={(ref) => { this.saveModal = ref; }}
|
||||
ref={(ref) => {
|
||||
this.saveModal = ref;
|
||||
}}
|
||||
modalTitle={t('Schedule Query')}
|
||||
modalBody={this.renderModalBody()}
|
||||
triggerNode={
|
||||
|
|
|
@ -43,7 +43,6 @@ class ShareSqlLabQuery extends React.Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
shortUrl: t('Loading ...'),
|
||||
showOverlay: false,
|
||||
};
|
||||
this.getCopyUrl = this.getCopyUrl.bind(this);
|
||||
}
|
||||
|
@ -57,11 +56,10 @@ class ShareSqlLabQuery extends React.Component {
|
|||
this.setState({ shortUrl });
|
||||
})
|
||||
.catch((response) => {
|
||||
getClientErrorObject(response)
|
||||
.then(({ error }) => {
|
||||
this.props.addDangerToast(error);
|
||||
this.setState({ shortUrl: t('Error') });
|
||||
});
|
||||
getClientErrorObject(response).then(({ error }) => {
|
||||
this.props.addDangerToast(error);
|
||||
this.setState({ shortUrl: t('Error') });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ const defaultProps = {
|
|||
export default class SqlEditorLeftBar extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
schemaLoading: false,
|
||||
schemaOptions: [],
|
||||
tableLoading: false,
|
||||
tableOptions: [],
|
||||
};
|
||||
this.resetState = this.resetState.bind(this);
|
||||
this.onSchemaChange = this.onSchemaChange.bind(this);
|
||||
this.onSchemasLoad = this.onSchemasLoad.bind(this);
|
||||
|
@ -76,7 +70,10 @@ export default class SqlEditorLeftBar extends React.PureComponent {
|
|||
}
|
||||
|
||||
dbMutator(data) {
|
||||
const options = data.result.map(db => ({ value: db.id, label: db.database_name }));
|
||||
const options = data.result.map(db => ({
|
||||
value: db.id,
|
||||
label: db.database_name,
|
||||
}));
|
||||
this.props.actions.setDatabases(data.result);
|
||||
if (data.result.length === 0) {
|
||||
this.props.actions.addDangerToast(t("It seems you don't have access to any database"));
|
||||
|
@ -89,12 +86,10 @@ export default class SqlEditorLeftBar extends React.PureComponent {
|
|||
}
|
||||
changeTable(tableOpt) {
|
||||
if (!tableOpt) {
|
||||
this.setState({ tableName: '' });
|
||||
return;
|
||||
}
|
||||
const schemaName = tableOpt.value.schema;
|
||||
const tableName = tableOpt.value.table;
|
||||
this.setState({ tableName });
|
||||
this.props.actions.queryEditorSetSchema(this.props.queryEditor, schemaName);
|
||||
this.props.actions.addTable(this.props.queryEditor, tableName, schemaName);
|
||||
}
|
||||
|
@ -129,10 +124,11 @@ export default class SqlEditorLeftBar extends React.PureComponent {
|
|||
))}
|
||||
</div>
|
||||
</div>
|
||||
{shouldShowReset &&
|
||||
{shouldShowReset && (
|
||||
<Button bsSize="small" bsStyle="danger" onClick={this.resetState}>
|
||||
<i className="fa fa-bomb" /> {t('Reset State')}
|
||||
</Button>}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -45,14 +45,17 @@ export default class ErrorBoundary extends React.Component {
|
|||
render() {
|
||||
const { error, info } = this.state;
|
||||
if (error) {
|
||||
const firstLine = error ? error.toString() : null;
|
||||
const firstLine = error.toString();
|
||||
const message = (
|
||||
<span>
|
||||
<strong>{t('Unexpected error')}</strong>{firstLine ? `: ${firstLine}` : ''}
|
||||
</span>);
|
||||
<strong>{t('Unexpected error')}</strong>
|
||||
{firstLine ? `: ${firstLine}` : ''}
|
||||
</span>
|
||||
);
|
||||
if (this.props.showMessage) {
|
||||
return (
|
||||
<StackTraceMessage message={message} stackTrace={info ? info.componentStack : null} />);
|
||||
<StackTraceMessage message={message} stackTrace={info ? info.componentStack : null} />
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ class Chart extends React.Component {
|
|||
const { queryResponse, chartUpdateEndTime } = chart;
|
||||
const isCached = queryResponse && queryResponse.is_cached;
|
||||
const cachedDttm = queryResponse && queryResponse.cached_dttm;
|
||||
const isOverflowable = OVERFLOWABLE_VIZ_TYPES.has(slice && slice.viz_type);
|
||||
const isOverflowable = OVERFLOWABLE_VIZ_TYPES.has(slice.viz_type);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue