Skip to content

Commit 297415d

Browse files
committed
feat(frontend): truncate items inside ongoing tasks list
Restrict the size of the ongoing items menu to 320px, and truncate text inside of it to fit. Also refactor to Popover and constrain everything to the viewport accordingly. Signed-off-by: Edward Sammut Alessi <[email protected]>
1 parent 9d30ff5 commit 297415d

File tree

3 files changed

+68
-43
lines changed

3 files changed

+68
-43
lines changed

frontend/src/components/common/ActionsBox/TActionsBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const toggleState = ref(false)
2626

2727
<DropdownMenuPortal>
2828
<DropdownMenuContent
29-
class="bg-popover text-popover-foreground z-50 max-h-(--reka-dropdown-menu-content-available-height) origin-(--reka-dropdown-menu-content-transform-origin) rounded border border-naturals-n4 bg-naturals-n3 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95"
29+
class="z-50 max-h-(--reka-dropdown-menu-content-available-height) origin-(--reka-dropdown-menu-content-transform-origin) rounded border border-naturals-n4 bg-naturals-n3 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95"
3030
align="end"
3131
side="bottom"
3232
>

frontend/src/components/common/OngoingTasks/OngoingTasks.stories.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import { createWatchStreamHandler } from '@msw/helpers'
77
import type { Meta, StoryObj } from '@storybook/vue3-vite'
88
import { formatRFC3339 } from 'date-fns'
99

10-
import type { OngoingTaskSpec } from '@/api/omni/specs/omni.pb'
10+
import {
11+
KubernetesUpgradeStatusSpecPhase,
12+
type OngoingTaskSpec,
13+
TalosUpgradeStatusSpecPhase,
14+
} from '@/api/omni/specs/omni.pb'
1115
import { EphemeralNamespace, OngoingTaskType } from '@/api/resources'
1216

1317
import OngoingTasks from './OngoingTasks.vue'
@@ -35,29 +39,45 @@ export const Default: Story = {
3539
created: formatRFC3339(faker.date.recent()),
3640
},
3741
spec: {
38-
title: faker.animal.cat(),
42+
title: faker.string.uuid(),
3943
...faker.helpers.arrayElement([
4044
{
4145
kubernetes_upgrade: {
4246
last_upgrade_version: faker.system.semver(),
4347
current_upgrade_version: faker.system.semver(),
48+
phase: KubernetesUpgradeStatusSpecPhase.Upgrading,
4449
},
4550
},
4651
{
4752
talos_upgrade: {
4853
last_upgrade_version: faker.system.semver(),
4954
current_upgrade_version: faker.system.semver(),
55+
phase: TalosUpgradeStatusSpecPhase.Upgrading,
56+
},
57+
},
58+
{
59+
talos_upgrade: {
60+
last_upgrade_version: faker.system.semver(),
61+
phase: TalosUpgradeStatusSpecPhase.Reverting,
5062
},
5163
},
5264
{
5365
machine_upgrade: {
54-
schematic_id: faker.system.semver(),
55-
current_schematic_id: faker.system.semver(),
66+
schematic_id: faker.string.hexadecimal({
67+
prefix: '',
68+
casing: 'lower',
69+
length: 64,
70+
}),
71+
current_schematic_id: faker.string.hexadecimal({
72+
prefix: '',
73+
casing: 'lower',
74+
length: 64,
75+
}),
5676
},
5777
},
5878
{
5979
destroy: {
60-
phase: 'Destroying',
80+
phase: 'Destroying: 2 machine sets, 3 machines',
6181
},
6282
},
6383
]),

frontend/src/components/common/OngoingTasks/OngoingTasks.vue

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ Use of this software is governed by the Business Source License
55
included in the LICENSE file.
66
-->
77
<script setup lang="ts">
8-
import { vOnClickOutside } from '@vueuse/components'
8+
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
99
import { ref } from 'vue'
1010
1111
import { Runtime } from '@/api/common/omni.pb'
1212
import { type Resource } from '@/api/grpc'
1313
import { KubernetesUpgradeStatusSpecPhase, type OngoingTaskSpec } from '@/api/omni/specs/omni.pb'
1414
import { EphemeralNamespace, OngoingTaskType } from '@/api/resources'
1515
import { itemID } from '@/api/watch'
16-
import TAnimation from '@/components/common/Animation/TAnimation.vue'
1716
import TIcon from '@/components/common/Icon/TIcon.vue'
1817
import { useWatch } from '@/components/common/Watch/useWatch'
1918
import IconHeaderDropdownLoading from '@/components/icons/IconHeaderDropdownLoading.vue'
@@ -52,21 +51,12 @@ const getCurrentVersion = (item: Resource<OngoingTaskSpec>) => {
5251
5352
return item.spec.machine_upgrade?.schematic_id
5453
}
55-
56-
const toggleDropdown = () => {
57-
dropdownOpen.value = !dropdownOpen.value
58-
}
59-
60-
const onClickOutside = () => {
61-
dropdownOpen.value = false
62-
}
6354
</script>
6455

6556
<template>
66-
<div v-on-click-outside="onClickOutside" class="relative flex items-center">
67-
<div
68-
class="flex cursor-pointer items-center gap-1 text-naturals-n11 transition-colors hover:text-naturals-n14"
69-
@click="() => toggleDropdown()"
57+
<PopoverRoot v-model:open="dropdownOpen">
58+
<PopoverTrigger
59+
class="flex items-center gap-1 text-naturals-n11 transition-colors hover:text-naturals-n14"
7060
>
7161
<IconHeaderDropdownLoading :active="data.length > 0" />
7262
<span class="text-xs font-normal whitespace-nowrap select-none">
@@ -78,44 +68,57 @@ const onClickOutside = () => {
7868
:class="{ '-rotate-180': dropdownOpen }"
7969
icon="arrow-down"
8070
/>
81-
</div>
82-
83-
<TAnimation>
84-
<div
85-
v-show="dropdownOpen"
86-
class="absolute top-7 -right-2 z-30 rounded border border-naturals-n4 bg-naturals-n2"
71+
</PopoverTrigger>
72+
73+
<PopoverPortal>
74+
<PopoverContent
75+
class="z-30 max-h-(--reka-popover-content-available-height) max-w-[min(--spacing(80),var(--reka-popover-content-available-width))] min-w-(--reka-popover-trigger-width) origin-(--reka-popover-content-transform-origin) overflow-auto rounded border border-naturals-n4 bg-naturals-n2 slide-in-from-top-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95"
76+
:side-offset="10"
77+
align="end"
78+
side="bottom"
8779
>
8880
<div
8981
v-for="item in data"
9082
:key="itemID(item)"
91-
class="flex flex-col gap-2 p-6 not-last:border-b not-last:border-naturals-n4"
83+
class="flex flex-col gap-2 border-naturals-n4 p-6 not-last:border-b"
9284
>
9385
<div class="flex items-center justify-between gap-4">
94-
<h3 class="w-9/12 text-xs whitespace-nowrap text-naturals-n13">
86+
<h3 class="truncate text-xs text-naturals-n13">
9587
{{ item.spec.title }}
9688
</h3>
9789

98-
<span v-if="item.metadata.created" class="w-3/12 text-right text-xs text-naturals-n9">
90+
<span
91+
v-if="item.metadata.created"
92+
class="shrink-0 text-right text-xs whitespace-nowrap text-naturals-n9"
93+
>
9994
{{ formatISO(item.metadata.created, 'HH:mm:ss') }}
10095
</span>
10196
</div>
10297

103-
<div class="truncate text-xs text-naturals-n9">
104-
<template v-if="item.spec.destroy">
98+
<div class="text-xs text-naturals-n9">
99+
<span v-if="item.spec.destroy" class="truncate">
105100
{{ item.spec.destroy.phase }}
106-
</template>
101+
</span>
107102

108103
<div v-else class="flex items-center gap-2 text-xs">
109104
<template v-if="getCurrentVersion(item)">
110-
<span v-if="item.spec.kubernetes_upgrade">Upgrade Kubernetes</span>
111-
<span v-else-if="item.spec.machine_upgrade">Upgrade Machine</span>
112-
<span v-else>Upgrade Talos</span>
105+
<span v-if="item.spec.kubernetes_upgrade" class="whitespace-nowrap">
106+
Upgrade Kubernetes
107+
</span>
108+
<span v-else-if="item.spec.machine_upgrade" class="whitespace-nowrap">
109+
Upgrade Machine
110+
</span>
111+
<span v-else class="whitespace-nowrap">Upgrade Talos</span>
113112
<div class="flex-1" />
114-
<span class="rounded bg-naturals-n4 px-2 text-xs font-bold text-naturals-n13">
113+
<span
114+
class="truncate rounded bg-naturals-n4 px-2 text-xs font-bold text-naturals-n13"
115+
>
115116
{{ getPreviousVersion(item) }}
116117
</span>
117118
<span>⇾</span>
118-
<span class="rounded bg-naturals-n4 px-2 text-xs font-bold text-naturals-n13">
119+
<span
120+
class="truncate rounded bg-naturals-n4 px-2 text-xs font-bold text-naturals-n13"
121+
>
119122
{{ getCurrentVersion(item) }}
120123
</span>
121124
</template>
@@ -126,16 +129,18 @@ const onClickOutside = () => {
126129
KubernetesUpgradeStatusSpecPhase.Reverting
127130
"
128131
>
129-
<span>Reverting back to</span>
132+
<span class="whitespace-nowrap">Reverting back to</span>
130133
<div class="flex-1" />
131-
<span class="rounded bg-naturals-n4 px-2 text-xs font-bold text-naturals-n13">
134+
<span
135+
class="rounded bg-naturals-n4 px-2 text-xs font-bold whitespace-nowrap text-naturals-n13"
136+
>
132137
{{
133138
(item.spec.kubernetes_upgrade ?? item.spec.talos_upgrade)?.last_upgrade_version
134139
}}
135140
</span>
136141
</template>
137142

138-
<span v-else>Updating machine schematics</span>
143+
<span v-else class="whitespace-nowrap">Updating machine schematics</span>
139144
</div>
140145
</div>
141146
</div>
@@ -144,7 +149,7 @@ const onClickOutside = () => {
144149
<TIcon icon="check" class="h-4 w-4" />
145150
No tasks
146151
</div>
147-
</div>
148-
</TAnimation>
149-
</div>
152+
</PopoverContent>
153+
</PopoverPortal>
154+
</PopoverRoot>
150155
</template>

0 commit comments

Comments
 (0)