PluginProbe
ElasticPress / 5.0.1
ElasticPress v5.0.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 / weighting / apps / weighting.js

weighting.js in ElasticPress 5.0.1, at assets/js/weighting/apps/weighting.js

65 lines 1.8 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 { Button } from '@wordpress/components';
5 import { WPElement } from '@wordpress/element';
6 import { __ } from '@wordpress/i18n';
7
8 /**
9 * Internal Dependencies.
10 */
11 import { useSettingsScreen } from '../../settings-screen';
12 import PostType from '../components/post-type';
13 import { useWeightingSettings } from '../provider';
14
15 /**
16 * Weighting settings app.
17 *
18 * @returns {WPElement} Element.
19 */
20 export default () => {
21 const { createNotice } = useSettingsScreen();
22 const { isBusy, save, weightableFields } = useWeightingSettings();
23
24 /**
25 * Submit event.
26 *
27 * @param {Event} event Submit event.
28 */
29 const onSubmit = async (event) => {
30 event.preventDefault();
31
32 try {
33 await save();
34 createNotice('success', __('Settings saved.', 'elasticpress'));
35 } catch (e) {
36 createNotice('error', __('Something went wrong. Please try again.', 'elasticpress'));
37 }
38 };
39
40 return (
41 <>
42 <p>
43 {__(
44 'This dashboard enables you to select which fields ElasticPress should sync, whether to use those fields in searches, and how heavily to weight fields in the search algorithm. In general, increasing the Weight of a field will increase the relevancy score of a post that has matching text in that field.',
45 'elasticpress',
46 )}
47 </p>
48 <p>
49 {__(
50 'For example, adding more weight to the title attribute will cause search matches on the post title to appear more prominently.',
51 'elasticpress',
52 )}
53 </p>
54 <form className="ep-weighting-screen" onSubmit={onSubmit}>
55 {weightableFields.map(({ key }) => {
56 return <PostType key={key} postType={key} />;
57 })}
58 <Button disabled={isBusy} isBusy={isBusy} isPrimary type="submit" variant="primary">
59 {__('Save changes', 'elasticpress')}
60 </Button>
61 </form>
62 </>
63 );
64 };
65