VAULT-32677 - Fix missing client count card in managed clusters (#29241)

* add check for admin namespace on managed clusters

* add tests for client count card in managed clusters

* add changelog
This commit is contained in:
Evan Moncuso
2025-01-07 12:53:06 -08:00
committed by GitHub
parent 6e3ae793f5
commit 035b7e6d8e
4 changed files with 97 additions and 5 deletions

3
changelog/29241.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
UI: Fix missing Client Count card when running as a Vault Dedicated cluster
```

View File

@@ -7,12 +7,14 @@
<div class="has-bottom-margin-xl">
<div class="is-flex-row gap-24">
{{#if (and @version.isEnterprise @isRootNamespace)}}
{{#if @version.isEnterprise}}
<div class="is-flex-column is-flex-1 gap-24">
{{#if (has-permission "clients" routeParams="activity")}}
{{#if (and (has-permission "clients" routeParams="activity") this.shouldShowClientCount)}}
<Dashboard::ClientCountCard />
{{/if}}
{{#if (and (has-permission "status" routeParams="replication") (not (is-empty-value @replication)))}}
{{#if
(and (has-permission "status" routeParams="replication") (not (is-empty-value @replication)) @isRootNamespace)
}}
<Dashboard::ReplicationCard
@replication={{@replication}}
@version={{@version}}
@@ -33,7 +35,6 @@
<Dashboard::SurveyLinkText />
</div>
</div>
{{else}}
<div class="is-flex-column is-flex-1 gap-24">
<Dashboard::SecretsEnginesCard @secretsEngines={{@secretsEngines}} />

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { service } from '@ember/service';
import type flagsService from 'vault/services/flags';
import NamespaceService from 'vault/services/namespace';
export type Args = {
isRootNamespace: boolean;
replication: unknown;
secretsEngines: unknown;
vaultConfiguration: unknown;
version: { isEnterprise: boolean };
};
export default class OverviewComponent extends Component<Args> {
@service declare readonly flags: flagsService;
@service declare readonly namespace: NamespaceService;
/**
* the client count card should show in the following conditions
* Self Managed clusters that are running enterprise and showing the `root` namespace
* Managed clusters that are running enterprise and show the `admin` namespace
*/
// for self managed clusters, this is the `root` namespace
// for HVD clusters, this is the `admin` namespace
get shouldShowClientCount() {
const { version, isRootNamespace } = this.args;
const { flags, namespace } = this;
// don't show client count if this isn't an enterprise cluster
if (!version.isEnterprise) return false;
// HVD clusters
if (flags.isHvdManaged && namespace.currentNamespace === 'admin') return true;
// SM clusters
if (isRootNamespace) return true;
return false;
}
}

View File

@@ -15,8 +15,10 @@ module('Integration | Component | dashboard/overview', function (hooks) {
setupMirage(hooks);
hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
this.flags = this.owner.lookup('service:flags');
this.namespace = this.owner.lookup('service:namespace');
this.permissions = this.owner.lookup('service:permissions');
this.store = this.owner.lookup('service:store');
this.version = this.owner.lookup('service:version');
this.version.version = '1.13.1+ent';
this.version.type = 'enterprise';
@@ -151,6 +153,46 @@ module('Integration | Component | dashboard/overview', function (hooks) {
assert.dom(DASHBOARD.cardName('replication')).exists();
});
test('it should show client count on enterprise in admin namespace when running a managed mode', async function (assert) {
this.permissions.exactPaths = {
'admin/sys/internal/counters/activity': {
capabilities: ['read'],
},
'admin/sys/replication/status': {
capabilities: ['read'],
},
};
this.version.type = 'enterprise';
this.flags.featureFlags = ['VAULT_CLOUD_ADMIN_NAMESPACE'];
this.namespace.path = 'admin';
this.isRootNamespace = false;
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).exists();
});
test('it should hide client count on enterprise in any other namespace when running a managed mode', async function (assert) {
this.permissions.exactPaths = {
'sys/internal/counters/activity': {
capabilities: ['read'],
},
'sys/replication/status': {
capabilities: ['read'],
},
};
this.version.type = 'enterprise';
this.flags.featureFlags = ['VAULT_CLOUD_ADMIN_NAMESPACE'];
this.namespace.path = 'groceries';
this.isRootNamespace = false;
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
});
test('it should hide cards on enterprise in root namespace but no permission', async function (assert) {
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();