Skip to content

Commit

Permalink
Adding warning message for sqllab save query (apache#7028)
Browse files Browse the repository at this point in the history
  • Loading branch information
michellethomas authored Mar 18, 2019
1 parent c771625 commit ead3d48
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions superset/assets/src/SqlLab/components/SaveQuery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ const propTypes = {
dbId: PropTypes.number,
animation: PropTypes.bool,
onSave: PropTypes.func,
saveQueryWarning: PropTypes.string,
};
const defaultProps = {
defaultLabel: t('Undefined'),
animation: true,
onSave: () => {},
saveQueryWarning: null,
};

class SaveQuery extends React.PureComponent {
Expand Down Expand Up @@ -108,6 +110,18 @@ class SaveQuery extends React.PureComponent {
</Col>
</Row>
<br />
{this.props.saveQueryWarning && (
<div>
<Row>
<Col md={12}>
<small>
{this.props.saveQueryWarning}
</small>
</Col>
</Row>
<br />
</div>
)}
<Row>
<Col md={12}>
<Button
Expand Down
3 changes: 3 additions & 0 deletions superset/assets/src/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ const propTypes = {
hideLeftBar: PropTypes.bool,
defaultQueryLimit: PropTypes.number.isRequired,
maxRow: PropTypes.number.isRequired,
saveQueryWarning: PropTypes.string,
};

const defaultProps = {
database: null,
latestQuery: null,
hideLeftBar: false,
saveQueryWarning: null,
};

class SqlEditor extends React.PureComponent {
Expand Down Expand Up @@ -309,6 +311,7 @@ class SqlEditor extends React.PureComponent {
onSave={this.props.actions.saveQuery}
schema={qe.schema}
dbId={qe.dbId}
saveQueryWarning={this.props.saveQueryWarning}
/>
</span>
<span className="m-r-5">
Expand Down
4 changes: 4 additions & 0 deletions superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ const propTypes = {
tabHistory: PropTypes.array.isRequired,
tables: PropTypes.array.isRequired,
offline: PropTypes.bool,
saveQueryWarning: PropTypes.string,
};
const defaultProps = {
queryEditors: [],
offline: false,
saveQueryWarning: null,
};

let queryCount = 1;
Expand Down Expand Up @@ -247,6 +249,7 @@ class TabbedSqlEditors extends React.PureComponent {
hideLeftBar={this.state.hideLeftBar}
defaultQueryLimit={this.props.defaultQueryLimit}
maxRow={this.props.maxRow}
saveQueryWarning={this.props.saveQueryWarning}
/>
)}
</div>
Expand Down Expand Up @@ -289,6 +292,7 @@ function mapStateToProps({ sqlLab, common }) {
offline: sqlLab.offline,
defaultQueryLimit: common.conf.DEFAULT_SQLLAB_LIMIT,
maxRow: common.conf.SQL_MAX_ROW,
saveQueryWarning: common.conf.SQLLAB_SAVE_WARNING_MESSAGE,
};
}
function mapDispatchToProps(dispatch) {
Expand Down
3 changes: 3 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@
# Maximum number of tables/views displayed in the dropdown window in SQL Lab.
MAX_TABLE_NAMES = 3000

# Adds a warning message on sqllab save query modal.
SQLLAB_SAVE_WARNING_MESSAGE = None

# If defined, shows this text in an alert-warning box in the navbar
# one example use case may be "STAGING" to make it clear that this is
# not the production version of the site.
Expand Down
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'DEFAULT_SQLLAB_LIMIT',
'SQL_MAX_ROW',
'SUPERSET_WEBSERVER_DOMAINS',
'SQLLAB_SAVE_WARNING_MESSAGE',
)


Expand Down

0 comments on commit ead3d48

Please sign in to comment.