From 0ab0f86443d57d525eaa5018dd2c235f966d92b5 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 5 Aug 2024 17:20:48 +0100 Subject: [PATCH 1/2] Fix prv/mgmt cluster description issues See #11588 for details - mgmt cluster is a steve resource, so can inherit the steve model - this resolve the issue of mgmt cluster not having a description - prv cluster uses it's own description, falls back on mgmt description - custom stuff on home screen not needed - fixes description on detail page of legacy clusters - remove description from hybrid model - this contains steve references and isn't needed --- shell/models/management.cattle.io.cluster.js | 4 ++-- shell/models/provisioning.cattle.io.cluster.js | 4 ++++ shell/pages/home.vue | 14 +------------- shell/plugins/steve/hybrid-class.js | 4 ---- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/shell/models/management.cattle.io.cluster.js b/shell/models/management.cattle.io.cluster.js index 0adab10bc91..8a23bdf39b5 100644 --- a/shell/models/management.cattle.io.cluster.js +++ b/shell/models/management.cattle.io.cluster.js @@ -10,7 +10,7 @@ import { addParams } from '@shell/utils/url'; import { isEmpty } from '@shell/utils/object'; import { HARVESTER_NAME as HARVESTER } from '@shell/config/features'; import { isHarvesterCluster } from '@shell/utils/cluster'; -import HybridModel from '@shell/plugins/steve/hybrid-class'; +import SteveModel from '@shell/plugins/steve/steve-class'; import { LINUX, WINDOWS } from '@shell/store/catalog'; import { KONTAINER_TO_DRIVER } from './management.cattle.io.kontainerdriver'; import { PINNED_CLUSTERS } from '@shell/store/prefs'; @@ -27,7 +27,7 @@ function findRelationship(verb, type, relationships = []) { return relationships.find((r) => r[from] === type)?.[id]; } -export default class MgmtCluster extends HybridModel { +export default class MgmtCluster extends SteveModel { get details() { const out = [ { diff --git a/shell/models/provisioning.cattle.io.cluster.js b/shell/models/provisioning.cattle.io.cluster.js index 74d603825b8..f060cadd6e4 100644 --- a/shell/models/provisioning.cattle.io.cluster.js +++ b/shell/models/provisioning.cattle.io.cluster.js @@ -986,4 +986,8 @@ export default class ProvCluster extends SteveModel { 'spec.rkeConfig.machinePools.dynamicSchemaSpec', ]; } + + get description() { + return super.description || this.mgmt?.description; + } } diff --git a/shell/pages/home.vue b/shell/pages/home.vue index 1abb7d2f44c..4a1b03bd914 100644 --- a/shell/pages/home.vue +++ b/shell/pages/home.vue @@ -91,10 +91,6 @@ export default { ...mapGetters(['currentCluster', 'defaultClusterId', 'releaseNotesUrl']), mcm: mapFeature(MULTI_CLUSTER), - mgmtClusters() { - return this.$store.getters['management/all'](MANAGEMENT.CLUSTER); - }, - provClusters() { return this.$store.getters['management/all'](CAPI.RANCHER_CLUSTER); }, @@ -211,15 +207,7 @@ export default { }, kubeClusters() { - const filteredClusters = filterHiddenLocalCluster(filterOnlyKubernetesClusters(this.provClusters || [], this.$store), this.$store); - - return filteredClusters.map((provCluster) => { - const mgmtCluster = this.mgmtClusters?.find((c) => provCluster.mgmt?.id === c.id); - - provCluster.description = provCluster.description || mgmtCluster?.description; - - return provCluster; - }); + return filterHiddenLocalCluster(filterOnlyKubernetesClusters(this.provClusters || [], this.$store), this.$store); } }, diff --git a/shell/plugins/steve/hybrid-class.js b/shell/plugins/steve/hybrid-class.js index 0a435099936..873baa0a3ac 100644 --- a/shell/plugins/steve/hybrid-class.js +++ b/shell/plugins/steve/hybrid-class.js @@ -100,8 +100,4 @@ export default class HybridModel extends Resource { get state() { return this.stateObj?.name || 'unknown'; } - - get description() { - return this.metadata?.annotations?.[DESCRIPTION] || this.spec?.description || this._description; - } } From 035fc68803e1a525d9306c48da37d3fe074de83e Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Tue, 6 Aug 2024 08:50:46 +0100 Subject: [PATCH 2/2] Fix lint --- shell/plugins/steve/hybrid-class.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/plugins/steve/hybrid-class.js b/shell/plugins/steve/hybrid-class.js index 873baa0a3ac..e004d6e423d 100644 --- a/shell/plugins/steve/hybrid-class.js +++ b/shell/plugins/steve/hybrid-class.js @@ -1,4 +1,4 @@ -import { ANNOTATIONS_TO_IGNORE_REGEX, LABELS_TO_IGNORE_REGEX, DESCRIPTION } from '@shell/config/labels-annotations'; +import { ANNOTATIONS_TO_IGNORE_REGEX, LABELS_TO_IGNORE_REGEX } from '@shell/config/labels-annotations'; import omitBy from 'lodash/omitBy'; import pickBy from 'lodash/pickBy'; import Vue from 'vue';