breadcrumb ing
This commit is contained in:
parent
7017e8ca19
commit
9ec2746a57
|
@ -96,41 +96,34 @@ export class TitleBar extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
public handleBreadcrumb = (path: string) => {
|
||||
console.log(path);
|
||||
if(path === '/probe' || path === '/sensor' || path === '/target') {
|
||||
path = path + 's';
|
||||
}
|
||||
this.props.onRedirect(path);
|
||||
}
|
||||
|
||||
|
||||
// temporary
|
||||
public renderBreadcrumb(): JSX.Element[] {
|
||||
|
||||
let options = [
|
||||
{
|
||||
text: 'Probes',
|
||||
value: 'probes',
|
||||
},
|
||||
{
|
||||
text: 'Targets',
|
||||
value: 'targets',
|
||||
},
|
||||
{
|
||||
text: 'Sensors',
|
||||
value: 'sensors',
|
||||
},
|
||||
];
|
||||
|
||||
let elems: JSX.Element[] = new Array();
|
||||
let pathArr = this.props.location.split('/');
|
||||
let index: number = 0;
|
||||
|
||||
let path = '';
|
||||
for (let item of pathArr) {
|
||||
if (item !== '' && !item.match(/^\d+$/)) {
|
||||
let path = '/' + item;
|
||||
elems.push(
|
||||
<Breadcrumb.Section key={index++} onClick={this.handleBreadcrumb.bind(this, path)}>
|
||||
{this.capitalizeFirst(item)}
|
||||
{/* <Dropdown inline options={options} defaultValue={this.capitalizeFirst(item)}/> */}
|
||||
</Breadcrumb.Section>);
|
||||
elems.push(<Breadcrumb.Divider key={index++} />);
|
||||
if (item !== '') {
|
||||
path = path + '/' + item;
|
||||
if (pathArr[pathArr.length - 1] !== item) {
|
||||
elems.push(
|
||||
<Breadcrumb.Section key={index++} onClick={this.handleBreadcrumb.bind(this, path)}>
|
||||
{this.capitalizeFirst(item)}
|
||||
</Breadcrumb.Section>);
|
||||
elems.push(<Breadcrumb.Divider key={index++} icon='right angle' />);
|
||||
} else {
|
||||
elems.push(
|
||||
<Breadcrumb.Section key={index++}>
|
||||
{this.capitalizeFirst(item)}
|
||||
</Breadcrumb.Section>);
|
||||
}
|
||||
}
|
||||
}
|
||||
return elems;
|
||||
|
@ -144,7 +137,7 @@ export class TitleBar extends React.Component<Props, State> {
|
|||
<Header.Subheader>
|
||||
<Breadcrumb size='mini'>
|
||||
<Breadcrumb.Section onClick={this.handleBreadcrumb.bind(this, '/')}>Home</Breadcrumb.Section>
|
||||
<Breadcrumb.Divider />
|
||||
<Breadcrumb.Divider icon='right angle' />
|
||||
{this.renderBreadcrumb()}
|
||||
</Breadcrumb>
|
||||
</Header.Subheader>
|
||||
|
|
Loading…
Reference in New Issue
Block a user