Skip to content
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

Site: Disable Beta buttons in "Get started!" documentation if the release is older than the latest Stable release. #18514

Merged
merged 7 commits into from
Apr 11, 2024

Conversation

Sryther
Copy link
Contributor

@Sryther Sryther commented Mar 26, 2024

Disabling Beta buttons is not instantaneous. I'm not sure that's the most convenient method to do it.

First it looks for latest release, if it's not a Beta one it'll disable the Beta button and activate the Stable one instead.

fixes #18505

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 26, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @Sryther!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @Sryther. 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 26, 2024
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Sryther thanks for the quick PR ! however in the prview I see it is disabled

https://deploy-preview-18514--kubernetes-sigs-minikube.netlify.app/docs/start/

even though right now minikube does have a new beta release, (it should have NOT been grayed out)

see
https://github.com/kubernetes/minikube/releases/tag/v1.33.0-beta.0
which is newer than 1.32

@Sryther
Copy link
Contributor Author

Sryther commented Mar 26, 2024

even though right now minikube does have a new beta release, (it should have NOT been grayed out)

You're totally right, I just forgot to invert the condition while I was testing...

@Sryther Sryther requested a review from medyagh March 26, 2024 21:55
@medyagh medyagh changed the title Disable Beta buttons in "Get started!" documentation if the release is older than the latest Stable release. Site: Disable Beta buttons in "Get started!" documentation if the release is older than the latest Stable release. Mar 27, 2024
@spowelljr
Copy link
Member

Hi @Sryther, thanks for your PR! I took a look at this and think we can simplify this. First off, 99% of the time we don't want to show the Beta button, so I think it's better if we start with it completely hidden and show it if there's a beta available. We have an existing hide class we can use, and for minimal code changes, we can check if option == "Beta" and if it is add the hide class by default (shown below).

diff --git a/site/layouts/shortcodes/quiz_button.html b/site/layouts/shortcodes/quiz_button.html
index 1100d1e92..3cf0b6433 100644
--- a/site/layouts/shortcodes/quiz_button.html
+++ b/site/layouts/shortcodes/quiz_button.html
@@ -1 +1 @@
-<button data-quiz-id="{{ .Parent.Get "base" }}/{{ .Get "option" }}" type="button" class="btn btn-outline-primary option-button">{{ .Get "option" }}</button>
+<button data-quiz-id="{{ .Parent.Get "base" }}/{{ .Get "option" }}" type="button" class="btn btn-outline-primary option-button{{ if eq (.Get "option") "Beta" }} hide{{ end }}">{{ .Get "option" }}</button>

Then this will simplify a lot of your code because you can remove your logic that changes the active button to Stable since the button won't be available if there's no beta, and if there is a beta we simply remove the hide class.

diff --git a/site/content/en/docs/start/_index.md b/site/content/en/docs/start/_index.md
index 71b0a86bc..569f9b0cf 100644
--- a/site/content/en/docs/start/_index.md
+++ b/site/content/en/docs/start/_index.md
@@ -38,21 +38,11 @@ All you need is Docker (or similarly compatible) container or a Virtual Machine
       if (releases && releases.length > 0 && releases[0] && releases[0].tag_name) {
         const isBetaMostRecent = releases[0].tag_name.includes("-beta");
 
-        if (!isBetaMostRecent) {
+        if (isBetaMostRecent) {
           for (architecture of architectures) {
             const betaElement = document.querySelector(`button[data-quiz-id="/${architecture}/Beta"]`);
-            const stableElement = document.querySelector(`button[data-quiz-id="/${architecture}/Stable"]`);
             if (betaElement) {
-              betaElement.disabled = true;
-
-              if (betaElement.classList.contains("active")) {
-                const stableElement = document.querySelector(`button[data-quiz-id="/${architecture}/Stable"]`);
-                if (stableElement) {
-                  stableElement.click();
-                  stableElement.classList.add("active");
-                }
-                betaElement.classList.remove("active");
-              }
+              betaElement.classList.remove("hide");
             }
           }
         }

@Sryther
Copy link
Contributor Author

Sryther commented Apr 5, 2024

I wasn't aware of the .hide class! Your proposal is clearly better with the arguments you're pointing at. Although, I don't think mentioning "Beta" is a good idea in the quizz_button shortcode, I mean a more generic parameter should be used, such as hidden or something like this:

{{% quiz_button option="Beta" hidden="true" %}}

It should work, right?

@spowelljr
Copy link
Member

Yeah, that's completely fine, I just used Beta to set hide because this component was specifically created for this so it's unlikely to be used anywhere else and would save from having to manually add hide="true" to all the beta ones. But making it generic is great too

"Windows/x86-64"
];

fetch('https://api.github.com/repos/kubernetes/minikube/releases')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we console out log how long this takes, so for reference ? I wanna know if it worth it to make our site slower by this call ..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a timer to measure the performance. Anyway it's asynchronous, it shouldn't affect page loading 🙂 .

Copy link
Member

@spowelljr spowelljr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@spowelljr spowelljr merged commit e97c7f9 into kubernetes:master Apr 11, 2024
5 of 6 checks passed
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: spowelljr, Sryther

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minikube website should not show Beta Releases to download if they are Older than the Stable release
5 participants