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
79 lines (66 loc) • 1.57 kB
JSX
import React, {
Component,
PropTypes,
} from 'react';
import {
Slugify,
} from '../../services';
import {
GuidePage,
GuidePageSection,
} from '../';
export default class GuideExample extends Component {
constructor(props, sections) {
super(props);
this.sections = sections.map(section => Object.assign({}, section, {
slug: Slugify.one(section.title),
}));
}
componentWillMount() {
this.sections.forEach(section => {
this.context.registerCode(section);
});
}
componentWillUnmount() {
this.sections.forEach(section => {
this.context.unregisterCode(section);
});
}
renderSections() {
return this.sections.map((section, index) => (
<GuidePageSection
key={index}
title={section.title}
slug={section.slug}
html={section.html}
js={section.js}
hasDarkTheme={section.hasDarkTheme}
>
{section.description}
</GuidePageSection>
));
}
render() {
return (
<GuidePage
title={this.props.route.name}
>
{this.renderSections()}
</GuidePage>
);
}
}
GuideExample.contextTypes = {
registerCode: PropTypes.func,
unregisterCode: PropTypes.func,
};
GuideExample.propTypes = {
route: PropTypes.object.isRequired,
sections: PropTypes.arrayOf(React.PropTypes.shape({
title: React.PropTypes.string.isRequired,
description: React.PropTypes.any,
html: React.PropTypes.string.isRequired,
js: React.PropTypes.string,
hasDarkTheme: React.PropTypes.bool,
})),
};