| 1 |
import React from 'react' |
| 2 |
import { __ } from '@wordpress/i18n' |
| 3 |
import { getSnippetType } from '../../../utils/snippets' |
| 4 |
import { useSnippetForm } from '../../../hooks/useSnippetForm' |
| 5 |
|
| 6 |
export const PriorityInput: React.FC = () => { |
| 7 |
const { snippet, setSnippet, isReadOnly } = useSnippetForm() |
| 8 |
|
| 9 |
return 'html' === getSnippetType(snippet) ? null : |
| 10 |
<p |
| 11 |
className="snippet-priority" |
| 12 |
title={__('Snippets with a lower priority number will run before those with a higher number.', 'code-snippets')} |
| 13 |
> |
| 14 |
<label htmlFor="snippet_priority">{`${__('Priority', 'code-snippets')} `}</label> |
| 15 |
<input |
| 16 |
type="number" |
| 17 |
id="snippet_priority" |
| 18 |
name="snippet_priority" |
| 19 |
value={snippet.priority} |
| 20 |
disabled={isReadOnly} |
| 21 |
onChange={event => setSnippet(previous => ({ |
| 22 |
...previous, |
| 23 |
priority: parseInt(event.target.value, 10) |
| 24 |
}))} |
| 25 |
/> |
| 26 |
</p> |
| 27 |
} |
| 28 |
|