github.com/aminovpavel/nomad@v0.11.8/ui/app/components/fs/breadcrumbs.js (about) 1 import Component from '@ember/component'; 2 import { computed } from '@ember/object'; 3 import { isEmpty } from '@ember/utils'; 4 5 export default Component.extend({ 6 tagName: 'nav', 7 classNames: ['breadcrumb'], 8 9 'data-test-fs-breadcrumbs': true, 10 11 allocation: null, 12 task: null, 13 path: null, 14 15 breadcrumbs: computed('path', function() { 16 const breadcrumbs = this.path 17 .split('/') 18 .reject(isEmpty) 19 .reduce((breadcrumbs, pathSegment, index) => { 20 let breadcrumbPath; 21 22 if (index > 0) { 23 const lastBreadcrumb = breadcrumbs[index - 1]; 24 breadcrumbPath = `${lastBreadcrumb.path}/${pathSegment}`; 25 } else { 26 breadcrumbPath = pathSegment; 27 } 28 29 breadcrumbs.push({ 30 name: pathSegment, 31 path: breadcrumbPath, 32 }); 33 34 return breadcrumbs; 35 }, []); 36 37 if (breadcrumbs.length) { 38 breadcrumbs[breadcrumbs.length - 1].isLast = true; 39 } 40 41 return breadcrumbs; 42 }), 43 });