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

Parameter feedback - #6 Better value normalization #4327

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

ranbena
Copy link
Contributor

@ranbena ranbena commented Nov 1, 2019

  • Bug Fix

Description

Text and Number parameters need some tweaking in terms of value normalization.

Text parameter

  1. An empty text field value is converted to null but multiple spaces do not and should. Now trimming.
  2. Adding spaces to value triggered dirty indication. Now it won't.

Number parameter

  1. Empty value sent 0 to server. Now sending null instead, displaying "Required parameter" error.
  2. Typing non-number values would disappear on blur/apply. Now sending value as is, displaying "Invalid value" error.

Screenshots have been added inline in code.

@ranbena ranbena requested a review from gabrieldutra November 1, 2019 06:53
@ranbena ranbena self-assigned this Nov 1, 2019
@@ -59,7 +59,7 @@ class ParameterValueInput extends React.Component {
}

onSelect = (value) => {
const isDirty = !isEqual(value, this.props.value);
const isDirty = !isEqual(trim(value), trim(this.props.value));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before:

After:

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there is a legitimate use case for multiple spaces in a parameter 😬

return null;
}
const normalizedValue = toNumber(value);
return !isNaN(normalizedValue) ? normalizedValue : null;
return !isNaN(normalizedValue) ? normalizedValue : value;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before:
Screen Shot 2019-11-01 at 9 04 05

After:
Screen Shot 2019-11-01 at 9 03 55

return null;
}
return this.value;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before:
Screen Shot 2019-11-01 at 9 05 58

After:
Screen Shot 2019-11-01 at 9 06 10

Copy link
Member

Choose a reason for hiding this comment

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

I didn't see a reason why someone would use a parameter only containing whitespaces, so this looks good to me 👍.

@@ -9,11 +9,11 @@ class NumberParameter extends Parameter {

// eslint-disable-next-line class-methods-use-this
normalizeValue(value) {
if (isNull(value)) {
if (!trim(value)) {
return null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before:
Screen Shot 2019-11-01 at 9 07 51

After:
Screen Shot 2019-11-01 at 9 07 25

@ranbena ranbena marked this pull request as ready for review November 1, 2019 12:44
value={normalize(value)}
onChange={val => this.onSelect(normalize(val))}
value={value}
onChange={val => this.onSelect(val)}
Copy link
Member

Choose a reason for hiding this comment

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

👍

return null;
}
return this.value;
}
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see a reason why someone would use a parameter only containing whitespaces, so this looks good to me 👍.

@ranbena ranbena changed the title Parameter input feedback - #6 Better value normalization Parameter feedback - #6 Better value normalization Nov 4, 2019
@@ -59,7 +59,7 @@ class ParameterValueInput extends React.Component {
}

onSelect = (value) => {
const isDirty = !isEqual(value, this.props.value);
const isDirty = !isEqual(trim(value), trim(this.props.value));
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there is a legitimate use case for multiple spaces in a parameter 😬

@guidopetri guidopetri merged commit 56f4947 into param-feedback-5 Jul 21, 2023
@guidopetri guidopetri deleted the param-feedback-6 branch July 21, 2023 19:35
guidopetri pushed a commit that referenced this pull request Jul 21, 2023
* Parameter feedback - #5 Unsaved indication

* Added ANGULAR_REMOVE_ME

* Added cypress test

* Fixed percy screenshot

* Some code improvements

* Parameter input feedback - #6 Better value normalization (#4327)
guidopetri pushed a commit that referenced this pull request Jul 21, 2023
* Parameter feedback - #4 Added in Dashboard params

* Added cypress test

* Moved to service

* Parameter feedback - #5 Unsaved indication (#4322)

* Parameter feedback - #5 Unsaved indication

* Added ANGULAR_REMOVE_ME

* Added cypress test

* Fixed percy screenshot

* Some code improvements

* Parameter input feedback - #6 Better value normalization (#4327)
guidopetri pushed a commit that referenced this pull request Jul 21, 2023
* Parameter feedback - #3 Added in Widgets

* Added cypress tests

* Making sure widget-level param is selected

* Parameter feedback - #4 Added in Dashboard params (#4321)

* Parameter feedback - #4 Added in Dashboard params

* Added cypress test

* Moved to service

* Parameter feedback - #5 Unsaved indication (#4322)

* Parameter feedback - #5 Unsaved indication

* Added ANGULAR_REMOVE_ME

* Added cypress test

* Fixed percy screenshot

* Some code improvements

* Parameter input feedback - #6 Better value normalization (#4327)
guidopetri pushed a commit that referenced this pull request Jul 21, 2023
* Parameter feedback - #2 Client errors in query page

* Added cypress test

* Fixed percy screenshot

* Safer touched change

* Parameter feedback - #3 Added in Widgets (#4320)

* Parameter feedback - #3 Added in Widgets

* Added cypress tests

* Making sure widget-level param is selected

* Parameter feedback - #4 Added in Dashboard params (#4321)

* Parameter feedback - #4 Added in Dashboard params

* Added cypress test

* Moved to service

* Parameter feedback - #5 Unsaved indication (#4322)

* Parameter feedback - #5 Unsaved indication

* Added ANGULAR_REMOVE_ME

* Added cypress test

* Fixed percy screenshot

* Some code improvements

* Parameter input feedback - #6 Better value normalization (#4327)
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.

4 participants