breadcrumb ing

This commit is contained in:
insanity 2017-08-30 16:05:06 +09:00
parent 7017e8ca19
commit 9ec2746a57

View File

@ -96,41 +96,34 @@ export class TitleBar extends React.Component<Props, State> {
} }
public handleBreadcrumb = (path: string) => { public handleBreadcrumb = (path: string) => {
console.log(path); if(path === '/probe' || path === '/sensor' || path === '/target') {
path = path + 's';
}
this.props.onRedirect(path); this.props.onRedirect(path);
} }
// temporary // temporary
public renderBreadcrumb(): JSX.Element[] { 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 elems: JSX.Element[] = new Array();
let pathArr = this.props.location.split('/'); let pathArr = this.props.location.split('/');
let index: number = 0; let index: number = 0;
let path = '';
for (let item of pathArr) { for (let item of pathArr) {
if (item !== '' && !item.match(/^\d+$/)) { if (item !== '') {
let path = '/' + item; path = path + '/' + item;
elems.push( if (pathArr[pathArr.length - 1] !== item) {
<Breadcrumb.Section key={index++} onClick={this.handleBreadcrumb.bind(this, path)}> elems.push(
{this.capitalizeFirst(item)} <Breadcrumb.Section key={index++} onClick={this.handleBreadcrumb.bind(this, path)}>
{/* <Dropdown inline options={options} defaultValue={this.capitalizeFirst(item)}/> */} {this.capitalizeFirst(item)}
</Breadcrumb.Section>); </Breadcrumb.Section>);
elems.push(<Breadcrumb.Divider key={index++} />); elems.push(<Breadcrumb.Divider key={index++} icon='right angle' />);
} else {
elems.push(
<Breadcrumb.Section key={index++}>
{this.capitalizeFirst(item)}
</Breadcrumb.Section>);
}
} }
} }
return elems; return elems;
@ -144,7 +137,7 @@ export class TitleBar extends React.Component<Props, State> {
<Header.Subheader> <Header.Subheader>
<Breadcrumb size='mini'> <Breadcrumb size='mini'>
<Breadcrumb.Section onClick={this.handleBreadcrumb.bind(this, '/')}>Home</Breadcrumb.Section> <Breadcrumb.Section onClick={this.handleBreadcrumb.bind(this, '/')}>Home</Breadcrumb.Section>
<Breadcrumb.Divider /> <Breadcrumb.Divider icon='right angle' />
{this.renderBreadcrumb()} {this.renderBreadcrumb()}
</Breadcrumb> </Breadcrumb>
</Header.Subheader> </Header.Subheader>