Skip to content

Commit

Permalink
[sql_lab]Disabled run query button if sql query editor is empty (apac…
Browse files Browse the repository at this point in the history
…he#4728)

* Disabled run query button if sql query editor is empty

* Removing unnecessary white space

* Fix failing test for sql props

* Adding sql variable into propTypes and defaultProps
  • Loading branch information
Prashant authored and michellethomas committed May 23, 2018
1 parent e89fc51 commit f228b33
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const propTypes = {
runQuery: PropTypes.func.isRequired,
selectedText: PropTypes.string,
stopQuery: PropTypes.func.isRequired,
sql: PropTypes.string.isRequired,
};
const defaultProps = {
allowAsync: false,
sql: '',
};

export default function RunQueryActionButton(props) {
Expand All @@ -32,6 +34,7 @@ export default function RunQueryActionButton(props) {
onClick={() => props.runQuery(false)}
key="run-btn"
tooltip={t('Run query synchronously')}
disabled={!props.sql.trim()}
>
<i className="fa fa-refresh" /> {runBtnText}
</Button>
Expand All @@ -43,6 +46,7 @@ export default function RunQueryActionButton(props) {
onClick={() => props.runQuery(true)}
key="run-async-btn"
tooltip={t('Run query asynchronously')}
disabled={!props.sql.trim()}
>
<i className="fa fa-table" /> {runBtnText}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class SqlEditor extends React.PureComponent {
runQuery={this.runQuery}
selectedText={qe.selectedText}
stopQuery={this.stopQuery}
sql={this.state.sql}
/>
</span>
<span className="m-r-5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('RunQueryActionButton', () => {
runQuery: () => {}, // eslint-disable-line
selectedText: null,
stopQuery: () => {}, // eslint-disable-line
sql: '',
};

beforeEach(() => {
Expand Down

0 comments on commit f228b33

Please sign in to comment.