| Server IP : 170.10.161.225 / Your IP : 216.73.217.54 Web Server : Apache System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : calvet ( 273824) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : ON Directory : /home/www/calvetrealty.com/wp-content/plugins/code-snippets/js/Edit/components/ |
Upload File : |
import classnames from 'classnames'
import React, { MouseEventHandler, ReactNode, useEffect } from 'react'
import { __, sprintf } from '@wordpress/i18n'
import { useSnippetForm } from '../SnippetForm/context'
interface DismissibleNoticeProps {
classNames?: classnames.Argument
onRemove: MouseEventHandler<HTMLButtonElement>
children?: ReactNode
}
const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ classNames, onRemove, children }) => {
useEffect(() => {
if (window.CODE_SNIPPETS_EDIT?.scrollToNotices) {
window.scrollTo({ top: 0, behavior: 'smooth' })
}
}, [])
return (
<div id="message" className={classnames('notice fade is-dismissible', classNames)}>
<>{children}</>
<button type="button" className="notice-dismiss" onClick={event => {
event.preventDefault()
onRemove(event)
}}>
<span className="screen-reader-text">{__('Dismiss notice.', 'code-snippets')}</span>
</button>
</div>
)
}
export const Notices: React.FC = () => {
const { currentNotice, setCurrentNotice, snippet, setSnippet } = useSnippetForm()
return <>
{currentNotice ?
<DismissibleNotice classNames={currentNotice[0]} onRemove={() => setCurrentNotice(undefined)}>
<p>{currentNotice[1]}</p>
</DismissibleNotice> :
null}
{snippet.code_error ?
<DismissibleNotice
classNames="error"
onRemove={() => setSnippet(previous => ({ ...previous, code_error: null }))}
>
<p>
<strong>{sprintf(
// translators: %d: line number.
__('Snippet automatically deactivated due to an error on line %d:', 'code-snippets'),
snippet.code_error[1]
)}</strong>
<blockquote>{snippet.code_error[0]}</blockquote>
</p>
</DismissibleNotice> :
null}
</>
}