2023-12-04 17:40:23 +08:00
|
|
|
import {OverlayTrigger} from "react-bootstrap";
|
|
|
|
import React from "react";
|
2023-12-05 17:35:31 +08:00
|
|
|
import {MaxLevel} from "./warnings";
|
2023-12-04 17:40:23 +08:00
|
|
|
|
|
|
|
|
2023-12-06 16:27:43 +08:00
|
|
|
export function CardWarnings({warnings, prefix}) {
|
2023-12-05 17:35:31 +08:00
|
|
|
const max_level = MaxLevel(warnings);
|
2023-12-04 17:40:23 +08:00
|
|
|
return (
|
|
|
|
<OverlayTrigger
|
|
|
|
placement="bottom"
|
|
|
|
trigger={['click', 'hover', 'focus']}
|
|
|
|
overlay={
|
|
|
|
({arrowProps, hasDoneInitialMeasure, show, ...props}) => (
|
|
|
|
<div className="k-popup-warning" {...props}>
|
2023-12-05 17:35:31 +08:00
|
|
|
{warnings.map((warning, _i) => {
|
|
|
|
return (
|
2023-12-06 16:27:43 +08:00
|
|
|
<p className="rule warning" key={`warnmsg_${prefix}_${warning.name}`}>
|
2023-12-05 17:35:31 +08:00
|
|
|
<i>{warning.message}</i>
|
|
|
|
</p>
|
|
|
|
)
|
|
|
|
})}
|
2023-12-04 17:40:23 +08:00
|
|
|
</div>)
|
|
|
|
}
|
|
|
|
rootClose
|
|
|
|
>
|
2023-12-05 17:35:31 +08:00
|
|
|
<img className="alert-warning" src={max_level.icon}/>
|
2023-12-04 17:40:23 +08:00
|
|
|
</OverlayTrigger>
|
|
|
|
)
|
2023-12-06 16:27:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function WarningIndicator({warnings}) {
|
|
|
|
const max_level = MaxLevel(warnings);
|
|
|
|
return (
|
|
|
|
<img
|
|
|
|
className="alert-warning align-self-start"
|
|
|
|
src={max_level.icon}
|
|
|
|
/>
|
|
|
|
)
|
2023-12-04 17:40:23 +08:00
|
|
|
}
|