PluginProbe
ElasticPress / 4.2.1
ElasticPress v4.2.1
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / assets / js / synonyms / components / editors / SolrEditor.js

SolrEditor.js in ElasticPress 4.2.1, at assets/js/synonyms/components/editors/SolrEditor.js

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies.
3 */
4 import { useContext, WPElement } from '@wordpress/element';
5
6 /**
7 * Internal dependencies.
8 */
9 import { State, Dispatch } from '../../context';
10
11 /**
12 * Synonym Inspector
13 *
14 * @returns {WPElement} SolrEditor Component
15 */
16 const SolrEditor = () => {
17 const state = useContext(State);
18 const dispatch = useContext(Dispatch);
19 const { alternatives, isSolrEditable, isSolrVisible, sets, solr } = state;
20 const {
21 synonymsTextareaInputName,
22 solrInputHeading,
23 solrAlternativesErrorMessage,
24 solrSetsErrorMessage,
25 } = window.epSynonyms.i18n;
26
27 return (
28 <div className={`synonym-solr-editor metabox-holder ${!isSolrVisible ? 'hidden' : ''}`}>
29 <div className="postbox">
30 <h2 className="hndle">
31 <span>{solrInputHeading}</span>
32 </h2>
33 <div className="inside">
34 <textarea
35 className="large-text"
36 id="ep-synonym-input"
37 name={synonymsTextareaInputName}
38 rows="20"
39 value={solr}
40 readOnly={!isSolrEditable}
41 onChange={(event) =>
42 dispatch({ type: 'UPDATE_SOLR', data: event.target.value })
43 }
44 />
45 <div
46 role="region"
47 aria-live="assertive"
48 className="synonym-solr-editor__validation"
49 >
50 {alternatives.some((alternative) => !alternative.valid) && (
51 <p>{solrAlternativesErrorMessage}</p>
52 )}
53 {sets.some((set) => !set.valid) && <p>{solrSetsErrorMessage}</p>}
54 </div>
55 </div>
56 </div>
57 </div>
58 );
59 };
60
61 export default SolrEditor;
62