Skip to content

Commit a6562dc

Browse files
committed
fix(frontend): fix alignment of provisioning machines
Fix the alignment of provisioning machines on the clusters page Signed-off-by: Edward Sammut Alessi <[email protected]>
1 parent 543f831 commit a6562dc

File tree

6 files changed

+110
-195
lines changed

6 files changed

+110
-195
lines changed

frontend/src/views/cluster/ClusterMachines/ClusterMachines.vue

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,89 +5,58 @@ 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 type { Ref } from 'vue'
9-
import { computed, ref, toRefs } from 'vue'
8+
import { computed } from 'vue'
109
1110
import { Runtime } from '@/api/common/omni.pb'
12-
import type { Resource } from '@/api/grpc'
1311
import type { ClusterDiagnosticsSpec, MachineSetSpec } from '@/api/omni/specs/omni.pb'
1412
import {
1513
ClusterDiagnosticsType,
1614
DefaultNamespace,
1715
LabelCluster,
18-
LabelControlPlaneRole,
19-
MachineSetNodeType,
2016
MachineSetStatusType,
2117
MachineSetType,
2218
} from '@/api/resources'
23-
import WatchResource, { itemID } from '@/api/watch'
19+
import { itemID } from '@/api/watch'
20+
import { useWatch } from '@/components/common/Watch/useWatch'
2421
import Watch from '@/components/common/Watch/Watch.vue'
2522
import { sortMachineSetIds } from '@/methods/machineset'
2623
2724
import MachineSet from './MachineSet.vue'
2825
29-
const props = defineProps<{
26+
const { clusterID } = defineProps<{
3027
clusterID: string
3128
isSubgrid?: boolean
3229
}>()
3330
34-
const { clusterID } = toRefs(props)
35-
36-
const machineSets: Ref<Resource<MachineSetSpec>[]> = ref([])
37-
const clusterDiagnostics: Ref<Resource<ClusterDiagnosticsSpec> | undefined> = ref()
38-
39-
const machineSetsWatch = new WatchResource(machineSets)
40-
const clusterDiagnosticsWatch = new WatchResource(clusterDiagnostics)
41-
42-
machineSetsWatch.setup(
43-
computed(() => {
44-
return {
45-
resource: {
46-
type: MachineSetType,
47-
namespace: DefaultNamespace,
48-
},
49-
runtime: Runtime.Omni,
50-
selectors: [`${LabelCluster}=${clusterID.value}`],
51-
}
52-
}),
53-
)
31+
const { data: machineSets } = useWatch<MachineSetSpec>(() => ({
32+
resource: {
33+
type: MachineSetType,
34+
namespace: DefaultNamespace,
35+
},
36+
runtime: Runtime.Omni,
37+
selectors: [`${LabelCluster}=${clusterID}`],
38+
}))
5439
55-
clusterDiagnosticsWatch.setup({
40+
const { data: clusterDiagnostics } = useWatch<ClusterDiagnosticsSpec>(() => ({
5641
runtime: Runtime.Omni,
5742
resource: {
5843
namespace: DefaultNamespace,
5944
type: ClusterDiagnosticsType,
60-
id: clusterID.value,
45+
id: clusterID,
6146
},
62-
})
47+
}))
6348
6449
const nodesWithDiagnostics = computed(() => {
65-
const nodes = clusterDiagnostics.value?.spec?.nodes?.map((node) => node.id ?? '') ?? []
50+
const nodes = clusterDiagnostics.value?.spec.nodes?.map((node) => node.id ?? '') ?? []
6651
return new Set(nodes)
6752
})
6853
6954
const watches = computed(() =>
7055
sortMachineSetIds(
71-
clusterID.value,
72-
machineSets.value.map((machineSet) => machineSet?.metadata?.id ?? ''),
56+
clusterID,
57+
machineSets.value.map((machineSet) => machineSet.metadata.id ?? ''),
7358
),
7459
)
75-
76-
const controlPlaneNodes = ref<Resource[]>([])
77-
78-
const machineNodesWatch = new WatchResource(controlPlaneNodes)
79-
machineNodesWatch.setup(
80-
computed(() => {
81-
return {
82-
resource: {
83-
type: MachineSetNodeType,
84-
namespace: DefaultNamespace,
85-
},
86-
runtime: Runtime.Omni,
87-
selectors: [`${LabelControlPlaneRole}`],
88-
}
89-
}),
90-
)
9160
</script>
9261

9362
<template>

frontend/src/views/cluster/ClusterMachines/MachineRequest.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ const stage = computed(() => {
4040
</script>
4141

4242
<template>
43-
<div
44-
class="col-span-full grid grid-cols-subgrid items-center gap-1 py-6 pr-11 pl-3 text-xs text-naturals-n14"
45-
>
46-
<div class="col-span-2 ml-5 flex items-center gap-2">
43+
<div class="col-span-full grid grid-cols-subgrid items-center p-2 pr-4 text-xs text-naturals-n14">
44+
<div class="col-span-2 ml-6 flex items-center gap-2">
4745
<IconHeaderDropdownLoading
4846
v-if="stage !== TCommonStatuses.PROVISIONED"
4947
active
50-
class="ml-2 h-4 w-4"
48+
class="size-4"
5149
/>
52-
<TIcon v-else icon="cloud-connection" class="ml-2 h-4 w-4" />
50+
<TIcon v-else icon="cloud-connection" class="size-4" />
5351
{{ requestStatus.metadata.id }}
5452
</div>
5553

frontend/src/views/cluster/ClusterMachines/MachineSet.vue

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ import {
2929
LabelMachineSet,
3030
MachineClassType,
3131
} from '@/api/resources'
32-
import Watch, { itemID } from '@/api/watch'
32+
import { itemID } from '@/api/watch'
3333
import TActionsBox from '@/components/common/ActionsBox/TActionsBox.vue'
3434
import TActionsBoxItem from '@/components/common/ActionsBox/TActionsBoxItem.vue'
3535
import IconButton from '@/components/common/Button/IconButton.vue'
3636
import TButton from '@/components/common/Button/TButton.vue'
3737
import TIcon from '@/components/common/Icon/TIcon.vue'
3838
import TSpinner from '@/components/common/Spinner/TSpinner.vue'
3939
import TInput from '@/components/common/TInput/TInput.vue'
40+
import { useWatch } from '@/components/common/Watch/useWatch'
4041
import { setupClusterPermissions } from '@/methods/auth'
4142
import {
4243
controlPlaneMachineSetId,
@@ -60,12 +61,6 @@ const props = defineProps<{
6061
6162
const { machineSet } = toRefs(props)
6263
63-
const machines = ref<Resource<ClusterMachineStatusSpec>[]>([])
64-
const machinesWatch = new Watch(machines)
65-
66-
const requests = ref<Resource<ClusterMachineRequestStatusSpec>[]>([])
67-
const requestsWatch = new Watch(requests)
68-
6964
const clusterID = computed(() => machineSet.value.metadata.labels?.[LabelCluster] ?? '')
7065
const editingMachinesCount = ref(false)
7166
const machineCount = ref(machineSet.value.spec.machine_allocation?.machine_count ?? 1)
@@ -99,43 +94,32 @@ const hiddenMachinesCount = computed(() => {
9994
return Math.max(0, (machineSet.value.spec.machines?.total || 0) - showMachinesCount.value)
10095
})
10196
102-
machinesWatch.setup(
103-
computed(() => {
104-
return {
105-
resource: {
106-
namespace: DefaultNamespace,
107-
type: ClusterMachineStatusType,
108-
},
109-
runtime: Runtime.Omni,
110-
selectors: [
111-
`${LabelCluster}=${clusterID.value}`,
112-
`${LabelMachineSet}=${machineSet.value.metadata.id!}`,
113-
],
114-
limit: showMachinesCount.value,
115-
}
116-
}),
117-
)
118-
119-
requestsWatch.setup(
120-
computed(() => {
121-
if (!machineSet.value.spec.machine_allocation) {
122-
return
123-
}
124-
125-
return {
126-
resource: {
127-
namespace: DefaultNamespace,
128-
type: ClusterMachineRequestStatusType,
129-
},
130-
selectors: [
131-
`${LabelCluster}=${clusterID.value}`,
132-
`${LabelMachineSet}=${machineSet.value.metadata.id!}`,
133-
],
134-
runtime: Runtime.Omni,
135-
limit: showMachinesCount.value,
136-
}
137-
}),
138-
)
97+
const { data: machines } = useWatch<ClusterMachineStatusSpec>(() => ({
98+
resource: {
99+
namespace: DefaultNamespace,
100+
type: ClusterMachineStatusType,
101+
},
102+
runtime: Runtime.Omni,
103+
selectors: [
104+
`${LabelCluster}=${clusterID.value}`,
105+
`${LabelMachineSet}=${machineSet.value.metadata.id}`,
106+
],
107+
limit: showMachinesCount.value,
108+
}))
109+
110+
const { data: requests } = useWatch<ClusterMachineRequestStatusSpec>(() => ({
111+
skip: !machineSet.value.spec.machine_allocation,
112+
resource: {
113+
namespace: DefaultNamespace,
114+
type: ClusterMachineRequestStatusType,
115+
},
116+
selectors: [
117+
`${LabelCluster}=${clusterID.value}`,
118+
`${LabelMachineSet}=${machineSet.value.metadata.id}`,
119+
],
120+
runtime: Runtime.Omni,
121+
limit: showMachinesCount.value,
122+
}))
139123
140124
const pendingRequests = computed(() => {
141125
return requests.value.filter(

frontend/src/views/omni/Clusters/ClusterItem.vue

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,12 @@ included in the LICENSE file.
66
-->
77
<script setup lang="ts">
88
import { useElementSize, useSessionStorage } from '@vueuse/core'
9-
import type { Ref } from 'vue'
10-
import { computed, ref, toRefs, useId, useTemplateRef } from 'vue'
11-
import { useRouter } from 'vue-router'
9+
import { computed, useId, useTemplateRef } from 'vue'
1210
import WordHighlighter from 'vue-word-highlighter'
1311
14-
import { Runtime } from '@/api/common/omni.pb'
1512
import type { Resource } from '@/api/grpc'
16-
import type { ClusterStatusSpec, MachineSetSpec } from '@/api/omni/specs/omni.pb'
17-
import {
18-
ClusterLocked,
19-
DefaultNamespace,
20-
LabelCluster,
21-
LabelMachineSet,
22-
MachineSetNodeType,
23-
MachineSetType,
24-
} from '@/api/resources'
25-
import WatchResource from '@/api/watch'
13+
import type { ClusterStatusSpec } from '@/api/omni/specs/omni.pb'
14+
import { ClusterLocked } from '@/api/resources'
2615
import TActionsBox from '@/components/common/ActionsBox/TActionsBox.vue'
2716
import TActionsBoxItem from '@/components/common/ActionsBox/TActionsBoxItem.vue'
2817
import IconButton from '@/components/common/Button/IconButton.vue'
@@ -32,12 +21,15 @@ import { downloadKubeconfig, downloadTalosconfig } from '@/methods'
3221
import { setupClusterPermissions } from '@/methods/auth'
3322
import { addClusterLabels, removeClusterLabels } from '@/methods/cluster'
3423
import type { Label } from '@/methods/labels'
35-
import { controlPlaneMachineSetId } from '@/methods/machineset'
3624
import ClusterMachines from '@/views/cluster/ClusterMachines/ClusterMachines.vue'
3725
import ClusterStatus from '@/views/omni/Clusters/ClusterStatus.vue'
3826
import ItemLabels from '@/views/omni/ItemLabels/ItemLabels.vue'
3927
40-
const props = defineProps<{
28+
const {
29+
item,
30+
defaultOpen,
31+
searchQuery = '',
32+
} = defineProps<{
4133
item: Resource<ClusterStatusSpec>
4234
defaultOpen?: boolean
4335
searchQuery?: string
@@ -47,60 +39,16 @@ defineEmits<{
4739
filterLabels: [Label]
4840
}>()
4941
50-
const { item } = toRefs(props)
51-
const expanded = useSessionStorage(`cluster-expanded-${item.value.metadata.id}`, props.defaultOpen)
52-
53-
const router = useRouter()
54-
55-
const openClusterDestroy = () => {
56-
router.push({
57-
query: { modal: 'clusterDestroy', cluster: item.value.metadata.id },
58-
})
59-
}
60-
61-
const machineSets: Ref<Resource<MachineSetSpec>[]> = ref([])
62-
const machineSetsWatch = new WatchResource(machineSets)
63-
machineSetsWatch.setup(
64-
computed(() => {
65-
if (!expanded) return
66-
67-
return {
68-
resource: {
69-
type: MachineSetType,
70-
namespace: DefaultNamespace,
71-
},
72-
runtime: Runtime.Omni,
73-
selectors: [`${LabelCluster}=${item.value.metadata.id!}`],
74-
}
75-
}),
76-
)
42+
const expanded = useSessionStorage(() => `cluster-expanded-${item.metadata.id}`, defaultOpen)
7743
7844
const {
7945
canDownloadKubeconfig,
8046
canDownloadTalosconfig,
8147
canAddClusterMachines,
8248
canRemoveClusterMachines,
83-
} = setupClusterPermissions(computed(() => item.value.metadata.id!))
84-
85-
const controlPlaneNodes = ref<Resource[]>([])
86-
87-
const machineNodesWatch = new WatchResource(controlPlaneNodes)
88-
machineNodesWatch.setup(
89-
computed(() => {
90-
if (!expanded) return
91-
92-
return {
93-
resource: {
94-
type: MachineSetNodeType,
95-
namespace: DefaultNamespace,
96-
},
97-
runtime: Runtime.Omni,
98-
selectors: [`${LabelMachineSet}=${controlPlaneMachineSetId(item.value.metadata.id!)}`],
99-
}
100-
}),
101-
)
49+
} = setupClusterPermissions(computed(() => item.metadata.id!))
10250
103-
const locked = computed(() => item.value.metadata.annotations?.[ClusterLocked] !== undefined)
51+
const locked = computed(() => item.metadata.annotations?.[ClusterLocked] !== undefined)
10452
10553
const regionId = useId()
10654
const labelId = useId()
@@ -136,7 +84,7 @@ const { height } = useElementSize(slider)
13684
class="list-item-link grow truncate"
13785
>
13886
<WordHighlighter
139-
:query="searchQuery ?? ''"
87+
:query="searchQuery"
14088
:text-to-highlight="item.metadata.id"
14189
split-by-space
14290
highlight-class="bg-naturals-n14"
@@ -216,7 +164,7 @@ const { height } = useElementSize(slider)
216164
v-if="canRemoveClusterMachines"
217165
icon="delete"
218166
danger
219-
@click="openClusterDestroy"
167+
@click="$router.push({ query: { modal: 'clusterDestroy', cluster: item.metadata.id } })"
220168
>
221169
Destroy Cluster
222170
</TActionsBoxItem>

0 commit comments

Comments
 (0)