Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/29241.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
UI: Fix missing Client Count card when running as a Vault Dedicated cluster
```
9 changes: 5 additions & 4 deletions ui/app/components/dashboard/overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -33,7 +35,6 @@
<Dashboard::SurveyLinkText />
</div>
</div>

{{else}}
<div class="is-flex-column is-flex-1 gap-24">
<Dashboard::SecretsEnginesCard @secretsEngines={{@secretsEngines}} />
Expand Down
46 changes: 46 additions & 0 deletions ui/app/components/dashboard/overview.ts
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are HVD clusters enterprise? I always forget this, but think I remember learning that they are? Just wanted to double check 😄

if (!version.isEnterprise) return false;

// HVD clusters
if (flags.isHvdManaged && namespace.currentNamespace === 'admin') return true;

// SM clusters
if (isRootNamespace) return true;

return false;
}
}
44 changes: 43 additions & 1 deletion ui/tests/integration/components/dashboard/overview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
Loading