import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { List, MenuItem, Icon, ListItem, ListItemText, ListItemAvatar, Button, Avatar, Typography, } from '@mui/material'; import { Apps } from '@mui/icons-material'; import styles from './common.module.scss'; import { ConditionallyRender } from './ConditionallyRender/ConditionallyRender'; export { styles }; export const AppsLinkList = ({ apps }) => ( 0} show={apps.map(({ appName, description, icon }) => ( {icon}} elseShow={} /> {appName} } secondary={description || 'No description'} /> ))} /> ); AppsLinkList.propTypes = { apps: PropTypes.array.isRequired, }; export const DataTableHeader = ({ title, actions }) => (
{title}
{actions &&
{actions}
}
); DataTableHeader.propTypes = { title: PropTypes.string, actions: PropTypes.any, }; export const FormButtons = ({ submitText = 'Create', onCancel, primaryButtonTestId, }) => (
 
); FormButtons.propTypes = { submitText: PropTypes.string, onCancel: PropTypes.func.isRequired, primaryButtonTestId: PropTypes.string, }; export const IconLink = ({ url, icon: IconComponent }) => ( ); IconLink.propTypes = { url: PropTypes.string, icon: PropTypes.object, }; export const MenuItemWithIcon = React.forwardRef( ({ icon: IconComponent, label, disabled, ...menuItemProps }, ref) => ( {label} ) ); MenuItemWithIcon.propTypes = { icon: PropTypes.object, label: PropTypes.string, disabled: PropTypes.bool, }; const badNumbers = [NaN, Infinity, -Infinity]; export function calc(value, total, decimal) { if ( typeof value !== 'number' || typeof total !== 'number' || typeof decimal !== 'number' ) { return null; } if (total === 0) { return 0; } badNumbers.forEach(number => { if ([value, total, decimal].indexOf(number) > -1) { return number; } }); return ((value / total) * 100).toFixed(decimal); } export const selectStyles = { control: provided => ({ ...provided, border: '1px solid #607d8b', boxShadow: '0', ':hover': { borderColor: '#607d8b', boxShadow: '0 0 0 1px #607d8b', }, }), };