Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New weighting screen with meta support #3068

Merged
merged 78 commits into from Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
6533af8
Add weghting screen page in react
mehidi258 Feb 8, 2022
3aeedc5
Resolve merge conflict
mehidi258 Feb 8, 2022
e909129
Fix weghting screen
mehidi258 Feb 9, 2022
02d459b
Merge branch 'develop' into feature/mapping-weighting-dashboard
JakePT Sep 29, 2022
d865cf0
Refactor with core components.
JakePT Oct 4, 2022
b68c382
WIP populate weighting screen with real data.
JakePT Oct 9, 2022
8dc36c8
WIP: Progress on dashboard, handle updated data format.
JakePT Oct 13, 2022
d1c4cd5
WIP: Implement manual management of meta.
JakePT Oct 19, 2022
0e48d7b
Revert unnecessary changes.
JakePT Oct 19, 2022
13672ac
Support saving settings.
JakePT Oct 19, 2022
74813a6
Rename manage meta setting.
JakePT Oct 19, 2022
3197023
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
JakePT Oct 19, 2022
207291e
WIP: Implement global meta management control.
JakePT Oct 20, 2022
712f656
Restore incorrectly removed CSS.
JakePT Oct 20, 2022
f910909
WIP: Move method.
JakePT Oct 20, 2022
2b37481
WIP: Unique name for meta group, sanitize weighting.
JakePT Oct 21, 2022
09bf6c2
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
felipeelia Oct 24, 2022
50adff6
Bring back some methods and mark them as deprecated
felipeelia Oct 24, 2022
12c2297
On multisites, always use meta = auto
felipeelia Oct 24, 2022
091d827
Implement meta mode auto/manual during index time
felipeelia Oct 24, 2022
32e2ea0
Check if $search->weighting is set before using it
felipeelia Oct 24, 2022
5a880b0
Test meta index when using manual
felipeelia Oct 24, 2022
d155577
Do not enqueue weighting files on install
felipeelia Oct 24, 2022
7007000
Get fields from the database
felipeelia Oct 24, 2022
27b755f
Fix typo
felipeelia Oct 24, 2022
d72afad
Move to a finally block
felipeelia Oct 24, 2022
fba57f4
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
felipeelia Oct 26, 2022
5b9f921
New filters and tests for get_distinct_meta_field_keys_db
felipeelia Oct 26, 2022
7b551a2
Adjust e2e tests to the new markup
felipeelia Oct 26, 2022
6d758b5
Copy update
felipeelia Oct 28, 2022
14635d3
Add notices on Save.
JakePT Oct 31, 2022
54de7aa
Update weighting tests, add test for meta.
JakePT Oct 31, 2022
ca9044e
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
JakePT Oct 31, 2022
42ded1b
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
JakePT Nov 4, 2022
0876079
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
JakePT Nov 21, 2022
689acf1
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
JakePT Mar 8, 2023
a18faed
Correct weighting script.
JakePT Mar 9, 2023
91399f6
Move meta mode to a filter.
JakePT Mar 13, 2023
cf3f002
Update copy to replace index with sync.
JakePT Mar 13, 2023
63a899e
Update ep_meta_mode hook description.
JakePT Mar 13, 2023
272767b
Require a sync when fields are added.
JakePT Mar 13, 2023
bc5a344
Tweak styles.
JakePT Mar 24, 2023
27c5a0e
Update @since tags.
JakePT Mar 24, 2023
944ac2f
Update tests to support filter.
JakePT Mar 27, 2023
d130ef3
Merge branch 'develop' into feature/mapping-weighting-dashboard-refactor
JakePT Apr 4, 2023
5d2b098
Don't make all keys available as weightable fields.
JakePT Sep 5, 2023
040e15a
Merge branch 'develop' into feature/1690
JakePT Sep 12, 2023
2462086
WIP: Allow adding arbitrary metadata.
JakePT Sep 7, 2023
c7f4540
Update package-lock.json.
JakePT Sep 12, 2023
0e56b99
Rearrange for cleaner diff.
JakePT Sep 12, 2023
a8b3bdb
Update validation of custom fields.
JakePT Sep 12, 2023
0661a10
Update @since versions.
JakePT Sep 12, 2023
3c5c48a
Fix PHPCS issues. Remove redundant test.
JakePT Sep 12, 2023
38aecdb
Update custom field test.
JakePT Sep 12, 2023
5ce4726
Only show custom fields for relevant post types.
JakePT Sep 12, 2023
aee10b2
Remove undo functionality.
JakePT Sep 12, 2023
06ed936
Add notices. Tweak styles.
JakePT Sep 13, 2023
bf5ea7f
Ensure custom results taxonomy is not public.
JakePT Sep 15, 2023
1d09602
Small tweaks.
JakePT Sep 15, 2023
c3d924f
Merge branch '5.0.0' into feature/mapping-weighting-dashboard-refactor
JakePT Sep 27, 2023
b29937b
Implement SettingsScreenProvider for weighting settings.
JakePT Sep 27, 2023
01e1fc4
Merge branch '5.0.0' into feature/mapping-weighting-dashboard-refactor
JakePT Oct 19, 2023
1b699a2
Merge branch '5.0.0' into feature/mapping-weighting-dashboard-refactor
JakePT Oct 24, 2023
d3bc1bd
Add fields to weighting for Facets tests.
JakePT Oct 24, 2023
5b7a6f0
Update posts indexable test.
JakePT Oct 24, 2023
72cde58
Fix button label in weighting tests.
JakePT Oct 24, 2023
46ead92
Fix weighting test.
JakePT Oct 24, 2023
ee93128
Add message about syncing.
JakePT Oct 24, 2023
32d7749
Merge branch '5.0.0' into feature/mapping-weighting-dashboard-refactor
felipeelia Oct 24, 2023
a2a7398
Adjust unit tests for the weighting dashboard
felipeelia Oct 25, 2023
f63f8f4
Delete elasticpress_weighting on uninstall
felipeelia Oct 25, 2023
18b4327
Use defaults when the weighting config was not saved
felipeelia Oct 25, 2023
8cf25c5
Allow ep_exclude_from_search by default
felipeelia Oct 25, 2023
cb49f96
Adjust testTooManyFieldsNoticeInAdmin
felipeelia Oct 25, 2023
72e5f8f
If a type is not searchable, do not apply weighting config
felipeelia Oct 25, 2023
f0b7284
Fix TestPost normalizing all meta key names
felipeelia Oct 25, 2023
68d1213
Fix lint
felipeelia Oct 25, 2023
e35af9b
Fix testIndexableContentReport
felipeelia Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .wp-env.json
Expand Up @@ -21,6 +21,7 @@
".htaccess": "./tests/cypress/wordpress-files/.htaccess",
"wp-content/mu-plugins/skip-wp-lookup.php": "./tests/cypress/wordpress-files/test-mu-plugins/skip-wp-lookup.php",
"wp-content/mu-plugins/unique-index-name.php": "./tests/cypress/wordpress-files/test-mu-plugins/unique-index-name.php",
"wp-content/plugins/auto-meta-mode.php": "./tests/cypress/wordpress-files/test-plugins/auto-meta-mode.php",
"wp-content/mu-plugins/disable-welcome-guide.php": "./tests/cypress/wordpress-files/test-mu-plugins/disable-welcome-guide.php",
"wp-content/plugins/cpt-and-custom-tax.php": "./tests/cypress/wordpress-files/test-plugins/cpt-and-custom-tax.php",
"wp-content/plugins/custom-instant-results-template.php": "./tests/cypress/wordpress-files/test-plugins/custom-instant-results-template.php",
Expand Down
174 changes: 0 additions & 174 deletions assets/css/dashboard.css
Expand Up @@ -665,180 +665,6 @@ h2.ep-list-features {
color: #d84440;
}

/**
* Weighting
*/

.weighting-settings .postbox {
box-sizing: border-box;
max-width: 650px;

& * {
box-sizing: border-box;
}
}

.weighting-settings .postbox h2.hndle {
color: #444;
cursor: inherit;
}

.weighting-settings fieldset {
padding: 10px;
}

.weighting-settings fieldset legend {
float: left; /* legend cannot use display */
position: relative;
top: 5px;
width: 100px;
}

.weighting-settings fieldset p {
display: inline-block;
float: left;
margin: 0;
}

.weighting-settings .field-group {
margin: 10px 0 0;
}

.weighting-settings .field-group h3 {
font-size: 1em;
margin: 10px;
}

.weighting-settings .fields > fieldset:nth-of-type(odd) {
background: #f9f9f9;
}

.weighting-settings .searchable {
display: inline-block;
width: 120px;
}

.weighting-settings .weighting {
align-items: center;
display: flex;
}

.weighting-settings .weighting label {
margin-right: 10px;
min-width: 80px;
}

.weighting-settings input[type="range"] {
-webkit-appearance: none;
background: transparent;
display: inline-block;
height: 1em;
margin: 0;
vertical-align: middle;
width: 200px;
}

.weighting-settings input[type="range"]:focus {
outline: none;
}

.weighting-settings input[type="range"]:disabled {
opacity: 0.5;
pointer-events: none;
}

.weighting-settings input[type="range"]::-webkit-slider-runnable-track {
background: #ddd;
border: 0 solid #000;
border-radius: 1px;
box-shadow: 0 0 0 #000;
cursor: pointer;
height: 3px;
width: 100%;
}

.weighting-settings input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
background: #1e8cbe;
border: 1px solid #1e8cbe;
border-radius: 25px;
box-shadow: 0 0 0 #000;
cursor: pointer;
height: 14px;
margin-top: -6px;
width: 14px;
}

.weighting-settings input[type="range"]:focus::-webkit-slider-runnable-track {
background: #ddd;
}

.weighting-settings input[type="range"]:focus::-webkit-slider-thumb {
background: #fff !important;
}

.weighting-settings input[type="range"]::-moz-range-track {
background: #1e8cbe;
border: 0 solid #000;
border-radius: 1px;
box-shadow: 0 0 0 #000;
cursor: pointer;
height: 3px;
width: 100%;
}

.weighting-settings input[type="range"]::-moz-range-thumb {
background: #1e8cbe;
border: 1px solid #1e8cbe;
border-radius: 25px;
box-shadow: 0 0 0 #000;
cursor: pointer;
height: 14px;
width: 14px;
}

.weighting-settings input[type="range"]::-ms-track {
background: transparent;
border-color: transparent;
color: transparent;
cursor: pointer;
height: 3px;
width: 100%;
}

.weighting-settings input[type="range"]::-ms-fill-lower {
background: #1e8cbe;
border: 0 solid #000;
border-radius: 2px;
box-shadow: 0 0 0 #000;
}

.weighting-settings input[type="range"]::-ms-fill-upper {
background: #1e8cbe;
border: 0 solid #000;
border-radius: 2px;
box-shadow: 0 0 0 #000;
}

.weighting-settings input[type="range"]::-ms-thumb {
background: #a1d0ff;
border: 1px solid #1e8cbe;
border-radius: 25px;
box-shadow: 0 0 0 #000;
cursor: pointer;
height: 14px;
margin-top: 1px;
width: 14px;
}

.weighting-settings input[type="range"]:focus::-ms-fill-lower {
background: #1e8cbe;
}

.weighting-settings input[type="range"]:focus::-ms-fill-upper {
background: #1e8cbe;
}

.ep-feature-search .wp-color-result.button {
margin-bottom: 10px;
}
Expand Down
64 changes: 64 additions & 0 deletions assets/js/weighting/apps/weighting.js
@@ -0,0 +1,64 @@
/**
* WordPress dependencies.
*/
import { Button } from '@wordpress/components';
import { WPElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Internal Dependencies.
*/
import { useSettingsScreen } from '../../settings-screen';
import PostType from '../components/post-type';
import { useWeightingSettings } from '../provider';

/**
* Weighting settings app.
*
* @returns {WPElement} Element.
*/
export default () => {
const { createNotice } = useSettingsScreen();
const { isBusy, save, weightableFields } = useWeightingSettings();

/**
* Submit event.
*
* @param {Event} event Submit event.
*/
const onSubmit = async (event) => {
event.preventDefault();

try {
await save();
createNotice('success', __('Settings saved.', 'elasticpress'));
} catch (e) {
createNotice('error', __('Something went wrong. Please try again.', 'elasticpress'));
}
};

return (
<>
<p>
{__(
'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.',
'elasticpress',
)}
</p>
<p>
{__(
'For example, adding more weight to the title attribute will cause search matches on the post title to appear more prominently.',
'elasticpress',
)}
</p>
<form className="ep-weighting-screen" onSubmit={onSubmit}>
{weightableFields.map(({ key }) => {
return <PostType key={key} postType={key} />;
})}
<Button disabled={isBusy} isBusy={isBusy} isPrimary type="submit" variant="primary">
{__('Save changes', 'elasticpress')}
</Button>
</form>
</>
);
};
78 changes: 78 additions & 0 deletions assets/js/weighting/components/field.js
@@ -0,0 +1,78 @@
/**
* WordPress Dependencies.
*/
import { Button, CheckboxControl, RangeControl } from '@wordpress/components';
import { WPElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { trash } from '@wordpress/icons';

/**
* Field settings component.
*
* @param {object} props Component props.
* @param {string} props.label Property label.
* @param {Function} props.onChange Change handler.
* @param {Function} props.onDelete Delete handler.
* @param {object} props.value Values.
* @returns {WPElement} Component element.
*/
export default ({ label, onChange, onDelete, value }) => {
const { enabled = false, weight = 0 } = value;

/**
* Handle change of searchable.
*
* @param {boolean} enabled New searchable value.
* @returns {void}
*/
const onChangeSearchable = (enabled) => {
onChange({ weight, enabled });
};

/**
* Handle change of weighting.
*
* @param {number} weight New weight value.
* @returns {void}
*/
const onChangeWeight = (weight) => {
onChange({ enabled: true, weight });
};

/**
* Render.
*/
return (
<div className="ep-weighting-field">
<fieldset>
<legend className="ep-weighting-field__name">{label}</legend>
<div className="ep-weighting-field__searchable">
<CheckboxControl
checked={enabled}
label={__('Searchable', 'elasticpress')}
onChange={onChangeSearchable}
/>
</div>
<div className="ep-weighting-field__weighting">
<RangeControl
disabled={!enabled}
label={__('Weight', 'elasticpress')}
max={100}
min={1}
onChange={onChangeWeight}
value={weight}
/>
</div>
<div className="ep-weighting-field__actions">
<Button
className="ep-weighting-action ep-weighting-action--delete"
disabled={!onDelete}
icon={trash}
label={__('Remove', 'elasticpress')}
onClick={onDelete}
/>
</div>
</fieldset>
</div>
);
};