mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
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:
3
changelog/29241.txt
Normal file
3
changelog/29241.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
UI: Fix missing Client Count card when running as a Vault Dedicated cluster
|
||||||
|
```
|
||||||
@@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
<div class="has-bottom-margin-xl">
|
<div class="has-bottom-margin-xl">
|
||||||
<div class="is-flex-row gap-24">
|
<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">
|
<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 />
|
<Dashboard::ClientCountCard />
|
||||||
{{/if}}
|
{{/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
|
<Dashboard::ReplicationCard
|
||||||
@replication={{@replication}}
|
@replication={{@replication}}
|
||||||
@version={{@version}}
|
@version={{@version}}
|
||||||
@@ -33,7 +35,6 @@
|
|||||||
<Dashboard::SurveyLinkText />
|
<Dashboard::SurveyLinkText />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="is-flex-column is-flex-1 gap-24">
|
<div class="is-flex-column is-flex-1 gap-24">
|
||||||
<Dashboard::SecretsEnginesCard @secretsEngines={{@secretsEngines}} />
|
<Dashboard::SecretsEnginesCard @secretsEngines={{@secretsEngines}} />
|
||||||
|
|||||||
46
ui/app/components/dashboard/overview.ts
Normal file
46
ui/app/components/dashboard/overview.ts
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,8 +15,10 @@ module('Integration | Component | dashboard/overview', function (hooks) {
|
|||||||
setupMirage(hooks);
|
setupMirage(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
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.permissions = this.owner.lookup('service:permissions');
|
||||||
|
this.store = this.owner.lookup('service:store');
|
||||||
this.version = this.owner.lookup('service:version');
|
this.version = this.owner.lookup('service:version');
|
||||||
this.version.version = '1.13.1+ent';
|
this.version.version = '1.13.1+ent';
|
||||||
this.version.type = 'enterprise';
|
this.version.type = 'enterprise';
|
||||||
@@ -151,6 +153,46 @@ module('Integration | Component | dashboard/overview', function (hooks) {
|
|||||||
assert.dom(DASHBOARD.cardName('replication')).exists();
|
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) {
|
test('it should hide cards on enterprise in root namespace but no permission', async function (assert) {
|
||||||
await this.renderComponent();
|
await this.renderComponent();
|
||||||
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
|
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
|
||||||
|
|||||||
Reference in New Issue
Block a user