diff --git a/src/lib/viewers/archive/ArchiveExplorer.js b/src/lib/viewers/archive/ArchiveExplorer.js index f80065b5e..292bbf991 100644 --- a/src/lib/viewers/archive/ArchiveExplorer.js +++ b/src/lib/viewers/archive/ArchiveExplorer.js @@ -138,7 +138,7 @@ class ArchiveExplorer extends React.Component { return ( -
+
} path items including name and path string */ getPathItems = fullPath => { - const { view } = this.props; - - if (view === VIEWS.VIEW_SEARCH) { - return [ - { - name: __('search_results'), - }, - ]; - } - const pathNames = fullPath.split('/').slice(0, -1); + // join path names from root to current index to get absolute path + const getAbsolutePath = index => pathNames.slice(0, index + 1).join('/'); return pathNames.map((name, index) => ({ name, - path: `${pathNames.slice(0, index + 1).join('/')}/`, + path: `${getAbsolutePath(index)}/`, })); }; @@ -44,19 +36,18 @@ class Breadcrumbs extends React.PureComponent { */ render() { const { fullPath, onClick, view } = this.props; - const pathItems = this.getPathItems(fullPath); return (
- {pathItems.map(pathItem => - view === VIEWS.VIEW_SEARCH ? ( - {pathItem.name} - ) : ( + {view === VIEWS.VIEW_SEARCH ? ( + {__('search_results')} + ) : ( + this.getPathItems(fullPath).map(pathItem => ( onClick(pathItem.path)} type="button"> {pathItem.name} - ), + )) )}
diff --git a/src/lib/viewers/archive/__tests__/ArchiveExplorer-test-react.js b/src/lib/viewers/archive/__tests__/ArchiveExplorer-test-react.js index 347d46af6..2ba5a019e 100644 --- a/src/lib/viewers/archive/__tests__/ArchiveExplorer-test-react.js +++ b/src/lib/viewers/archive/__tests__/ArchiveExplorer-test-react.js @@ -71,7 +71,7 @@ describe('lib/viewers/archive/ArchiveExplorer', () => { it('should render correct components', () => { const component = shallow(); - expect(component.find('.bp-archive-explorer').length).to.equal(1); + expect(component.find('.bp-ArchiveExplorer').length).to.equal(1); expect(component.find('Breadcrumbs').length).to.equal(1); expect(component.find('Internationalize').length).to.equal(1); expect(component.find('InjectIntl(VirtualizedTable)').length).to.equal(1); diff --git a/src/lib/viewers/archive/__tests__/Breadcrumbs-test-react.js b/src/lib/viewers/archive/__tests__/Breadcrumbs-test-react.js index 45b489bf2..915f164aa 100644 --- a/src/lib/viewers/archive/__tests__/Breadcrumbs-test-react.js +++ b/src/lib/viewers/archive/__tests__/Breadcrumbs-test-react.js @@ -28,6 +28,12 @@ describe('lib/viewers/archive/Breadcrumbs', () => { expect(component.find('InjectIntl(Breadcrumb)').length).to.equal(1); expect(component.find('PlainButton').length).to.equal(2); }); + + it('should render search result if view is search', () => { + const component = shallow(); + + expect(component.find('span').text()).to.equal(__('search_results')); + }); }); describe('getPathItems()', () => { @@ -47,16 +53,5 @@ describe('lib/viewers/archive/Breadcrumbs', () => { }, ]); }); - - it('should return search results if view is search', () => { - const component = shallow(); - const pathItems = component.instance().getPathItems(fullPath); - - expect(pathItems).to.eql([ - { - name: __('search_results'), - }, - ]); - }); }); });