@openshift-console/dynamic-plugin-sdk
Version:
Provides core APIs, types and utilities used by dynamic plugins at runtime.
26 lines (25 loc) • 1.37 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import PopoverStatus from './PopoverStatus';
import StatusIconAndText from './StatusIconAndText';
/**
* Component for a generic status popover
* @param {string} [title] - (optional) status text
* @param {boolean} [iconOnly] - (optional) if true, only displays icon
* @param {boolean} [noTooltip] - (optional) if true, tooltip won't be displayed
* @param {string} [className] - (optional) additional class name for the component
* @param {string} [popoverTitle] - (optional) title for popover
* @param {React.ComponentType} Icon - icon to be displayed
* @param {ReactNode} [children] - (optional) children for the component
* @example
* ```tsx
* <GenericStatus Icon={CircleIcon} />
* ```
*/
const GenericStatus = (props) => {
const { Icon, children, popoverTitle, title, noTooltip, iconOnly, ...restProps } = props;
const renderIcon = iconOnly && !noTooltip ? _jsx(Icon, { title: title }) : _jsx(Icon, {});
const statusBody = (_jsx(StatusIconAndText, { ...restProps, noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon }));
return React.Children.toArray(children).length ? (_jsx(PopoverStatus, { title: popoverTitle || title, ...restProps, statusBody: statusBody, children: children })) : (statusBody);
};
export default GenericStatus;