Skip to content

Commit 917c837

Browse files
authored
feat: adds a new drop down to jump to same name containers (#3510)
1 parent 756b212 commit 917c837

File tree

7 files changed

+132
-17
lines changed

7 files changed

+132
-17
lines changed

assets/auto-imports.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ declare module 'vue' {
476476
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
477477
readonly onClickOutside: UnwrapRef<typeof import('@vueuse/core')['onClickOutside']>
478478
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
479-
readonly onElementRemoval: UnwrapRef<typeof import('@vueuse/core')['onElementRemoval']>
480479
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
481480
readonly onKeyStroke: UnwrapRef<typeof import('@vueuse/core')['onKeyStroke']>
482481
readonly onLongPress: UnwrapRef<typeof import('@vueuse/core')['onLongPress']>
@@ -671,7 +670,6 @@ declare module 'vue' {
671670
readonly usePreferredDark: UnwrapRef<typeof import('@vueuse/core')['usePreferredDark']>
672671
readonly usePreferredLanguages: UnwrapRef<typeof import('@vueuse/core')['usePreferredLanguages']>
673672
readonly usePreferredReducedMotion: UnwrapRef<typeof import('@vueuse/core')['usePreferredReducedMotion']>
674-
readonly usePreferredReducedTransparency: UnwrapRef<typeof import('@vueuse/core')['usePreferredReducedTransparency']>
675673
readonly usePrevious: UnwrapRef<typeof import('@vueuse/core')['usePrevious']>
676674
readonly useProfileStorage: UnwrapRef<typeof import('./composable/profileStorage')['useProfileStorage']>
677675
readonly useRafFn: UnwrapRef<typeof import('@vueuse/core')['useRafFn']>
@@ -680,7 +678,6 @@ declare module 'vue' {
680678
readonly useResizeObserver: UnwrapRef<typeof import('@vueuse/core')['useResizeObserver']>
681679
readonly useRoute: UnwrapRef<typeof import('vue-router')['useRoute']>
682680
readonly useRouter: UnwrapRef<typeof import('vue-router')['useRouter']>
683-
readonly useSSRWidth: UnwrapRef<typeof import('@vueuse/core')['useSSRWidth']>
684681
readonly useScreenOrientation: UnwrapRef<typeof import('@vueuse/core')['useScreenOrientation']>
685682
readonly useScreenSafeArea: UnwrapRef<typeof import('@vueuse/core')['useScreenSafeArea']>
686683
readonly useScriptTag: UnwrapRef<typeof import('@vueuse/core')['useScriptTag']>

assets/components/ContainerViewer/ContainerLog.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
<template #header v-if="showTitle">
44
<div class="@container mx-2 flex items-center gap-2 md:ml-4">
55
<ContainerTitle :container="container" />
6-
<MultiContainerStat class="ml-auto lg:hidden lg:@3xl:flex" :containers="[container]" />
6+
<MultiContainerStat
7+
class="ml-auto lg:hidden lg:@3xl:flex"
8+
:containers="[container]"
9+
v-if="container.state === 'running'"
10+
/>
711

812
<ContainerActionsToolbar @clear="viewer?.clear()" class="mobile-hidden" :container="container" />
913
<a class="btn btn-circle btn-xs" @click="close()" v-if="closable">

assets/components/ContainerViewer/ContainerTitle.vue

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
<template>
2-
<div class="@container flex flex-1 gap-1.5 truncate md:gap-2">
2+
<div class="@container flex flex-1 items-center gap-1.5 truncate md:gap-2">
33
<label class="swap swap-rotate size-4">
44
<input type="checkbox" v-model="pinned" />
55
<carbon:star-filled class="swap-on text-secondary" />
66
<carbon:star class="swap-off" />
77
</label>
8-
<div class="inline-flex font-mono text-sm">
9-
<div v-if="config.hosts.length > 1" class="mobile-hidden font-thin">
10-
{{ container.hostLabel }}<span class="mx-2">/</span>
11-
</div>
12-
<div class="font-semibold">{{ container.name }}</div>
13-
<div
14-
class="mobile-hidden max-w-[1.5em] truncate transition-[max-width] hover:max-w-[400px]"
15-
v-if="container.isSwarm"
16-
>
17-
.{{ container.swarmId }}
8+
<div class="inline-flex items-center text-sm">
9+
<div class="breadcrumbs p-0">
10+
<ul>
11+
<li v-if="config.hosts.length > 1" class="mobile-hidden font-thin">
12+
{{ container.hostLabel }}
13+
</li>
14+
<li>
15+
<div class="wrapper" ref="wrapper">
16+
<button popovertarget="popover-container-list" class="btn btn-xs md:btn-sm anchor font-mono">
17+
{{ container.name }} <carbon:caret-down />
18+
</button>
19+
<ul popover id="popover-container-list" class="dropdown menu rounded-box bg-base-100 tethered shadow-sm">
20+
<li v-for="other in otherContainers">
21+
<router-link :to="{ name: '/container/[id]', params: { id: other.id } }">
22+
<div
23+
class="status data-[state=exited]:status-error data-[state=running]:status-success"
24+
:data-state="other.state"
25+
></div>
26+
<div class="font-mono" v-if="other.isSwarm">{{ other.swarmId }}</div>
27+
<div class="font-mono" v-else>{{ other.name }}</div>
28+
<div v-if="other.state === 'running'">running</div>
29+
<DistanceTime :date="other.created" strict class="text-base-content/70 text-xs" v-else />
30+
</router-link>
31+
</li>
32+
</ul>
33+
</div>
34+
</li>
35+
</ul>
1836
</div>
1937
</div>
2038
<ContainerHealth :health="container.health" v-if="container.health" />
@@ -38,4 +56,41 @@ const pinned = computed({
3856
}
3957
},
4058
});
59+
const store = useContainerStore();
60+
const { containers: allContainers } = storeToRefs(store);
61+
62+
const otherContainers = computed(() =>
63+
[...allContainers.value.filter((c) => c.name === container.name && c.id !== container.id)].sort(
64+
(a, b) => +b.created - +a.created,
65+
),
66+
);
67+
const wrapper = useTemplateRef("wrapper");
68+
69+
onMounted(async () => {
70+
if (!("anchorName" in document.documentElement.style)) {
71+
// @ts-ignore
72+
const module = await import("@oddbird/css-anchor-positioning/fn");
73+
// @ts-ignore
74+
await module.default([wrapper.value]);
75+
}
76+
});
4177
</script>
78+
79+
<style scoped>
80+
/* https://github.com/oddbird/css-anchor-positioning/issues/282 */
81+
.wrapper {
82+
anchor-scope: --anchor;
83+
}
84+
85+
.anchor {
86+
anchor-name: --anchor;
87+
}
88+
89+
.tethered {
90+
margin: 0;
91+
padding: 0;
92+
position-anchor: --anchor;
93+
top: anchor(bottom);
94+
left: anchor(left);
95+
}
96+
</style>

assets/components/HostMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
class="group auto-cols-[auto_max-content_max-content]"
8484
>
8585
<div class="truncate">
86-
{{ item.name }}<span class="font-light opacity-70" v-if="item.isSwarm">.{{ item.swarmId }}</span>
86+
{{ item.name }}
8787
</div>
8888
<ContainerHealth :health="item.health" />
8989
<span

assets/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ const app = createApp(App);
66
Object.values(import.meta.glob<{ install: (app: VueApp) => void }>("./modules/*.ts", { eager: true })).forEach((i) =>
77
i.install?.(app),
88
);
9-
109
app.mount("#app");

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@iconify-json/octicon": "^1.2.2",
4040
"@iconify-json/ph": "^1.2.2",
4141
"@intlify/unplugin-vue-i18n": "^6.0.3",
42+
"@oddbird/css-anchor-positioning": "^0.4.0",
4243
"@tailwindcss/typography": "^0.5.15",
4344
"@tailwindcss/vite": "4.0.0-beta.8",
4445
"@vueuse/components": "^12.3.0",

pnpm-lock.yaml

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)