UNPKG

@orfeas126/box-ui-elements

Version:
62 lines (60 loc) 1.49 kB
/** * * @file Content sub header component * @author Box */ import * as React from 'react'; import { injectIntl } from 'react-intl'; import messages from '../messages'; import { Breadcrumbs } from '../breadcrumbs'; import { VIEW_SEARCH, VIEW_FOLDER, VIEW_RECENTS, DELIMITER_CARET } from '../../../constants'; const SubHeaderLeft = ({ view, isSmall, rootId, rootName, currentCollection, onItemClick, intl }) => { let crumbs; if (view === VIEW_FOLDER || view === VIEW_SEARCH) { const { id, name = '', breadcrumbs = [] } = currentCollection; crumbs = breadcrumbs.concat({ id, name }); // Search results are specific to the current folder // hence the breadcrumb is added to the end of the list if (view === VIEW_SEARCH) { crumbs = crumbs.concat({ id: undefined, name: intl.formatMessage(messages.searchBreadcrumb) }); } } else { crumbs = [{ id: undefined, name: intl.formatMessage(messages[`${view}Breadcrumb`]) }]; if (view !== VIEW_RECENTS) { crumbs.unshift({ id: rootId, name: rootName || intl.formatMessage(messages.rootBreadcrumb) }); } } return /*#__PURE__*/React.createElement(Breadcrumbs, { crumbs: crumbs, delimiter: DELIMITER_CARET, isSmall: isSmall, onCrumbClick: onItemClick, rootId: rootId }); }; export default injectIntl(SubHeaderLeft); //# sourceMappingURL=SubHeaderLeft.js.map