diff --git a/changelog/21562.txt b/changelog/21562.txt new file mode 100644 index 000000000..c41d727da --- /dev/null +++ b/changelog/21562.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes issue with certain navigational links incorrectly displaying in child namespaces +``` \ No newline at end of file diff --git a/ui/app/components/sidebar/nav/cluster.hbs b/ui/app/components/sidebar/nav/cluster.hbs index 5ec3a5e34..8c5d23e3d 100644 --- a/ui/app/components/sidebar/nav/cluster.hbs +++ b/ui/app/components/sidebar/nav/cluster.hbs @@ -37,7 +37,12 @@ {{/if}} {{#if - (and this.version.isEnterprise this.cluster.anyReplicationEnabled (has-permission "status" routeParams="replication")) + (and + this.version.isEnterprise + this.namespace.inRootNamespace + this.cluster.anyReplicationEnabled + (has-permission "status" routeParams="replication") + ) }} Replication Monitoring {{/if}} - {{#if (and this.version.isEnterprise (has-permission "status" routeParams="replication"))}} + {{#if (and this.version.isEnterprise this.namespace.inRootNamespace (has-permission "status" routeParams="replication"))}} {{/if}} - {{#if (and this.cluster.usingRaft (has-permission "status" routeParams="raft"))}} + {{#if (and this.cluster.usingRaft this.namespace.inRootNamespace (has-permission "status" routeParams="raft"))}} {{/if}} - {{#if (and this.version.features (has-permission "status" routeParams="license") (not this.cluster.dr.isSecondary))}} + {{#if + (and + this.version.features + this.namespace.inRootNamespace + (has-permission "status" routeParams="license") + (not this.cluster.dr.isSecondary) + ) + }} {{/if}} - {{#if (and (has-permission "status" routeParams="seal") (not this.cluster.dr.isSecondary))}} + {{#if (and this.namespace.inRootNamespace (has-permission "status" routeParams="seal") (not this.cluster.dr.isSecondary))}} { const permissions = owner.lookup('service:permissions'); - sinon.stub(permissions, 'hasNavPermission').returns(true); + const hasNavPermission = sinon.stub(permissions, 'hasNavPermission'); + hasNavPermission.returns(true); sinon.stub(permissions, 'navPathParams'); const version = owner.lookup('service:version'); - sinon.stub(version, 'features').value(allFeatures()); + const features = sinon.stub(version, 'features'); + features.value(allFeatures()); sinon.stub(version, 'isEnterprise').value(isEnterprise); const auth = owner.lookup('service:auth'); @@ -20,4 +22,6 @@ export const stubFeaturesAndPermissions = (owner, isEnterprise = false, setClust usingRaft: true, }); } + + return { hasNavPermission, features }; }; diff --git a/ui/tests/integration/components/sidebar/nav/cluster-test.js b/ui/tests/integration/components/sidebar/nav/cluster-test.js index 740b395b2..05a8d43c7 100644 --- a/ui/tests/integration/components/sidebar/nav/cluster-test.js +++ b/ui/tests/integration/components/sidebar/nav/cluster-test.js @@ -64,4 +64,32 @@ module('Integration | Component | sidebar-nav-cluster', function (hooks) { assert.dom(`[data-test-sidebar-nav-link="${link}"]`).hasText(link, `${link} link renders`); }); }); + + test('it should hide enterprise related links in child namespace', async function (assert) { + const links = [ + 'Disaster Recovery', + 'Performance', + 'Replication', + 'Raft Storage', + 'License', + 'Seal Vault', + ]; + this.owner.lookup('service:namespace').set('path', 'foo'); + const stubs = stubFeaturesAndPermissions(this.owner, true, true); + stubs.hasNavPermission.callsFake((route) => route !== 'clients'); + + await renderComponent(); + + assert + .dom('[data-test-sidebar-nav-heading="Monitoring"]') + .doesNotExist( + 'Monitoring heading is hidden in child namespace when user does not have access to Client Count' + ); + + links.forEach((link) => { + assert + .dom(`[data-test-sidebar-nav-link="${link}"]`) + .doesNotExist(`${link} is hidden in child namespace`); + }); + }); });