-
Notifications
You must be signed in to change notification settings - Fork 196
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
fix virtual systems listing filters #8265
fix virtual systems listing filters #8265
Conversation
👋 Hello! Thanks for contributing to our project. If you are unsure the failing tests are related to your code, you can check the "reference jobs". These are jobs that run on a scheduled time with code from master. If they fail for the same reason as your build, it means the tests or the infrastructure are broken. If they do not fail, but yours do, it means it is related to your code. Reference tests: KNOWN ISSUES Sometimes the build can fail when pulling new jar files from download.opensuse.org . This is a known limitation. Given this happens rarely, when it does, all you need to do is rerun the test. Sorry for the inconvenience. For more tips on troubleshooting, see the troubleshooting guide. Happy hacking! |
Suggested tests to cover this Pull Request
|
169a0f4
to
aff153f
Compare
"COALESCE(RS.name, '(none)') AS virtual_host_name, " + | ||
"COALESCE(VII.name, '(none)') AS virtual_vm_name, " + |
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 is no need to change the names here as this will imply additional fields and getters/setters in the DTO.
@@ -67,7 +68,8 @@ public VirtualSystemOverview(Tuple tuple) { | |||
stateLabel = getTupleValue(tuple, "state_label", String.class).orElse(null); | |||
vcpus = getTupleValue(tuple, "vcpus", Number.class).map(Number::longValue).orElse(0L); | |||
memory = getTupleValue(tuple, "memory", Number.class).map(Number::longValue).orElse(0L); | |||
hostServerName = getTupleValue(tuple, "host_server_name", String.class).orElse(null); | |||
virtualHostName = getTupleValue(tuple, "virtual_host_name", String.class).orElse(null); | |||
virtualVmName = getTupleValue(tuple, "virtual_vm_name", String.class).orElse(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.
server_name
is setup the parent class IIRC. There is no need to add another field for it
hostServerName = getTupleValue(tuple, "host_server_name", String.class).orElse(null); | ||
virtualHostName = getTupleValue(tuple, "virtual_host_name", String.class).orElse(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 changing the field name?
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.
yeah, you're right, it goes in line with the original names. already rolled it back
"hostServerName", "host_server_name", | ||
"name", "VII.name", | ||
defaultFilterColumn, "RS.name", | ||
"virtual_vm_name", "VII.name", |
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'm not sure this rename is really needed
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
|
||
public final class Predicates { |
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 are probably missing a Javadoc comment for this class
@@ -52,6 +52,15 @@ const allListOptions = [ | |||
{ value: "group_count", label: t("Groups") }, | |||
]; | |||
|
|||
const virtualSystemsListOptions = [ | |||
{ value: "virtual_host_name", label: t("Virtual Host Name") }, | |||
{ value: "virtual_vm_name", label: t("Virtual VM Name") }, |
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.
virtual VM
is a pleonasm, either use virtual guest
, virtual machine
or just vm
aff153f
to
6498937
Compare
6498937
to
e1fbd32
Compare
header={t("Virtual System")} | ||
header={t("Virtual Machine")} |
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.
Better not change this name: the word System
is used all over the place in the user interface and docs to refer to a machine. But this is nitpicking
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.
Got you! Updated the label on the dropdown as well.
e1fbd32
to
d59fbe9
Compare
d59fbe9
to
236d6d7
Compare
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.
Thanks, @rjpmestre!
I left 2 minor comments below.
Also, thanks for extensive testing, and introducing parametrized tests ❤️
/** | ||
* Determines whether a CharSequence is null or blank, ie, containing only whitespace characters. | ||
* | ||
* @param value the CharSequence to be evaluated | ||
* @return true if the CharSequence is null or blank | ||
*/ | ||
public static boolean isBlank(final CharSequence value) { | ||
if (isNull(value)) { | ||
return true; | ||
} | ||
|
||
int length = value.length(); | ||
if (length == 0) { | ||
return true; | ||
} | ||
|
||
for (int i = 0; i < length; i++) { | ||
if (!Character.isWhitespace(value.charAt(i))) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} |
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 method is already available in StringUtils
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.
Yeah, you're right. I had this sitting for a while now and i cannot recall exactly the small detail this was supposed to address/cover. Well, i should've commented back then. Lets stick to apache's StringUtils.
String filterColumn = requestIn.queryParams("qc"); | ||
String filterQuery = requestIn.queryParams("q"); |
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 can also use the PageControlHelper
to get these parameters. It encapsulates the logic and does some minimal validation.
String filterColumn = requestIn.queryParams("qc"); | |
String filterQuery = requestIn.queryParams("q"); | |
PageControlHelper pageHelper = new PageControlHelper(requestIn); | |
// pageHelper.getQuery() | |
// pageHelper.getQueryColumn() |
236d6d7
to
82696d5
Compare
What does this PR change?
This PR fixes virtual system listing and enhances its filtering system. It adds a new dropdown input field. This will allow users to select either "Virtual Host" or "Virtual System" as the target for their query.
GUI diff
Before:
After:
Documentation
No documentation needed: There is a GUI difference but the granularity its not high enough to cover these filters.
DONE
Test coverage
Unit tests were added
DONE
Links
Issue(s): https://github.com/SUSE/spacewalk/issues/21192
Changelogs
Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository
If you don't need a changelog check, please mark this checkbox:
If you uncheck the checkbox after the PR is created, you will need to re-run
changelog_test
(see below)Re-run a test
If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:
Before you merge
Check How to branch and merge properly!