Skip to content

Commit

Permalink
Merge pull request elastic#7586 from ycombinator/management/add-dereg…
Browse files Browse the repository at this point in the history
…ister-method

Adding method to deregister a (child) section
  • Loading branch information
ycombinator authored Jun 29, 2016
2 parents a97184d + 01cf4c5 commit ce9efff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/ui/public/management/__tests__/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ describe('ManagementSection', () => {
});
});

describe('deregister', () => {
let section;

beforeEach(() => {
section = new ManagementSection('kibana');
section.register('about');
});

it ('deregisters an existing section', () => {
section.deregister('about');
expect(section.items).to.have.length(0);
});

it ('allows deregistering a section more than once', () => {
section.deregister('about');
section.deregister('about');
expect(section.items).to.have.length(0);
});

});

describe('getSection', () => {
let section;

Expand Down
9 changes: 9 additions & 0 deletions src/ui/public/management/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export default class ManagementSection {
return item;
}

/**
* Deregisters a section
*
* @param {string} id
*/
deregister(id) {
this.items.remove(item => item.id === id);
}

/**
* Determine if an id is already registered
*
Expand Down

0 comments on commit ce9efff

Please sign in to comment.