-
Notifications
You must be signed in to change notification settings - Fork 32
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
PCH Related Posts: Add advanced search #3117
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request introduces significant changes to the Related Posts functionality across multiple files. The primary modifications involve removing Changes
Sequence DiagramsequenceDiagram
participant User
participant EditorSidebar
participant RelatedPostsProvider
participant ContentAPI
User->>EditorSidebar: Open sidebar
EditorSidebar->>RelatedPostsProvider: Request related posts
RelatedPostsProvider->>ContentAPI: Fetch posts with new filters
ContentAPI-->>RelatedPostsProvider: Return filtered posts
RelatedPostsProvider-->>EditorSidebar: Display related posts
Possibly related PRs
Suggested Labels
Suggested Reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
foreach ( $params as $param ) { | ||
$param = rawurlencode( $param ); | ||
if ( strpos( $url, $param_name . '=' ) === false ) { | ||
$url = add_query_arg( $param_name, $param, $url ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed because add_query_arg()
would remove same key params that were previously added.
test( 'should show no results message when there is no tag or category in the post', async () => { | ||
const getRelatedPostsFn = getRelatedPostsMockFn( () => Promise.resolve( { | ||
message: 'The Parse.ly API did not return any results for posts by "author".', | ||
posts: [], | ||
} ) ); | ||
|
||
setMockPostData( [ 'admin' ], [], [] ); | ||
|
||
await waitFor( async () => { | ||
render( relatedPostsPanel ); | ||
expect( getLoadingMessage() ).toBeInTheDocument(); | ||
} ); | ||
|
||
expect( getRelatedPostsFn ).toHaveBeenCalled(); | ||
expect( getLoadingMessage() ).toBeNull(); | ||
|
||
const relatedPostDescr = getRelatedPostDescr(); | ||
expect( relatedPostDescr ).toBeInTheDocument(); | ||
expect( relatedPostDescr ).toBeVisible(); | ||
|
||
// When there is no tag or category in the post, it should fallback to the author. | ||
expect( relatedPostDescr?.textContent ).toEqual( 'Top related posts by admin in the last 7 days.' ); | ||
expect( getRelatedPostsEmptyMessage() ).toBeInTheDocument(); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really applicable with the new setup.
/** | ||
* Verifies that the Related Posts panel will work correctly when a new | ||
* taxonomy is added from within the WordPress Post Editor. | ||
* | ||
* @since 3.17.0 Migrated to Playwright. | ||
*/ | ||
test( 'Should work correctly when a taxonomy is added from within the WordPress Post Editor', async ( { admin } ) => { | ||
const categoryName = 'Analytics That Matter'; | ||
|
||
expect( await getRelatedPostsMessage( | ||
admin, categoryName, '', 'section', '.related-posts-descr' | ||
) ).toMatch( `Top related posts in the “${ categoryName }” section in the last 7 days.` ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were essentially testing Gutenberg functionality here. With the cleanup in the getRelatedPostsMessage()
function, I chose to just remove it.
// Select/add category in the Post Editor. | ||
if ( category !== '' ) { | ||
const categoryToggleButton = page.getByRole( 'button', { name: 'Categories' } ); | ||
await categoryToggleButton.click(); | ||
await page.getByRole( 'button', { name: 'Add New Category' } ).first().click(); | ||
await page.getByLabel( 'New Category Name' ).fill( category ); | ||
await page.getByRole( 'button', { name: 'Add New Category' } ).last().click(); | ||
await categoryToggleButton.click(); | ||
} | ||
|
||
// Select/add tag in the Post Editor. | ||
if ( tag !== '' ) { | ||
const tagToggleButton = page.getByRole( 'button', { name: 'Tags' } ); | ||
await tagToggleButton.click(); | ||
await page.getByLabel( 'Add New Tag' ).fill( tag ); | ||
await page.keyboard.press( 'Enter' ); | ||
await tagToggleButton.click(); | ||
} | ||
|
||
// Show the Content Helper Sidebar. | ||
// Show the Content Helper Sidebar and expand the Related Posts panel. | ||
await page.getByRole( 'button', { name: 'Parse.ly' } ).click(); | ||
await setSidebarPanelExpanded( page, 'Related Posts', true ); | ||
|
||
// Set the filter type. | ||
if ( '' !== filterType ) { | ||
await page.keyboard.press( 'Tab' ); | ||
await page.keyboard.type( filterType.charAt( 0 ) ); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed code wasn't been used in most tests, and our new advanced search approach made it obsolete. Rewriting it would provide very limited value and take some time, so I opted to remove it instead.
If we ever want to extensively test filter selection impact, it will be maybe better to have a dedicated function for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (9)
src/content-helper/editor-sidebar/related-posts/provider.ts (3)
44-50
: Add a @SInCE tag in the method’s JSDoc.
WordPress coding standards require a@since
annotation for newly introduced methods.
53-65
: End parameter descriptions with a period.
WordPress coding guidelines recommend ending each JSDoc parameter line with a period.
71-90
: Sanitize filter input before API requests.
Ensure thatauthor
,section
, andtags
values are safely handled to prevent potential injection.src/content-helper/editor-sidebar/related-posts/component.tsx (3)
126-130
: Externalize default filter values.
Consider moving them to a constants file to simplify updates and maintenance.
Line range hint
185-209
: Consider a fully async/await approach.
Refactor the promise chain for clearer readability and error handling.
212-217
: Complete JSDoc with @SInCE and punctuation.
Add a@since
annotation if newly introduced, and end each parameter line with a period.src/content-helper/common/utils/api.ts (1)
15-15
: Update JSDoc for the tag property to document the array support.The change from string to string[] is correct and aligns with the multi-tag filtering requirement. Consider adding JSDoc to document this capability.
export interface AnalyticsApiOptionalQueryParams extends ApiPeriodRange { + /** Array of tags to filter by. Supports up to 5 tags. @since 3.14.0 */ tag?: string[];
src/content-helper/editor-sidebar/related-posts/component-filter-settings.tsx (2)
22-24
: Add JSDoc for FilterControlsProps properties.The type definition needs documentation for its properties.
type FilterControlsProps = { + /** Post filters containing author, section, and tags. @since 3.14.0 */ filters: PostFilters; + /** Optional label for the filter controls. @since 3.14.0 */ label?: string; + /** Callback function when filters change. @since 3.14.0 */ onFiltersChange: ( selection: string | null | undefined, type:PostFilterType ) => void;
40-43
: Consider extracting the condition to a descriptive variable.The condition checking for empty data could be more readable.
- if ( 0 === postData.authors.length && - 0 === postData.categories.length && - 0 === postData.tags.length - ) { + const hasNoFilterableData = 0 === postData.authors.length && + 0 === postData.categories.length && + 0 === postData.tags.length; + + if (hasNoFilterableData) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
build/content-helper/dashboard-widget.asset.php
is excluded by!build/**
build/content-helper/dashboard-widget.js
is excluded by!build/**
build/content-helper/editor-sidebar-rtl.css
is excluded by!build/**
build/content-helper/editor-sidebar.asset.php
is excluded by!build/**
build/content-helper/editor-sidebar.css
is excluded by!build/**
build/content-helper/editor-sidebar.js
is excluded by!build/**
build/loader.asset.php
is excluded by!build/**
build/loader.js
is excluded by!build/**
📒 Files selected for processing (17)
src/content-helper/common/settings/types/sidebar-settings.d.ts
(0 hunks)src/content-helper/common/utils/api.ts
(1 hunks)src/content-helper/common/utils/constants.ts
(1 hunks)src/content-helper/editor-sidebar/editor-sidebar.tsx
(1 hunks)src/content-helper/editor-sidebar/related-posts/component-filter-settings.tsx
(2 hunks)src/content-helper/editor-sidebar/related-posts/component.tsx
(8 hunks)src/content-helper/editor-sidebar/related-posts/provider.ts
(2 hunks)src/content-helper/editor-sidebar/related-posts/related-posts.scss
(0 hunks)src/rest-api/settings/class-endpoint-editor-sidebar-settings.php
(1 hunks)src/services/content-api/endpoints/class-endpoint-analytics-posts.php
(2 hunks)tests/Integration/RestAPI/Settings/EndpointEditorSidebarSettingsTest.php
(1 hunks)tests/Integration/Services/ContentAPI/Endpoints/EndpointAnalyticsPostsTest.php
(2 hunks)tests/e2e/specs/content-helper/errors.spec.ts
(2 hunks)tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts
(1 hunks)tests/e2e/specs/content-helper/top-bar-icon.spec.ts
(1 hunks)tests/e2e/utils.ts
(1 hunks)tests/js/content-helper/structure.test.tsx
(7 hunks)
💤 Files with no reviewable changes (2)
- src/content-helper/common/settings/types/sidebar-settings.d.ts
- src/content-helper/editor-sidebar/related-posts/related-posts.scss
🧰 Additional context used
📓 Path-based instructions (15)
tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/common/utils/api.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/rest-api/settings/class-endpoint-editor-sidebar-settings.php (1)
Pattern **/*.{html,php}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
- Ensure the code follows WordPress coding standards and is well-documented.
- Confirm the code is secure and free from vulnerabilities.
- Optimize the code for performance, removing any unnecessary elements.
- Validate comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/RestAPI/Settings/EndpointEditorSidebarSettingsTest.php (1)
Pattern **/*.{html,php}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
- Ensure the code follows WordPress coding standards and is well-documented.
- Confirm the code is secure and free from vulnerabilities.
- Optimize the code for performance, removing any unnecessary elements.
- Validate comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/e2e/utils.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/e2e/specs/content-helper/top-bar-icon.spec.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/e2e/specs/content-helper/errors.spec.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/services/content-api/endpoints/class-endpoint-analytics-posts.php (1)
Pattern **/*.{html,php}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
- Ensure the code follows WordPress coding standards and is well-documented.
- Confirm the code is secure and free from vulnerabilities.
- Optimize the code for performance, removing any unnecessary elements.
- Validate comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/Services/ContentAPI/Endpoints/EndpointAnalyticsPostsTest.php (1)
Pattern **/*.{html,php}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
- Ensure the code follows WordPress coding standards and is well-documented.
- Confirm the code is secure and free from vulnerabilities.
- Optimize the code for performance, removing any unnecessary elements.
- Validate comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/common/utils/constants.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/related-posts/component-filter-settings.tsx (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/related-posts/provider.ts (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/js/content-helper/structure.test.tsx (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/related-posts/component.tsx (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
src/content-helper/editor-sidebar/editor-sidebar.tsx (1)
Pattern **/*.{js,ts,tsx,jsx}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the code to ensure it is well-structured and adheres to best practices.
- Verify compliance with WordPress coding standards.
- Ensure the code is well-documented.
- Check for security vulnerabilities and confirm the code is secure.
- Optimize the code for performance, removing any unnecessary elements.
- Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
- Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
🪛 Biome (1.9.4)
src/content-helper/editor-sidebar/related-posts/provider.ts
[error] 40-40: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
🔇 Additional comments (29)
src/services/content-api/endpoints/class-endpoint-analytics-posts.php (3)
121-123
: LGTM! Method name change improves clarity.The renamed method
append_same_key_params_to_url
better describes its purpose of appending multiple values with the same key.
157-170
: LGTM! Well-documented method with improved parameter names.The PHPDoc follows WordPress standards, and the parameter names are more descriptive and aligned with their purpose.
171-186
: LGTM! Robust implementation with proper validation.The implementation includes:
- Empty key and value validation
- Proper URL encoding for special characters
- Correct URL parameter appending logic
tests/Integration/Services/ContentAPI/Endpoints/EndpointAnalyticsPostsTest.php (3)
50-71
: LGTM! Well-structured test method with comprehensive documentation.The test method follows PHPUnit best practices with proper annotations and parameter documentation.
72-81
: LGTM! Test implementation follows best practices.The test properly uses reflection to access the protected method and performs exact string comparison for validation.
83-158
: LGTM! Comprehensive data provider with excellent test coverage.The data provider includes well-organized test cases covering:
- Basic URL parameter handling
- Complex scenarios with existing parameters
- Special character handling
- Edge cases with empty values
src/content-helper/editor-sidebar/related-posts/provider.ts (1)
10-14
: No concerns about the new imports.
They adhere to standard WordPress and TypeScript usage with no functional or security concerns.src/content-helper/editor-sidebar/related-posts/component.tsx (5)
Line range hint
11-24
: Imports and enumerations are consistent.
Usage of WordPress imports and enumerations appears fine and secure.
219-236
: Validate or sanitize filter input.
Ensure that user-provided data is not used in a way that could introduce XSS or other vulnerabilities.
259-259
: Localized string usage is correct.
Good job using the__()
function for translations.
295-296
: Filter component integration looks good.
Props usage is consistent with the newPostFilters
interface.
314-314
: Clear no-results message.
Provides a user-friendly fallback in case no posts are returned.tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts (1)
46-47
: Test coverage is appropriate.
Verifying for “Loading…” ensures the fetch request initiates successfully.src/content-helper/editor-sidebar/related-posts/component-filter-settings.tsx (1)
82-92
: LGTM! Well-implemented tag filtering.The FormTokenField implementation correctly:
- Limits tags to 5 using maxLength
- Hides unnecessary help text
- Uses placeholder text
- Provides tag suggestions
tests/e2e/specs/content-helper/errors.spec.ts (1)
86-87
: LGTM! Tests updated to match new UI text.The test changes correctly reflect the updated UI message and selector.
src/rest-api/settings/class-endpoint-editor-sidebar-settings.php (1)
84-91
: LGTM! Clean removal of deprecated filter settings.The RelatedPosts configuration has been correctly simplified while maintaining essential settings.
tests/e2e/utils.ts (2)
44-45
: LGTM! Function signature simplified to match new advanced search approach.The removal of
category
,tag
, andfilterType
parameters aligns with the PR's objective of supporting composite searches. The simplified signature improves maintainability.Also applies to: 50-51
57-60
: LGTM! Clear and focused implementation.The code is well-commented and performs the necessary steps in a straightforward manner.
src/content-helper/common/utils/constants.ts (2)
Line range hint
32-38
: LGTM! Filter types aligned with advanced search feature.The
PostFilterType
enum now precisely reflects the available filter types for the advanced search feature.
50-55
: LGTM! Well-designed interface for advanced search.The
PostFilters
interface effectively supports:
- AND search queries with author and section
- Multiple tag selection through the tags array
tests/e2e/specs/content-helper/top-bar-icon.spec.ts (1)
78-79
: LGTM! Tests updated to match new UI.The selector and expected message have been appropriately updated to reflect the new advanced search interface.
src/content-helper/editor-sidebar/editor-sidebar.tsx (2)
14-14
: LGTM! Import reorganized for better code organization.The
PluginSidebar
import is now properly sourced from type definitions.
Line range hint
71-77
: LGTM! Settings structure simplified.The removal of
FilterBy
andFilterValue
fromRelatedPosts
settings aligns with the new advanced search implementation, reducing complexity while maintaining type safety.tests/js/content-helper/structure.test.tsx (5)
21-21
: LGTM: Import statement aligns with type changes.The addition of the PostData type import is consistent with the refactoring of related posts handling.
128-128
: LGTM: Mock function signature simplified.The function now directly returns PostData[], which aligns with the simplified related posts API interactions.
183-185
: LGTM: Mock data structure simplified.The mock data is now directly returned without wrapping it in a GetRelatedPostsResult object, consistent with the new API structure.
290-292
: LGTM: Function signature updated correctly.The type annotation change to PostData[] maintains consistency with the simplified data structure.
308-310
: LGTM: Function signature updated correctly.The type annotation change to PostData[] maintains consistency with the simplified data structure.
tests/Integration/RestAPI/Settings/EndpointEditorSidebarSettingsTest.php (1)
77-79
: LGTM: RelatedPosts array simplified and properly ordered.The removal of FilterBy and FilterValue keys aligns with the broader restructuring, and the remaining keys are correctly sorted alphabetically as per the comment guidelines.
Description
With this PR, we're adding advanced search to PCH Related Posts.
To keep the fetching operation to a single API call, only
AND
search queries are supported. The search can query for author, section, and up to 5 tags simultaneously.Additional changes:
Top related posts in the x section in the last x days
was removed, as it would become quite large and unwieldy for composite searches.Motivation and context
Offer a way to get more specific results.
How has this been tested?
Some tests were added, others adjusted and a couple of them removed.
Screenshots
Summary by CodeRabbit
Release Notes
New Features
Changes
Improvements
Refactoring
This release focuses on improving the flexibility and usability of related posts filtering while removing legacy code and simplifying the overall implementation.