-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Improve addons list table design #21288
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: pavansaikrishna78
Once this PR has been reviewed and has the lgtm label, please assign spowelljr for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
Hi @pavansaikrishna78. Thanks for your PR.
I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test
on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test
label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
Can one of the admins verify this patch?
pkg/minikube/constants/constants.go
Outdated
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 there a way to show how it looks like maybe a link or copy to the comment ?
is a library to use?
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.
add a helper func to Format the text
we have a style package
style.Enable(.....)
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.
we should have a style func that does
style.Normal( white color)
style.Enabled(
Style.Trouble(
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 should be an iteration loop that calls the and based on the status it will call the Style Function in the package.
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 split the logical changes to separate commits instead of posing a new commit on every change.
If tests fail fix the failing commit. Don't post another commit fixing the first commit. This makes reviewing the changes much harder. Adding fix commit locally is fine, but before you post a new version you should squash the fix commit into the commit that introduced the problem.
Please remove all the unrelated and unnecessary changes. Focus on only on the design change to keep the change small, easy to review and be able to complete it quickly.
pkg/minikube/constants/constants.go
Outdated
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 green forground color. I will help to add a comment like:
Enabled = "033円[32m" // green forground
pkg/minikube/constants/constants.go
Outdated
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 a color but a reset command, removing all attributes (foreground color, background color, effects). We don't need a constant for default since it does not change the text.
pkg/minikube/constants/constants.go
Outdated
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.
Same, since this is using the same value as default.
pkg/minikube/constants/constants.go
Outdated
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 red foreground, a comment will help.
But I don't think this is the way to go. What we need is a new package for color that can be reused by code writing output for tables or other output.
This package can use constants to the define the color of enabled, disabled, or errors, and provide functions using this signature:
Enabled(s string) string
Code rendering UI should use the functions to decorate fragments of text.
To implement this we can use a library like this:
https://github.com/fatih/color?tab=readme-ov-file#insert-into-noncolor-strings-sprintfunc
The advantage of using a library is using a well tested code that works on all platforms.
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.
We don't need to update the dates, that's pointless effort. The best way is to remove the date form the copyright headers, but this is not in the scope of this PR, so just remove this change.
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 too complicated for no reason.
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.
Converting the values to string like we did before was better. If we colorize all value in a raw, we can keep the old code as is and apply the right color function to the entire slice.
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 did you change this?
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.
We have 3 logic changes:
- Removing the profile column
- Replacing Status with Enabled
- Coloring the output
Each change should be done in a separate commit. This will make it easier to write the code without errors, test it, and review.
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.
Too complicated.
We need 2 steps:
- Create list of strings for the table writer
- Color the strings
For creating list of strings we can modify the previous code a little bit:
enabled := addonBundle.IsEnabled(cc) row = []string{addonName, cc.Name, iconFromStatus(enabled), maintainer}
iconForStatus() should return empty string if enabled is false. If it does not do this create a function that does this.
Since the list is so simple, we don't really need a loop to color it:
if enabled { row[0] = color.Enabled(row[0]) row[2] = color.Enabled(row[2]) }
But since wan to color longer lists (like profile list), we can add a function to color rows:
type colorFunc func(string) string func ColorRow(row []string, colored colorFunc) { for i := range row { text := row[i] if text == "" || isEmoji(text) { continue } row[i] = colored(text) } }
With this we can do:
switch status { case Broken: color.ColorRow(row, color.Broken) case Error: color.ColorRow(row, color.Error) case Enabled: color.ColorRow(row, color.Enabled) }
3f61c2c
to
6bc5fee
Compare
565498b
to
cd36cf8
Compare
addons list and profile list and making pass the test
cd36cf8
to
789116d
Compare
6aab811
to
789116d
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.
lets plz not do changes not related to this PR
and also check nir's suggetsions how to make the code more simple
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.
Reviewed and left a comment. In addition, for the run instructions it would be cleaner to update the screenshots to just be the table output. Or update listing the full command in plain text to make it easier to copy and paste.
i.e.
command: ./out/minikube addons list
...
command: ./out/minikube profile list -d
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 don't think this change is needed or relevant to the PR. Other files follow the same convention. So this should be taken care of in a different PR for refactoring once its determined why its being done this way. I think this is done to make the function easier to test but I'm not sure.
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.
hi @Wilson-Duncan here is the output of the and correcting your above comment
image
image
image
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 saying the commands should not be in the screenshots. ./out/minikube profile list
, make
, ./out/minikube addons list
, and ./out/minikube profile list -d
should be plain text and not a part of the screenshot.
addons list function correction
b3a9d84
to
64cb1a4
Compare
64cb1a4
to
b3a9d84
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.
Lets remove all unrelated changes and keep only the code needed to add colors.
We can add additional changes later, for now we need to focus on the color changes.
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.
table.Options(tablewriter.WithHeaderAutoFormat(tw.On))
replaces this code?
Is this related to the color change? If not please don't include this in this PR. I'm trying to review the color changes and I don't have time to review other changes now.
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 did you change these names? Is this related to the color changes?
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 to you keep adding unrelated whitespace changes? I already commented about it in previous reviews several times.
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.
Lets move the helpers to another file since they are used both in adding_list.go and profile_list.go. We can add a color.go file for these helpers. If we use colors only in the config package this is good enough for now, but I think the best place for it is a new color package in pkg/minikube/color/color.go.
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 will not color test with emoji like "enabled ✅". Currently we don't have this but it will be more correct to use:
s == "✅"
Ideally we can use the unicode package to detect if the string contains only emoji characters.
If status is enabled then the whole row green
command: addons list
image
command: addons list -d
image
command: profile list
image
command: profile list -d
image
ADDON.LIST.MINIKUBE.docx