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
mgr/dashboard: fix columns in host table with NaN Undefined #44843
mgr/dashboard: fix columns in host table with NaN Undefined #44843
Conversation
3798690
to
0d9d804
Compare
|
jenkins test dashboard cephadm |
| hostKey['memory_total_bytes'] = !isNaN(hostKey['memory_total_kb']) | ||
| ? hostKey['memory_total_kb'] * 1024 | ||
| : 'N/A'; | ||
| hostKey['raw_capacity'] = | ||
| !isNaN(hostKey['hdd_capacity_bytes']) && !isNaN(hostKey['flash_capacity_bytes']) | ||
| ? hostKey['hdd_capacity_bytes'] + hostKey['flash_capacity_bytes'] | ||
| : 'N/A'; |
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.
honestly, if a ternary assignment is not a one liner I would prefer a usual if statement.
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 avoided writing if else block twice)
|
jenkins test make check |
|
jenkins test make check |
|
jenkins test dashboard |
| hostKey['memory_total_bytes'] = !isNaN(hostKey['memory_total_kb']) | ||
| ? hostKey['memory_total_kb'] * 1024 |
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 do we care about presentation stuff in the logic layer? NaN or "N/A" is not relevant at this stage.
IMHO that should be left for the template and pipes are good at this. We even have a pipe empty that basically converts null and undefined to "-". If we need to deal with NaN let's add that check to that pipe and keep a consistent behaviour ("-" for null/undefined in some places, but "N/A" in others). That's the good thing of reusing helpers.
And going one step further: if this NaN/null/undefined seems to be a recurrent issue (I remember at least another 2 recent PRs dealing with it), why don't we append the empty pipe by default to the cd-datatable cells? That way we'll avoid having to manual check for this in every single piece of data that we display.
Additionally, is it normal to get a NaN here? Shouldn't we get a null or undefined?
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 do we care about presentation stuff in the logic layer?
NaNor"N/A"is not relevant at this stage.IMHO that should be left for the template and pipes are good at this. We even have a pipe
emptythat basically convertsnullandundefinedto"-". If we need to deal withNaNlet's add that check to that pipe and keep a consistent behaviour ("-" for null/undefined in some places, but "N/A" in others). That's the good thing of reusing helpers.And going one step further: if this
NaN/null/undefinedseems to be a recurrent issue (I remember at least another 2 recent PRs dealing with it), why don't we append theemptypipe by default to thecd-datatablecells? That way we'll avoid having to manual check for this in every single piece of data that we display.Additionally, is it normal to get a
NaNhere? Shouldn't we get a null or undefined?
Yes but if we do arithmetic operation with a number and those undefined values it'll NaN.
|
jenkins test make check |
Fixes: https://tracker.ceph.com/issues/54068 Signed-off-by: Avan Thakkar <athakkar@redhat.com>
0d9d804
to
41ca50c
Compare
|
jenkins test make check |
|
jenkins test windows |
1 similar comment
|
jenkins test windows |
|
jenkins test windows |
Fixes: https://tracker.ceph.com/issues/54068
Signed-off-by: Avan Thakkar athakkar@redhat.com
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox