UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

78 lines (63 loc) 1.45 kB
import {assign} from 'lodash'; import IndexedArray from 'ui/indexed_array'; export default class ManagementSection { /** * @param {string} id * @param {object} options * @param {number|null} options.order * @param {string|null} options.display - defaults to id * @param {string|null} options.url * @param {string|null} options.info * @returns {ManagementSection} */ constructor(id, options = {}) { this.display = id; this.id = id; this.items = new IndexedArray({ index: ['id'], order: ['order'] }); assign(this, options); } /** * Registers a sub-section * * @param {string} id * @param {object} options * @returns {ManagementSection} */ register(id, options = {}) { const item = new ManagementSection(id, assign(options, { parent: this })); if (this.hasItem(id)) { throw new Error(`'${id}' is already registered`); } this.items.push(item); return item; } /** * Deregisters a section * * @param {string} id */ deregister(id) { this.items.remove(item => item.id === id); } /** * Determine if an id is already registered * * @param {string} id * @returns {boolean} */ hasItem(id) { return this.items.byId.hasOwnProperty(id); } /** * Fetches a section by id * * @param {string} id * @returns {ManagementSection} */ getSection(id) { return this.items.byId[id]; } }