forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfleet.cattle.io.bundle.vue
108 lines (93 loc) · 2.55 KB
/
fleet.cattle.io.bundle.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<script>
import { FLEET } from '@/config/types';
import Banner from '@/components/Banner';
import Loading from '@/components/Loading';
import ResourceTable from '@/components/ResourceTable';
import {
AGE,
STATE,
NAME,
} from '@/config/table-headers';
import { isHarvesterCluster } from '@/utils/cluster';
export default {
name: 'ListBundle',
components: {
Banner, Loading, ResourceTable
},
props: {
schema: {
type: Object,
required: true,
},
},
async fetch() {
this.allBundles = await this.$store.dispatch('management/findAll', { type: FLEET.BUNDLE });
this.allFleet = await this.$store.dispatch('management/findAll', { type: FLEET.CLUSTER });
},
data() {
return {
allFleet: [],
allBundles: [],
};
},
computed: {
harvesterClusters() {
const harvester = {};
this.allFleet.forEach((c) => {
if (isHarvesterCluster(c)) {
harvester[c.metadata.name] = c;
}
});
return harvester;
},
bundles() {
const harvester = this.harvesterClusters;
return this.allBundles.filter((bundle) => {
const targets = bundle.spec?.targets || [];
// Filter out any bundle that has one target whose cluster is a harvester cluster
if (targets.length === 1) {
return !harvester[targets[0].clusterName];
}
return true;
});
},
hidden() {
return this.allBundles.length - this.bundles.length;
},
headers() {
const out = [
STATE,
NAME,
{
name: 'deploymentsReady',
labelKey: 'tableHeaders.bundleDeploymentsReady',
value: 'status.display.readyClusters',
sort: 'status.display.readyClusters',
search: ['status.summary.ready', 'status.summary.desiredReady'],
},
AGE
];
return out;
},
},
};
</script>
<template>
<div>
<Loading v-if="$fetchState.pending" />
<div v-else>
<Banner v-if="hidden" color="info" :label="t('fleet.bundles.harvester', {count: hidden} )" />
<ResourceTable
:schema="schema"
:headers="headers"
:rows="bundles"
>
<template #cell:deploymentsReady="{row}">
<span v-if="row.status.summary.desiredReady != row.status.summary.ready" class="text-warning">
{{ row.status.summary.ready }}/{{ row.status.summary.desiredReady }}</span>
<span v-else>{{ row.status.summary.desiredReady }}</span>
</template>
</ResourceTable>
</div>
</div>
</template>