Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Parameter input feedback #4197

Closed
wants to merge 13 commits into from
Closed

Conversation

ranbena
Copy link
Contributor

@ranbena ranbena commented Sep 30, 2019

  • Feature

Description

Fixes #2721.
Depends on #4049.

  1. Shows "Required field" feedback when param input is left empty
  2. Disallows query execution with missing params.
  3. Added to all parameter input instances - a) Query b) Dashboard c) Widget d) Static widget value.

Screen Shot 2019-09-30 at 10 25 38

Screen Shot 2019-09-30 at 10 25 13

Here's the whole gang:
Screen Shot 2019-10-02 at 15 14 28

Notice that the Number param also checks that input is a number.
Notice dropdown can't be invalid so has no error.

@ranbena
Copy link
Contributor Author

ranbena commented Sep 30, 2019

@arikfr how do you feel about this approach?
https://deploy-preview-4197--redash-preview.netlify.com/

Can also add "Invalid input" error (i.e. NaN in InputNumber)

@@ -137,6 +143,8 @@ export class Parameters extends React.Component {

renderParameter(param, index) {
const { editable } = this.props;
const isEmpty = param.pendingValue === '' || param.pendingValue === null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line of code is totally temporary.
@gabrieldutra wdyt of this for Parameter.js?

get isEmpty() {
  const value = this.hasPendingValue ? this.pendingValue : this.value;
  return this.isEmptyValue(value);
}

It makes sense to me that param.isEmpty always responds with the currently selected value.

Copy link
Member

@gabrieldutra gabrieldutra Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the most relevant usage of that (or the only one) is to determine the parameters with missing values prior to a query execution, so that would need to be updated (in this case it's necessary to consider the parameter value, not the pending value).

I'm actually "centered positioned" on that. Depends if it makes more sense for the Parameter structure to reflect the "actual Input" or the "Query Execution". For the first one the pendingValue is part of it, for the second one it's just a "state" the parameter has. Considering the existence of this.isEmptyValue(anyValue) it doesn't matter the direction we choose.

BTW, considering "Can also add "Invalid input" error (i.e. NaN in InputNumber)", one idea is to remove the isEmpty (no usage besides deciding if there is an error prior to the query execution) and work on a generalized getErrors with anything that should return an UI error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm for param.getCurrentInputError() which would return a string ("Required field", "Invalid input", etc) or null. I can add it in this PR 👍

@ranbena ranbena changed the title [WIP] Added param required warning [WIP] Parameter input feedback Oct 2, 2019
Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indication on the field is the first part, but we also need to revise the big red message as well (either replace or remove).

@ranbena
Copy link
Contributor Author

ranbena commented Oct 2, 2019

The indication on the field is the first part, but we also need to revise the big red message as well (either replace or remove).

Sure, it'll be removed when I publish the PR.

@ranbena ranbena changed the base branch from master to parameters-structure October 2, 2019 12:15
@arikfr
Copy link
Member

arikfr commented Oct 2, 2019

Sure, it'll be removed when I publish the PR.

I have a feeling removing it will be a big part of the work :)

Preventing execution when invalid value on query or dashboard page init.
Disabling execute button when invalid value.
@ranbena
Copy link
Contributor Author

ranbena commented Oct 5, 2019

Added specific error msg in case query or dashboard init with invalid params.
Notice, these will become edge cases as the UI will now not allow executing an invalid param query.

Query:

Screen Shot 2019-10-05 at 21 14 20

Dashboard widget link:

Screen Shot 2019-10-05 at 21 22 05

@ranbena
Copy link
Contributor Author

ranbena commented Oct 9, 2019

@arikfr before I release this to be reviewed, here are a few points to be aware of:

  • In a query view, newly added parameters immediately show "Required field" error state. I think better ux would be to indicate the added parameter and show the error only after query save. Not an easy implementation.
  • Param value errors do not prevent saving the query. Dunno if that's something we should do or not.
  • Query error message styling has been left as is. I think it's out of this PR's scope.
  • Changing a param type to DateRange causes "missing param" error from server (cause the query itself doesn't include correlated start/end). In a follow-up PR I'll try to make the message actually accurate.

Lmk if any of these are show stoppers.

@ranbena
Copy link
Contributor Author

ranbena commented Oct 12, 2019

Changing a param type to DateRange causes "missing param" error from server (cause the query itself doesn't include correlated start/end). In a follow-up PR I'll try to make the message actually accurate.

Now handled with dedicated param validation check.

When changing param type to DateRange

Screen Shot 2019-10-12 at 13 15 02

When changing DateRange param to another type

Screen Shot 2019-10-12 at 13 14 31

@ranbena
Copy link
Contributor Author

ranbena commented Oct 21, 2019

Swapped for a backend validation version #4264

@ranbena ranbena closed this Oct 21, 2019
@guidopetri guidopetri deleted the param-validation branch July 22, 2023 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants