diff --git a/src/ui/public/management/__tests__/section.js b/src/ui/public/management/__tests__/section.js index 97f08491aed69..b41a2e494a652 100644 --- a/src/ui/public/management/__tests__/section.js +++ b/src/ui/public/management/__tests__/section.js @@ -94,6 +94,16 @@ describe('ManagementSection', () => { it('returns undefined if un-registered', () => { expect(section.getSection('unknown')).to.be(undefined); }); + + it('returns sub-sections specified via a /-separated path', () => { + section.getSection('about').register('time'); + expect(section.getSection('about/time')).to.be.a(ManagementSection); + expect(section.getSection('about/time')).to.be(section.getSection('about').getSection('time')); + }); + + it('returns undefined if a sub-section along a /-separated path does not exist', () => { + expect(section.getSection('about/damn/time')).to.be(undefined); + }); }); describe('items', () => { diff --git a/src/ui/public/management/section.js b/src/ui/public/management/section.js index 1a318939c2dcb..fccfc5f24dbd9 100644 --- a/src/ui/public/management/section.js +++ b/src/ui/public/management/section.js @@ -72,6 +72,17 @@ export default class ManagementSection { */ getSection(id) { - return this.items.byId[id]; + if (!id) { + return; + } + + const sectionPath = id.split('/'); + return sectionPath.reduce((currentSection, nextSection) => { + if (!currentSection) { + return; + } + + return currentSection.items.byId[nextSection]; + }, this); } }