2022-09-17 10:30:21 +02:00
|
|
|
import DefaultErrorView from 'shared/components/error/view'
|
2022-01-28 16:57:07 +01:00
|
|
|
|
2022-10-06 22:59:37 +02:00
|
|
|
const Error = (props) => {
|
|
|
|
const errors = {
|
|
|
|
pattern: 0,
|
2022-10-08 07:23:58 -07:00
|
|
|
sets: 0,
|
2022-10-06 22:59:37 +02:00
|
|
|
}
|
|
|
|
const warnings = {
|
|
|
|
pattern: 0,
|
|
|
|
sets: 0,
|
|
|
|
}
|
|
|
|
if (props.patternLogs) {
|
|
|
|
errors.pattern += props.patternLogs.error.length
|
|
|
|
warnings.pattern += props.patternLogs.warning.length
|
|
|
|
}
|
|
|
|
if (props.setLogs) {
|
2022-10-08 07:23:58 -07:00
|
|
|
errors.sets += props.setLogs.error.length
|
|
|
|
warnings.sets += props.setLogs.warning.length
|
2022-09-17 10:30:21 +02:00
|
|
|
}
|
|
|
|
|
2022-10-06 22:59:37 +02:00
|
|
|
const logInfo = []
|
|
|
|
if (errors.pattern > 0)
|
|
|
|
logInfo.push(
|
|
|
|
<li>
|
|
|
|
There are <strong>{errors.pattern} errors</strong> in the pattern logs
|
|
|
|
</li>
|
|
|
|
)
|
2022-10-08 07:23:58 -07:00
|
|
|
if (errors.sets > 0)
|
2022-10-06 22:59:37 +02:00
|
|
|
logInfo.push(
|
2022-07-14 07:08:41 -05:00
|
|
|
<li>
|
2022-10-08 07:23:58 -07:00
|
|
|
There are <strong>{errors.sets} errors</strong> in the draft logs
|
2022-07-14 07:08:41 -05:00
|
|
|
</li>
|
2022-10-06 22:59:37 +02:00
|
|
|
)
|
|
|
|
if (warnings.pattern > 0)
|
|
|
|
logInfo.push(
|
|
|
|
<li>
|
|
|
|
There are <strong>{warnings.pattern} warnings</strong> in the pattern logs
|
|
|
|
</li>
|
|
|
|
)
|
2022-10-08 07:23:58 -07:00
|
|
|
if (warnings.sets > 0)
|
2022-10-06 22:59:37 +02:00
|
|
|
logInfo.push(
|
|
|
|
<li>
|
2022-10-08 07:23:58 -07:00
|
|
|
There are <strong>{warnings.sets} warnings</strong> in the draft logs
|
2022-10-06 22:59:37 +02:00
|
|
|
</li>
|
|
|
|
)
|
|
|
|
const ic = (
|
|
|
|
<ul className="list-disc list-inside ml-4 text-xl">
|
|
|
|
{logInfo}
|
|
|
|
{logInfo.length > 0 && (
|
|
|
|
<li>
|
|
|
|
<button className="btn-link" onClick={() => props.updateGist(['_state', 'view'], 'logs')}>
|
|
|
|
Check the logs for more details
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
)}
|
2022-07-14 07:08:41 -05:00
|
|
|
<li>Check the partially rendered pattern below to see which areas are problematic</li>
|
2022-09-17 10:30:21 +02:00
|
|
|
</ul>
|
|
|
|
)
|
2022-03-24 10:53:57 +01:00
|
|
|
|
2022-09-17 10:30:21 +02:00
|
|
|
return (
|
2022-10-06 22:59:37 +02:00
|
|
|
<DefaultErrorView inspectChildren={ic} {...props}>
|
2022-09-17 10:30:21 +02:00
|
|
|
<p>No need to be alarmed, but we ran into some trouble while drafting this pattern.</p>
|
|
|
|
</DefaultErrorView>
|
|
|
|
)
|
2022-02-08 20:49:19 +01:00
|
|
|
}
|
|
|
|
|
2022-01-28 16:57:07 +01:00
|
|
|
export default Error
|