Revision b51f2297
Added by Amir Fefer almost 6 years ago
webpack/assets/javascripts/react_app/components/BreadcrumbBar/components/BreadcrumbSwitcherPopover.js | ||
---|---|---|
import { Popover, ListGroup, ListGroupItem, Pager, Icon } from 'patternfly-react';
|
||
import EllipsisWithTooltip from 'react-ellipsis-with-tooltip';
|
||
import SearchInput from '../../common/SearchInput';
|
||
import { noop } from '../../../common/helpers';
|
||
import SubstringWrapper from '../../common/SubstringWrapper';
|
||
import { noop } from '../../../common/helpers';
|
||
import './BreadcrumbSwitcherPopover.scss';
|
||
|
||
const BreadcrumbSwitcherPopover = ({
|
||
resources,
|
||
onResourceClick,
|
||
onNextPageClick,
|
||
onPrevPageClick,
|
||
loading,
|
||
... | ... | |
onSearchClear,
|
||
searchValue,
|
||
searchDebounceTimeout,
|
||
onResourceClick,
|
||
...props
|
||
}) => {
|
||
let popoverBody;
|
||
... | ... | |
</div>
|
||
);
|
||
} else {
|
||
const handleItemClick = (item) => {
|
||
onResourceClick(item);
|
||
if (item.onClick) item.onClick();
|
||
};
|
||
|
||
const createItemProps = (item) => {
|
||
const { id, url, name } = item;
|
||
const key = `${id}-${name}`;
|
||
... | ... | |
return { ...itemProps, disabled: true };
|
||
}
|
||
|
||
return { ...itemProps, onClick: () => handleItemClick(item), href: url };
|
||
return { ...itemProps, onClick: e => onResourceClick(e, url), href: url };
|
||
};
|
||
|
||
popoverBody = (
|
||
... | ... | |
hasError: PropTypes.bool,
|
||
currentPage: PropTypes.number,
|
||
totalPages: PropTypes.number,
|
||
onResourceClick: PropTypes.func,
|
||
resources: PropTypes.arrayOf(PropTypes.shape({
|
||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||
name: PropTypes.string.isRequired,
|
||
... | ... | |
})),
|
||
onSearchChange: PropTypes.func,
|
||
searchValue: PropTypes.string,
|
||
onResourceClick: PropTypes.func,
|
||
};
|
||
|
||
BreadcrumbSwitcherPopover.defaultProps = {
|
||
... | ... | |
hasError: false,
|
||
currentPage: 1,
|
||
totalPages: 1,
|
||
onResourceClick: noop,
|
||
resources: [],
|
||
onResourceClick: noop,
|
||
};
|
||
|
||
export default BreadcrumbSwitcherPopover;
|
Also available in: Unified diff
Fixes #23977 - add onClick callback to breadcrumbs