Skip to content

Commit

Permalink
Merge pull request #12375 from richard-cox/fleet-improvements
Browse files Browse the repository at this point in the history
[2.10] Fleet Improvements
  • Loading branch information
richard-cox authored Oct 29, 2024
2 parents 38c9ed9 + 965833d commit df953cd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 31 deletions.
3 changes: 0 additions & 3 deletions shell/components/fleet/FleetClusters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ export default {
value: 'status.display.readyBundles',
sort: 'status.summary.ready',
search: false,
align: 'center',
},
{
name: 'reposReady',
labelKey: 'tableHeaders.reposReady',
value: 'status.readyGitRepos',
sort: 'status.summary.ready',
search: false,
align: 'center',
},
FLEET_SUMMARY,
{
Expand All @@ -62,7 +60,6 @@ export default {
formatter: 'LiveDate',
formatterOpts: { addSuffix: true },
width: 120,
align: 'right'
},
AGE,
];
Expand Down
20 changes: 11 additions & 9 deletions shell/detail/fleet.cattle.io.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ResourceTabs from '@shell/components/form/ResourceTabs';
import Tab from '@shell/components/Tabbed/Tab';
import { MANAGEMENT, FLEET } from '@shell/config/types';
import { FLEET as FLEET_LABELS } from '@shell/config/labels-annotations';
import { allHash } from 'utils/promise';
export default {
name: 'FleetDetailCluster',
Expand All @@ -29,17 +30,18 @@ export default {
async fetch() {
const clusterId = this.value?.metadata?.labels[FLEET_LABELS.CLUSTER_NAME];
this.rancherCluster = await this.$store.dispatch('management/find', {
type: MANAGEMENT.CLUSTER,
id: clusterId
const hash = await allHash({
rancherCluster: this.$store.dispatch('management/find', {
type: MANAGEMENT.CLUSTER,
id: clusterId
}),
repos: this.$store.dispatch('management/findAll', { type: FLEET.GIT_REPO }),
workspaces: this.$store.dispatch('management/findAll', { type: FLEET.WORKSPACE }),
bundleDeployments: this.$store.dispatch('management/findAll', { type: FLEET.BUNDLE_DEPLOYMENT })
});
this.allRepos = await this.$store.dispatch('management/findAll', { type: FLEET.GIT_REPO });
await this.$store.dispatch('management/findAll', { type: FLEET.WORKSPACE });
await this.$store.dispatch('management/findAll', { type: FLEET.BUNDLE_DEPLOYMENT });
this.rancherCluster = hash.rancherCluster;
this.allRepos = hash.repos;
},
data() {
Expand Down
2 changes: 1 addition & 1 deletion shell/detail/fleet.cattle.io.gitrepo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
},
computed: {
gitRepoHasClusters() {
return this.value?.clusterResourceStatus?.length;
return this.value.status.desiredReadyClusters;
},
clusterSchema() {
return this.$store.getters['management/schemaFor'](FLEET.CLUSTER);
Expand Down
17 changes: 4 additions & 13 deletions shell/models/fleet.cattle.io.gitrepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,11 @@ export default class GitRepo extends SteveModel {
bundle.namespacedName.startsWith(`${ this.namespace }:${ this.name }`));
}

/**
* Bundles with state of active
*/
get bundlesReady() {
if (this.bundles && this.bundles.length) {
return this.bundles.filter((bundle) => bundle.state === 'active');
}

return 0;
}

get targetClustersReady() {
if (this.targetClusters && this.targetClusters.length) {
return this.targetClusters.filter((cluster) => cluster.state === 'active');
}

return 0;
return this.bundles?.filter((bundle) => bundle.state === 'active');
}

get bundleDeployments() {
Expand Down
16 changes: 11 additions & 5 deletions shell/pages/c/_cluster/fleet/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { WORKSPACE_ANNOTATION } from '@shell/config/labels-annotations';
import { filterBy } from '@shell/utils/array';
import FleetNoWorkspaces from '@shell/components/fleet/FleetNoWorkspaces.vue';
import { NAME } from '@shell/config/product/fleet';
import { xOfy } from '@shell/utils/string';
export default {
name: 'FleetDashboard',
Expand Down Expand Up @@ -175,7 +176,12 @@ export default {
}
if (area === 'clusters') {
group = row.targetClusters;
if (row.clusterInfo?.ready === row.clusterInfo?.total && row.clusterInfo?.ready) {
return {
badgeClass: STATES[STATES_ENUM.ACTIVE].color,
icon: STATES[STATES_ENUM.ACTIVE].compoundIcon
};
}
} else if (area === 'bundles') {
group = row.bundles;
} else if (area === 'resources') {
Expand Down Expand Up @@ -223,7 +229,7 @@ export default {
}
if (area === 'clusters') {
group = row.targetClusters;
group = '';
} else if (area === 'bundles') {
group = row.bundles;
} else if (area === 'resources') {
Expand Down Expand Up @@ -262,11 +268,11 @@ export default {
}
if (area === 'clusters') {
value = `${ row.targetClustersReady?.length || '0' }/${ row.targetClusters?.length || '?' }`;
return `${ row.clusterInfo.ready }/${ row.clusterInfo.total }`;
} else if (area === 'bundles') {
value = `${ row.bundlesReady?.length || '0' }/${ row.bundles?.length || '?' }`;
value = xOfy(row.bundlesReady?.length, row.bundles?.length);
} else if (area === 'resources') {
value = `${ row.status?.resourceCounts?.ready || '0' }/${ row.status?.resourceCounts?.desiredReady || '?' }`;
value = xOfy(row.status?.resourceCounts?.ready, row.status?.resourceCounts?.desiredReady);
}
return value;
Expand Down
9 changes: 9 additions & 0 deletions shell/utils/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,12 @@ export function sanitizeValue(v) {
export function sanitizeIP(v) {
return (v || '').replace(/[^a-z0-9.:_-]/ig, '');
}

/**
* Return the string `<x> / <y>`
*
* Each param should be a number, otherwise `?` is used
*/
export function xOfy(x, y) {
return `${ typeof x === 'number' ? x : '?' }/${ typeof y === 'number' ? y : '?' }`;
}

0 comments on commit df953cd

Please sign in to comment.