diff --git a/app/_assets/javascripts/tabs.js b/app/_assets/javascripts/tabs.js index 1011b7e57..d984acbf2 100644 --- a/app/_assets/javascripts/tabs.js +++ b/app/_assets/javascripts/tabs.js @@ -5,6 +5,7 @@ class TabsComponent { this.addEventListeners(); this.setInitialMeshServiceState(localStorage.getItem("meshservice")) + this.currentTabSlug = "Kubernetes" } addEventListeners() { @@ -27,6 +28,38 @@ class TabsComponent { item.setAttribute("checked", checked) } }); + this.hideMeshServiceTabs(checked) + } + + hideMeshServiceTabs(checked) { + // do nothing on non meshservice capable elements + if (this.elem.querySelectorAll('.tabs-component-tabs a[data-slug$="­"]').length === 0) { + return + } + + const that = this + this.elem.querySelectorAll('.tabs-component-tabs a[data-slug$="­"]').forEach((item) => { + if (checked === "false") { + item.parentElement.hidden = true + item.parentElement.classList.remove("is-active") + } else if (checked === "true") { + item.parentElement.hidden = false + if (item.attributes['aria-controls'].nodeValue.includes(that.currentTabSlug)) { + item.parentElement.classList.add("is-active") + } + } + }); + this.elem.querySelectorAll('.tabs-component-tabs a:not([data-slug$="­"])').forEach((item) => { + if (checked === "true") { + item.parentElement.hidden = true + item.parentElement.classList.remove("is-active") + } else if (checked === "false") { + item.parentElement.hidden = false + if (item.attributes['aria-controls'].nodeValue.includes(that.currentTabSlug)) { + item.parentElement.classList.add("is-active") + } + } + }); } selectTab(event) { @@ -66,13 +99,16 @@ class TabsComponent { onTabSelected(event) { const { tabSlug } = event.detail; this.setSelectedTabBySlug(tabSlug); + this.currentTabSlug = tabSlug } onNewMeshServiceChanged(event) { if (event.currentTarget.checked === true) { localStorage.setItem("meshservice", "true") + this.hideMeshServiceTabs("true") } else { localStorage.setItem("meshservice", "false") + this.hideMeshServiceTabs("false") } } diff --git a/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/policyyaml.rb b/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/policyyaml.rb index 25d3247af..f76ab3d6d 100644 --- a/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/policyyaml.rb +++ b/jekyll-kuma-plugins/lib/jekyll/kuma-plugins/liquid/tags/policyyaml.rb @@ -154,10 +154,10 @@ def render(context) if use_meshservice htmlContent += " -{% tab #{@tabs_name} Kubernetes  %} +{% tab #{@tabs_name} Kubernetes­%} #{kube_style2_content} {% endtab %} -{% tab #{@tabs_name} Universal  %} +{% tab #{@tabs_name} Universal­%} #{uni_style2_content} {% endtab %}" end