-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathInfraError.tsx
43 lines (37 loc) · 1.38 KB
/
InfraError.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React, { type PropsWithChildren } from 'react';
import cx from 'classnames';
import type { InfraError } from 'common/api/osrdEditoastApi';
import InfraErrorDescription from './InfraErrorDescription';
import InfraErrorIcon from './InfraErrorIcon';
import InfraErrorTypeLabel from './InfraErrorTypeLabel';
type InfraErrorBoxProps = PropsWithChildren<{ error: InfraError; index?: number }>;
/**
* A component that display an infra error.
* If index is provided, we display it with `#` on the left
*/
export const InfraErrorBox = ({ error, index, children }: InfraErrorBoxProps) => (
<div className="management-item-content">
<div className="management-item-symbol">
<InfraErrorIcon error={error} />
{index !== undefined && <span className="mt-2 text-muted">#{index}</span>}
</div>
<div className="management-item-main flex-grow-1">
<h5 className="font-weight-bold">
<InfraErrorTypeLabel error={error} />
</h5>
<p>
<InfraErrorDescription error={error} />
</p>
</div>
{children && <div>{children}</div>}
</div>
);
export const InfraErrorLine = ({ error }: { error: InfraError }) => (
<div>
<span className={cx('font-weight-bold', error.is_warning ? 'text-warning' : 'text-danger')}>
<InfraErrorTypeLabel error={error} />
:
</span>
<InfraErrorDescription error={error} />
</div>
);