diff --git a/assets/components/HostMenu.vue b/assets/components/HostMenu.vue index 5af9b8fd..5a05431c 100644 --- a/assets/components/HostMenu.vue +++ b/assets/components/HostMenu.vue @@ -90,6 +90,7 @@ import Pin from "~icons/ph/map-pin-simple"; import Stack from "~icons/ph/stack"; // @ts-ignore import Containers from "~icons/octicon/container-24"; +import { RouteLocationNormalizedLoaded } from "vue-router"; const containerStore = useContainerStore(); const { visibleContainers } = storeToRefs(containerStore); @@ -166,6 +167,21 @@ const menuItems = computed(() => { return items; }); + +const route = useRoute(); + +const updateHostForContainerRoute = (to: RouteLocationNormalizedLoaded) => { + if (to.name === "container-id") { + const container = containerStore.findContainerById(to.params.id as string); + if (container) { + setHost(container.host); + } + } +}; + +updateHostForContainerRoute(route); + +onBeforeRouteUpdate((to) => updateHostForContainerRoute(to));