PluginProbe
Code Snippets / 3.10.2
Code Snippets v3.10.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / ImportMenu / MigrateForm / ImporterSelector.tsx

ImporterSelector.tsx in Code Snippets 3.10.2, at js/components/ImportMenu/MigrateForm/ImporterSelector.tsx

49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useId } from 'react'
2 import { __, sprintf } from '@wordpress/i18n'
3 import { ImportCard } from '../common/ImportCard'
4 import type { Importer } from './WithMigrationData'
5
6 export interface ImporterSelectorProps {
7 value: string
8 onChange: (newValue: string) => void
9 isLoading: boolean
10 options: Importer[]
11 }
12
13 export const ImporterSelector: React.FC<ImporterSelectorProps> = ({ value, onChange, options, isLoading }) => {
14 const importerId = useId()
15
16 return (
17 <ImportCard variant="controls" className="importer-selector-card">
18 <h2 id="importer-select-heading">{__('Select plugin', 'code-snippets')}</h2>
19 <label htmlFor={importerId} className="screen-reader-text">
20 {__('Select plugin to migrate from', 'code-snippets')}
21 </label>
22
23 <select
24 aria-labelledby="importer-select-heading"
25 id={importerId}
26 value={value}
27 onChange={event => onChange(event.target.value)}
28 className="regular-text"
29 disabled={isLoading}
30 >
31 <option value="">{__('-- Select an importer --', 'code-snippets')}</option>
32 {options.map(importer =>
33 <option
34 key={importer.name}
35 value={importer.name}
36 disabled={!importer.is_active}
37 >
38 {importer.is_active
39 ? importer.title
40 // translators: %s: importer title.
41 : sprintf(__('%s (Inactive)', 'code-snippets'), importer.title)}
42 </option>)}
43 </select>
44
45 {isLoading && <p role="status" aria-live="polite">{__('Loading snippets…', 'code-snippets')}</p>}
46 </ImportCard>
47 )
48 }
49