temporary breadcrumb

This commit is contained in:
insanity 2017-07-25 14:59:19 +09:00
parent 687034778e
commit 81049e375f

View File

@ -52,18 +52,22 @@ export class TitleBar extends React.Component<Props, State> {
return this.capitalizeFirst(pathArr[1]);
}
public handleBreadcrumb = (path: string) => {
console.log(path);
this.props.onRedirect(path);
}
// temporary
public renderBreadcrumb(): JSX.Element[] {
let elems: JSX.Element[] = new Array();
let pathArr = this.props.location.split('/');
if (pathArr[1].indexOf('probe') > -1 || pathArr[1].indexOf('sensor') > -1) {
elems.push(<Breadcrumb.Section link>Monitoring</Breadcrumb.Section>);
elems.push(<Breadcrumb.Divider />);
elems.push(<Breadcrumb.Section link active>{this.capitalizeFirst(pathArr[1])}</Breadcrumb.Section>);
}else if (pathArr[1].indexOf('target') > -1) {
elems.push(<Breadcrumb.Section link>Infrastructure</Breadcrumb.Section>);
elems.push(<Breadcrumb.Divider />);
elems.push(<Breadcrumb.Section link active>{this.capitalizeFirst(pathArr[1])}</Breadcrumb.Section>);
for (let item of pathArr) {
if (item !== '' && !item.match(/^\d+$/)) {
let path = '/' + item;
elems.push(<Breadcrumb.Section onClick={this.handleBreadcrumb.bind(this, path)}>{this.capitalizeFirst(item)}</Breadcrumb.Section>);
elems.push(<Breadcrumb.Divider />);
}
}
return elems;
}
@ -75,7 +79,7 @@ export class TitleBar extends React.Component<Props, State> {
<Header as='h3'>{this.showTitle()}
<Header.Subheader>
<Breadcrumb size='mini'>
<Breadcrumb.Section link>Home</Breadcrumb.Section>
<Breadcrumb.Section onClick={this.handleBreadcrumb.bind(this, '/')}>Home</Breadcrumb.Section>
<Breadcrumb.Divider />
{this.renderBreadcrumb()}
</Breadcrumb>