You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/07/02 00:31:29 UTC
[GitHub] [incubator-superset] ktmud opened a new pull request #10224: fix: chart validation error not cleared on control value update
ktmud opened a new pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224
### SUMMARY
This fixes another bug introduced by #10113 : when a chart has frontend validator errors (e.g. empty metrics), it's impossible to clear it without refreshing the page.
Also refactored some Cypress tests and did some minor optimization on error collection.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<img src="https://user-images.githubusercontent.com/335541/86303240-1fcf0f80-bbc0-11ea-9c90-5ce0d922b61f.png" width="300">
### TEST PLAN
Added Cypress tests.
To reproduce the bug:
1. Go to Explore a table chart, clear any metrics under in "Aggregate" mode if there's any
2. Select "Raw" query mode
3. Select some columns
4. Change chart to line chart
5. You should see a validation error on "metrics", add a new metric will not clear the error, preventing users from running the query. However, if they run the query and refresh the page, the query can go through.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [x] Has associated issue:
- [x] Changes UI
- [ ] Requires DB Migration.
- [ ] Confirm DB Migration upgrade and downgrade tested.
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448684255
##########
File path: superset-frontend/cypress-base/cypress/integration/explore/control.test.js
##########
@@ -40,255 +40,6 @@ describe('Groupby', () => {
});
});
-describe('AdhocMetrics', () => {
Review comment:
Didn't really change these tests other than splitting them into ts files.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-commenter commented on pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#issuecomment-652719365
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=h1) Report
> Merging [#10224](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-superset/commit/f7a024d7de22b32d7045bdc319b70696f3b300be&el=desc) will **increase** coverage by `6.11%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #10224 +/- ##
==========================================
+ Coverage 63.81% 69.93% +6.11%
==========================================
Files 533 190 -343
Lines 29823 18385 -11438
Branches 2851 0 -2851
==========================================
- Hits 19033 12858 -6175
+ Misses 10612 5527 -5085
+ Partials 178 0 -178
```
| Flag | Coverage Δ | |
|---|---|---|
| #cypress | `?` | |
| #python | `69.93% <ø> (-0.23%)` | :arrow_down: |
| [Impacted Files](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [superset/views/database/mixins.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvdmlld3MvZGF0YWJhc2UvbWl4aW5zLnB5) | `59.64% <0.00%> (-21.06%)` | :arrow_down: |
| [superset/utils/cache.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvdXRpbHMvY2FjaGUucHk=) | `48.00% <0.00%> (-20.00%)` | :arrow_down: |
| [superset/db\_engine\_specs/mysql.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL215c3FsLnB5) | `78.72% <0.00%> (-12.77%)` | :arrow_down: |
| [superset/views/database/validators.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvdmlld3MvZGF0YWJhc2UvdmFsaWRhdG9ycy5weQ==) | `78.94% <0.00%> (-5.27%)` | :arrow_down: |
| [superset/views/database/api.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvdmlld3MvZGF0YWJhc2UvYXBpLnB5) | `84.09% <0.00%> (-3.41%)` | :arrow_down: |
| [superset/db\_engine\_specs/postgres.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL3Bvc3RncmVzLnB5) | `97.36% <0.00%> (-2.64%)` | :arrow_down: |
| [superset/views/database/views.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvdmlld3MvZGF0YWJhc2Uvdmlld3MucHk=) | `88.03% <0.00%> (-2.57%)` | :arrow_down: |
| [superset/models/core.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvbW9kZWxzL2NvcmUucHk=) | `84.44% <0.00%> (-2.23%)` | :arrow_down: |
| [superset/jinja\_context.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvamluamFfY29udGV4dC5weQ==) | `80.00% <0.00%> (-0.96%)` | :arrow_down: |
| [superset/db\_engine\_specs/base.py](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2Jhc2UucHk=) | `86.47% <0.00%> (-0.30%)` | :arrow_down: |
| ... and [345 more](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=footer). Last update [f7a024d...097b2c8](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud closed pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud closed pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#issuecomment-652714473
Don't know why Python test is failing. This PR didn't change any Python code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-commenter edited a comment on pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#issuecomment-652719365
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=h1) Report
> Merging [#10224](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-superset/commit/f7a024d7de22b32d7045bdc319b70696f3b300be&el=desc) will **increase** coverage by `1.73%`.
> The diff coverage is `66.66%`.
[](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #10224 +/- ##
==========================================
+ Coverage 63.81% 65.55% +1.73%
==========================================
Files 533 594 +61
Lines 29823 31485 +1662
Branches 2851 3222 +371
==========================================
+ Hits 19033 20640 +1607
- Misses 10612 10664 +52
- Partials 178 181 +3
```
| Flag | Coverage Δ | |
|---|---|---|
| #cypress | `?` | |
| #javascript | `59.40% <66.66%> (?)` | |
| #python | `69.93% <ø> (-0.23%)` | :arrow_down: |
| [Impacted Files](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../src/explore/components/ControlPanelsContainer.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9Db250cm9sUGFuZWxzQ29udGFpbmVyLmpzeA==) | `81.53% <ø> (-9.77%)` | :arrow_down: |
| [superset-frontend/src/explore/controlUtils.js](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29udHJvbFV0aWxzLmpz) | `94.17% <ø> (+19.88%)` | :arrow_up: |
| [...et-frontend/src/explore/reducers/exploreReducer.js](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvcmVkdWNlcnMvZXhwbG9yZVJlZHVjZXIuanM=) | `30.50% <66.66%> (-1.64%)` | :arrow_down: |
| [superset-frontend/src/SqlLab/App.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi9BcHAuanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset-frontend/src/explore/App.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvQXBwLmpzeA==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset-frontend/src/SqlLab/index.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi9pbmRleC5qc3g=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset-frontend/src/dashboard/App.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9BcHAuanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset-frontend/src/explore/index.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvaW5kZXguanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset-frontend/src/dashboard/index.jsx](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9pbmRleC5qc3g=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset-frontend/src/setup/setupColors.js](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3NldHVwL3NldHVwQ29sb3JzLmpz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [308 more](https://codecov.io/gh/apache/incubator-superset/pull/10224/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=footer). Last update [f7a024d...097b2c8](https://codecov.io/gh/apache/incubator-superset/pull/10224?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] kristw commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
kristw commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448687071
##########
File path: superset-frontend/src/explore/controlUtils.js
##########
@@ -141,8 +139,9 @@ export function getControlStateFromControlConfig(controlConfig, state, value) {
// If a choice control went from multi=false to true, wrap value in array
const controlValue =
controlConfig.multi && value && !Array.isArray(value) ? [value] : value;
+
controlState.value =
- typeof controlValue === 'undefined' ? controlState.default : controlValue;
+ controlValue === undefined ? controlState.default : controlValue;
Review comment:
no need to change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448689270
##########
File path: superset-frontend/src/explore/reducers/exploreReducer.js
##########
@@ -99,24 +99,34 @@ export default function exploreReducer(state = {}, action) {
},
[actions.SET_FIELD_VALUE]() {
const new_form_data = state.form_data;
- new_form_data[action.controlName] = action.value;
+ const { controlName, value, validationErrors } = action;
+ new_form_data[controlName] = value;
- // These errors are reported from the Control components
- let errors = action.validationErrors || [];
const vizType = new_form_data.viz_type;
+
// Use the processed control config (with overrides and everything)
// if `controlName` does not existing in current controls,
const controlConfig =
state.controls[action.controlName] ||
getControlConfig(action.controlName, vizType) ||
{};
+
+ // will call validators again
const control = {
...getControlStateFromControlConfig(controlConfig, state, action.value),
};
- // These errors are based on control config `validators`
- errors = errors.concat(control.validationErrors || []);
+ // combine newly detected errors with errors from `onChange` event of
+ // each control component (passed via reducer action).
Review comment:
I think most cases the same. I only checked `isInteger` validator for calendar chart.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448685311
##########
File path: superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx
##########
@@ -189,15 +189,15 @@ describe('controlUtils', () => {
it('removes the mapStateToProps key from the object', () => {
let control = getControlConfig('all_columns', 'table');
control = applyMapStateToPropsToControl(control, state);
- expect(control.mapStateToProps).toBe(undefined);
+ expect(control.mapStateToProps[0]).toBe(undefined);
});
});
describe('getControlState', () => {
- it('to be function free', () => {
- const control = getControlState('all_columns', 'table', state, ['a']);
- expect(control.mapStateToProps).toBe(undefined);
- expect(control.validators).toBe(undefined);
+ it('to still have the functions', () => {
+ const control = getControlState('metrics', 'table', state, ['a']);
+ expect(typeof control.mapStateToProps).toBe('function');
+ expect(typeof control.validators[0]).toBe('function');
Review comment:
Controls will now keep the validation and stateToProp functions because parsed configs will be cached and reused.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448684392
##########
File path: superset-frontend/cypress-base/cypress/integration/explore/visualizations/line.test.js
##########
@@ -27,9 +27,26 @@ describe('Visualization > Line', () => {
cy.route('POST', '/superset/explore_json/**').as('getJson');
});
+ it('should show validator error when no metric', () => {
+ const formData = { ...LINE_CHART_DEFAULTS, metrics: [] };
+ cy.visitChartByParams(JSON.stringify(formData));
+ cy.get('.alert-warning').contains(`"Metrics" cannot be empty`);
+ });
+
+ it('should not show validator error when metric added', () => {
+ const formData = { ...LINE_CHART_DEFAULTS, metrics: [] };
+ cy.visitChartByParams(JSON.stringify(formData));
+ cy.get('.alert-warning').contains(`"Metrics" cannot be empty`);
+ cy.get('.text-danger').contains('Metrics');
+ cy.get('.metrics-select .Select__input input:eq(0)')
+ .focus()
+ .type('SUM(num){enter}');
+ cy.get('.text-danger').should('not.exist');
+ cy.get('.alert-warning').should('not.exist');
+ });
Review comment:
Added a new test for line chart to check clearing validator errors.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448684937
##########
File path: superset-frontend/cypress-base/cypress/support/index.ts
##########
@@ -78,17 +80,21 @@ Cypress.Commands.add(
chartSelector,
}: {
waitAlias: string;
- querySubstring: string;
chartSelector: JQuery.Selector;
+ querySubstring?: string | RegExp;
}) => {
cy.wait(waitAlias).then(xhr => {
cy.verifySliceContainer(chartSelector);
cy.verifyResponseCodes(xhr, responseBody => {
if (querySubstring) {
- type QueryResponse = { query: string };
- expect(
- responseBody && (responseBody as QueryResponse).query,
- ).contains(querySubstring);
+ const query = responseBody
+ ? (responseBody as { query: string }).query
+ : '';
+ if (querySubstring instanceof RegExp) {
+ expect(query).to.match(querySubstring);
+ } else {
+ expect(query).to.contain(querySubstring);
+ }
Review comment:
Extended the `verifySliceSuccess` command a bit to accept RegExp.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448689562
##########
File path: superset-frontend/src/explore/controlUtils.js
##########
@@ -141,8 +139,9 @@ export function getControlStateFromControlConfig(controlConfig, state, value) {
// If a choice control went from multi=false to true, wrap value in array
const controlValue =
controlConfig.multi && value && !Array.isArray(value) ? [value] : value;
+
controlState.value =
- typeof controlValue === 'undefined' ? controlState.default : controlValue;
+ controlValue === undefined ? controlState.default : controlValue;
Review comment:
thought this change will make the code shorter and fit it in one line... obviously not enuogh...
##########
File path: superset-frontend/src/explore/controlUtils.js
##########
@@ -141,8 +139,9 @@ export function getControlStateFromControlConfig(controlConfig, state, value) {
// If a choice control went from multi=false to true, wrap value in array
const controlValue =
controlConfig.multi && value && !Array.isArray(value) ? [value] : value;
+
controlState.value =
- typeof controlValue === 'undefined' ? controlState.default : controlValue;
+ controlValue === undefined ? controlState.default : controlValue;
Review comment:
thought this change will make the code shorter and fit it in one line... obviously not enough...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448689562
##########
File path: superset-frontend/src/explore/controlUtils.js
##########
@@ -141,8 +139,9 @@ export function getControlStateFromControlConfig(controlConfig, state, value) {
// If a choice control went from multi=false to true, wrap value in array
const controlValue =
controlConfig.multi && value && !Array.isArray(value) ? [value] : value;
+
controlState.value =
- typeof controlValue === 'undefined' ? controlState.default : controlValue;
+ controlValue === undefined ? controlState.default : controlValue;
Review comment:
thought this change will make the code short enough to fit in one line... obviously not...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448685944
##########
File path: superset-frontend/src/explore/components/ControlPanelsContainer.jsx
##########
@@ -76,13 +76,6 @@ class ControlPanelsContainer extends React.Component {
// apply current value in formData
value: formData[name],
};
- const { mapStateToProps: mapFn } = controlData;
- if (mapFn) {
- Object.assign(
- controlData,
- mapFn(exploreState, controlData, actions) || {},
- );
- }
Review comment:
No need to call `mapStateToProps` again because it's always called during both [initialization](https://github.com/apache/incubator-superset/blob/e0ccb2ce1d592e6b259c6c95831ecff502a10224/superset-frontend/src/explore/controlUtils.js#L205) and [reduce actions](https://github.com/apache/incubator-superset/blob/194f9ef9be82d9532bd55b34a35e68dfc22e9bc3/superset-frontend/src/explore/reducers/exploreReducer.js#L100) (via the `getControlStateFromControlConfig` function).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud merged pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud merged pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] ktmud commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
ktmud commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448686433
##########
File path: superset-frontend/src/explore/reducers/exploreReducer.js
##########
@@ -99,24 +99,34 @@ export default function exploreReducer(state = {}, action) {
},
[actions.SET_FIELD_VALUE]() {
const new_form_data = state.form_data;
- new_form_data[action.controlName] = action.value;
+ const { controlName, value, validationErrors } = action;
+ new_form_data[controlName] = value;
- // These errors are reported from the Control components
- let errors = action.validationErrors || [];
const vizType = new_form_data.viz_type;
+
// Use the processed control config (with overrides and everything)
// if `controlName` does not existing in current controls,
const controlConfig =
state.controls[action.controlName] ||
getControlConfig(action.controlName, vizType) ||
{};
+
+ // will call validators again
const control = {
...getControlStateFromControlConfig(controlConfig, state, action.value),
};
- // These errors are based on control config `validators`
- errors = errors.concat(control.validationErrors || []);
+ // combine newly detected errors with errors from `onChange` event of
+ // each control component (passed via reducer action).
Review comment:
Sometimes the `onChange` event returns the same validation error than the one returned by validators. (**Maybe we shouldn't allow controls to run validations in `onChange`.**)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] kristw commented on a change in pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
kristw commented on a change in pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#discussion_r448687726
##########
File path: superset-frontend/src/explore/reducers/exploreReducer.js
##########
@@ -99,24 +99,34 @@ export default function exploreReducer(state = {}, action) {
},
[actions.SET_FIELD_VALUE]() {
const new_form_data = state.form_data;
- new_form_data[action.controlName] = action.value;
+ const { controlName, value, validationErrors } = action;
+ new_form_data[controlName] = value;
- // These errors are reported from the Control components
- let errors = action.validationErrors || [];
const vizType = new_form_data.viz_type;
+
// Use the processed control config (with overrides and everything)
// if `controlName` does not existing in current controls,
const controlConfig =
state.controls[action.controlName] ||
getControlConfig(action.controlName, vizType) ||
{};
+
+ // will call validators again
const control = {
...getControlStateFromControlConfig(controlConfig, state, action.value),
};
- // These errors are based on control config `validators`
- errors = errors.concat(control.validationErrors || []);
+ // combine newly detected errors with errors from `onChange` event of
+ // each control component (passed via reducer action).
Review comment:
> Sometimes the onChange event returns the same validation error than the one returned by validators.
The same one or different one?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] kristw commented on pull request #10224: fix: chart validation error not cleared on control value update
Posted by GitBox <gi...@apache.org>.
kristw commented on pull request #10224:
URL: https://github.com/apache/incubator-superset/pull/10224#issuecomment-652715922
> Don't know why Python test is failing. This PR didn't change any Python code.
could be flaky test. not sure. perhaps re-run
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org