diff --git a/npm/ng-packs/packages/core/src/lib/services/routes.service.ts b/npm/ng-packs/packages/core/src/lib/services/routes.service.ts index 1548e09b79..dfd453fe04 100644 --- a/npm/ng-packs/packages/core/src/lib/services/routes.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/routes.service.ts @@ -144,6 +144,11 @@ export abstract class AbstractNavTreeService extends Abstract return this.store.selectSnapshot(ConfigState.getGrantedPolicy(requiredPolicy)); } + hasInvisibleChild(identifier: string): boolean { + const node = this.find(item => item[this.id] === identifier); + return node?.children?.some(child => child.invisible); + } + /* istanbul ignore next */ ngOnDestroy() {} } diff --git a/npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts index ffb5c8b2f0..93214442ea 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/routes.service.spec.ts @@ -68,6 +68,16 @@ describe('Routes Service', () => { }); }); + describe('#hasInvisibleChild', () => { + it('should return if node has invisible child', () => { + service.add(routes); + + expect(service.hasInvisibleChild('foo')).toBe(true); + expect(service.hasInvisibleChild('bar')).toBe(false); + expect(service.hasInvisibleChild('baz')).toBe(false); + }); + }); + describe('#remove', () => { it('should remove routes based on given routeNames', () => { service.add(routes);