-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
@@ -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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value={normalize(value)} | ||
onChange={val => this.onSelect(normalize(val))} | ||
value={value} | ||
onChange={val => this.onSelect(val)} |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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 👍.
@@ -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)); |
There was a problem hiding this comment.
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 😬
* 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)
* 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)
* 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)
Description
Text and Number parameters need some tweaking in terms of value normalization.
Text parameter
null
but multiple spaces do not and should. Now trimming.dirty
indication. Now it won't.Number parameter
0
to server. Now sendingnull
instead, displaying "Required parameter" error.Screenshots have been added inline in code.