| 1 |
import { createInterpolateElement } from '@wordpress/element' |
| 2 |
import React from 'react' |
| 3 |
import { __, sprintf } from '@wordpress/i18n' |
| 4 |
import { useSnippetForm } from '../../../hooks/useSnippetForm' |
| 5 |
import { DismissibleNotice } from '../../common/DismissableNotice' |
| 6 |
|
| 7 |
export const Notices: React.FC = () => { |
| 8 |
const { currentNotice, setCurrentNotice, snippet, setSnippet } = useSnippetForm() |
| 9 |
|
| 10 |
return <> |
| 11 |
{currentNotice |
| 12 |
? <DismissibleNotice className={currentNotice[0]} onDismiss={() => setCurrentNotice(undefined)}> |
| 13 |
<p>{createInterpolateElement(currentNotice[1], { strong: <strong /> })}</p> |
| 14 |
</DismissibleNotice> |
| 15 |
: null} |
| 16 |
|
| 17 |
{snippet.code_error |
| 18 |
? <DismissibleNotice |
| 19 |
className="notice-error" |
| 20 |
onDismiss={() => setSnippet(previous => ({ ...previous, code_error: null }))} |
| 21 |
> |
| 22 |
<p> |
| 23 |
<strong>{sprintf( |
| 24 |
// translators: %d: line number. |
| 25 |
__('Snippet automatically deactivated due to an error on line %d:', 'code-snippets'), |
| 26 |
snippet.code_error[1] |
| 27 |
)}</strong> |
| 28 |
|
| 29 |
<blockquote>{snippet.code_error[0]}</blockquote> |
| 30 |
</p> |
| 31 |
</DismissibleNotice> |
| 32 |
: null} |
| 33 |
</> |
| 34 |
} |
| 35 |
|