Skip to content

Commit

Permalink
feat(meshservice): seems to be working
Browse files Browse the repository at this point in the history
Signed-off-by: slonka <slonka@users.noreply.github.com>
  • Loading branch information
slonka committed Oct 11, 2024
1 parent 9e64ab2 commit 140f3f6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions app/_assets/javascripts/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TabsComponent {

this.addEventListeners();
this.setInitialMeshServiceState(localStorage.getItem("meshservice"))
this.currentTabSlug = "Kubernetes"
}

addEventListeners() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def render(context)

if use_meshservice
htmlContent += "
{% tab #{@tabs_name} Kubernetes&nbsp; %}
{% tab #{@tabs_name} Kubernetes­%}
#{kube_style2_content}
{% endtab %}
{% tab #{@tabs_name} Universal&nbsp; %}
{% tab #{@tabs_name} Universal­%}
#{uni_style2_content}
{% endtab %}"
end
Expand Down

0 comments on commit 140f3f6

Please sign in to comment.