-
Notifications
You must be signed in to change notification settings - Fork 21
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
[O2B-643] Run duration accept format HH:MM:SS #1464
base: main
Are you sure you want to change the base?
[O2B-643] Run duration accept format HH:MM:SS #1464
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1464 +/- ##
==========================================
- Coverage 43.82% 43.51% -0.31%
==========================================
Files 889 892 +3
Lines 15761 15872 +111
Branches 2939 2973 +34
==========================================
Hits 6907 6907
- Misses 8854 8965 +111 ☔ View full report in Codecov by Sentry. |
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 have put several comments on things that I have already commented too much times.
Please have a look, fix what I commented, and try to fix the rest (do it carefully, especially prune from this PR everything that do not belongs to it)
lib/public/components/Filters/common/filters/NumericComparisonOperatorSelectionModel.js
Outdated
Show resolved
Hide resolved
lib/public/components/Filters/common/filters/NumericComparisonOperatorSelectionModel.js
Outdated
Show resolved
Hide resolved
lib/public/components/Filters/common/filters/NumericComparisonOperatorSelectionModel.js
Outdated
Show resolved
Hide resolved
lib/public/components/Filters/common/filters/NumericFilterModel.js
Outdated
Show resolved
Hide resolved
const { hours, minutes, seconds } = durationInputModel.raw; | ||
|
||
/** | ||
* Return oninput handler for given time unit |
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.
Never mention what the function should be used for, only explain what it does.
* @param {'hours'|'minutes'|'seconds'} unitName time unit | ||
* @return {function(InputEvent, void)} oninput handler for input for given time unit | ||
*/ | ||
const updateInputModelHandlerByTimeUnit = (unitName) => (e) => { |
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.
This function seems to add more complexity than it brings value I think
const { value } = e.target; | ||
const parsedValue = Number(value); | ||
if (value.length > 0 || 0 <= parsedValue && (unitName === 'hours' || parsedValue < 60)) { | ||
durationInputModel.update({ [unitName]: value.length > 0 ? parsedValue : 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.
Doing so, if you delete a value, update will not be triggered, so it will be put back to previous value.
Plus, this kind of processing should be in the model.
What you do in oninput is simply call durationFilterModel update, pass it RAW value (i.e. the string input), you store this raw value and try to extract the actual value.
If user put 80 minutes you still need to keep this as raw value but mark the input as invalid, and not update the actual value.
Please have a look at other inputs, such as DateTimeInputComponent
this._operatorSelectionModel.observe(() => { | ||
if (this._durationInputModel.value === null) { | ||
this._visualChange$.notify(); | ||
} else { | ||
this.notify(); | ||
} | ||
}); |
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.
This is not how it should work I suppose. If operatorSelectionModel has visualChange you need to bubleUp this to the current visualChange, but not mix the global notify and the visual change
try { | ||
this._raw = { ...this._raw, ...raw }; | ||
this._value = | ||
(this._raw.hours || 0) * 60 * 60 * 1000 + | ||
(this._raw.minutes || 0) * 60 * 1000 + | ||
(this._raw.seconds || 0) * 1000; | ||
|
||
if (this._value === 0) { | ||
this.reset(); | ||
const { hours, minutes, seconds } = this._raw; | ||
if ((hours ?? minutes ?? seconds ?? null) === null) { | ||
this._value = null; | ||
} else { | ||
this._value = (hours || 0) * 60 * 60 * 1000 | ||
+ (minutes || 0) * 60 * 1000 | ||
+ (seconds || 0) * 1000; | ||
} | ||
} catch (_) { | ||
} catch { | ||
this._value = 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.
Why the try catch?
'filter[runDuration][operator]': this._runDurationOperatorSelectionModel.selected, | ||
'filter[runDuration][limit]': this._runDurationFilterModel.value, | ||
...!this._runDurationFilterModel.isEmpty() && { | ||
'filter[runDuration][operator]': this._runDurationFilterModel.operatorSelectionModel.selected[0], |
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.
you should use current
instead
* | ||
* @return {Promise<void>} resolve once row's values were checked | ||
*/ | ||
module.exports.expectRowValues = async (page, rowId, expectedInnerTextValues) => { |
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.
Where is this used? It looks like it's not, and tbh I think it's a good thing because I don't really see where it make sense.
@@ -634,13 +658,16 @@ module.exports.checkColumnValuesWithRegex = async (page, columnId, expectedValue | |||
valuesCheckingMode = 'every', | |||
negation = false, | |||
} = options; | |||
|
|||
const adjustedRegExp = new RegExp(expectedValuesRegex).toString().slice(1, -1); |
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.
Please explain why you do that?
Why not
if (typeof expectedValuesRegex === 'string') {
expectedValuesRegex = new RegExp(expectedValuesRegex);
}
* Constructor | ||
* @param {string} [defaultOperator = '='] one of ['<', '<=', '=', '>=', '>'] operators | ||
*/ | ||
constructor(defaultOperator = '=') { |
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.
If you don't override this parameter anywhere, simply don't add it
oninput: updateInputModelHandlerByTimeUnit('seconds'), | ||
}, 's'); | ||
|
||
const inputs = h('.flex-row.w-100', [ |
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.
is w-100 usefull? Can't we use flex-grow or equivalent instead?
I have a JIRA ticket
Notable changes for users:
Notable changes for developers:
Changes made to the database: