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