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

PCH Excerpt Suggestions: Adds feature as a panel in the PCH sidebar #2811

Open
wants to merge 1 commit into
base: add/excerpt-suggestions-settings
Choose a base branch
from

Conversation

vaurdan
Copy link
Contributor

@vaurdan vaurdan commented Sep 26, 2024

Description

This PR adds the Excerpt Suggestions feature to the PCH Sidebar, as it's own panel. The feature is still available as a replacement for the core excerpt panel, in the document sidebar.

There are some slight UI differences between the two panels, that are visible in the screenshots below.

Note: this work is based upon #2776, since it uses the work that was implemented there.

Motivation and context

How has this been tested?

Tested locally

Screenshots (if appropriate)

UI in the document sidebar UI in the PCH sidebar
image image

Summary by CodeRabbit

  • New Features

    • Introduced ExcerptSuggestionsPanel for improved excerpt suggestions with dynamic UI elements.
    • Added ExcerptDocumentSettingPanel for custom excerpt suggestions based on post type support.
    • Implemented a new "Excerpt Suggestions" panel in the sidebar, conditional on user permissions and post type.
  • Bug Fixes

    • Streamlined rendering logic for success notices in the Smart Linking feature.
  • Style

    • Enhanced styling for excerpt suggestions with new CSS classes for better layout and presentation.

@vaurdan vaurdan added this to the 3.17.0 milestone Sep 26, 2024
@vaurdan vaurdan self-assigned this Sep 26, 2024
@vaurdan vaurdan requested a review from a team as a code owner September 26, 2024 09:50
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

📝 Walkthrough

Walkthrough

The changes introduce a new ExcerptSuggestionsPanel component that replaces the PostExcerptSuggestions component, allowing conditional rendering based on the isDocumentSettingPanel prop. This affects the UI elements displayed, including instructional text and buttons. The ExcerptDocumentSettingPanel is added to manage excerpt suggestions based on post type support. Additionally, CSS styles are updated to enhance the layout of excerpt suggestions. The SmartLinkingPanel is modified to streamline success notice rendering, and a new conditional rendering feature is added to the SidebarToolsTab for excerpt suggestions.

Changes

File Change Summary
src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx Introduced ExcerptSuggestionsPanel, replaced PostExcerptSuggestions, added conditional rendering based on isDocumentSettingPanel. Removed ExcerptPanel.
src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.scss Added new CSS class .excerpt-suggestions-text and modified .wp-parsely-excerpt-generator.is-doc-set-panel.
src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.tsx Added ExcerptDocumentSettingPanel, updated rendering logic to use this new panel instead of ExcerptPanel.
src/content-helper/editor-sidebar/smart-linking/component.tsx Simplified rendering logic for success notice in SmartLinkingPanel, adjusted formatting.
src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx Added conditional rendering for "Excerpt Suggestions" panel based on user permissions and post type support.

Assessment against linked issues

Objective Addressed Explanation
Include excerpt generator in Content Helper sidebar panel (#2552)
Display excerpt suggestions in the appropriate location within the publishing workflow (#2552)

Possibly related PRs

Suggested labels

Feature: Content Helper, Component: JavaScript


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (5)
src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.tsx (1)

24-50: LGTM: Well-structured component implementing excerpt suggestions.

The ExcerptDocumentSettingPanel component is well-implemented and aligns with the PR objectives. It correctly uses PostTypeSupportCheck and PluginDocumentSettingPanel to create the excerpt suggestions panel in the sidebar.

Minor suggestion:
Consider adding a brief explanation of the isDocumentSettingPanel prop passed to ExcerptSuggestionsPanel in the JSDoc comment for clarity.

src/content-helper/editor-sidebar/smart-linking/component.tsx (3)

682-692: Approved: Improved readability of success notice rendering.

The changes simplify the conditional rendering of the success notice, enhancing code readability. The message format adjustment is minor and maintains clarity.

Consider using template literals for better readability:

-						{ sprintf(
-							/* translators: 1 - number of smart links generated */
-							__( 'Successfully added %s smart links.', 'wp-parsely' ),
-							numAddedLinks > 0 ? numAddedLinks : suggestedLinks.length,
-						) }
+						{ /* translators: 1 - number of smart links generated */ }
+						{ __( `Successfully added ${numAddedLinks > 0 ? numAddedLinks : suggestedLinks.length} smart links.`, 'wp-parsely' ) }

Line range hint 1-748: Consider refactoring to reduce component complexity.

The SmartLinkingPanel component is quite large and complex. Consider breaking it down into smaller, more manageable sub-components or custom hooks to improve maintainability and readability.

For example, you could extract the smart link generation logic into a custom hook:

const useSmartLinkGeneration = (isFullContent, selectedBlock, postContent, maxLinks) => {
  // ... extract relevant logic here
  return { generateSmartLinks, loading, error };
};

Then use it in the component:

const { generateSmartLinks, loading, error } = useSmartLinkGeneration(isFullContent, selectedBlock, postContent, maxLinks);

This would significantly reduce the complexity of the main component.


Line range hint 280-321: Enhance error handling in generateSmartLinksWithRetry.

The error handling in the generateSmartLinksWithRetry function could be improved to provide more specific error messages and better error recovery.

Consider creating a custom error class for different types of errors that can occur during smart link generation. This would allow for more precise error handling and recovery:

class SmartLinkGenerationError extends Error {
  constructor(message: string, public readonly code: string, public readonly retryable: boolean) {
    super(message);
    this.name = 'SmartLinkGenerationError';
  }
}

// In the catch block:
if (err instanceof SmartLinkGenerationError) {
  if (err.retryable && retries > 0) {
    // Retry logic
  } else {
    // Handle non-retryable errors
  }
} else {
  // Handle unexpected errors
}
src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx (1)

68-79: Add JSDoc comment with @since tag for the Excerpt Suggestions panel.

To maintain consistency and provide clear documentation, please add a JSDoc comment for the Excerpt Suggestions panel, including an @since tag indicating the next version of the plugin that includes this code.

Example:

/**
 * Excerpt Suggestions Panel.
 * Displays excerpt suggestions in the Content Helper sidebar.
 *
 * @since x.x.x
 */

Place this comment above the <PanelBody> component starting at line 67.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b409dcd and 777390b.

⛔ Files ignored due to path filters (4)
  • 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/**
📒 Files selected for processing (5)
  • src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx (8 hunks)
  • src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.scss (1 hunks)
  • src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.tsx (2 hunks)
  • src/content-helper/editor-sidebar/smart-linking/component.tsx (2 hunks)
  • src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.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/excerpt-suggestions/excerpt-suggestions.scss (1)

Pattern **/*.{css,scss}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the SCSS code to ensure it is well-structured and adheres to best practices.
  • Convert dimensions greater than or equal to 3px to rem units using the to_rem function.
  • Utilize variables for sizes and colors defined in src/content-helper/common/css/variables.scss instead of hardcoding values."
src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.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/smart-linking/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/tabs/sidebar-tools-tab.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."
🔇 Additional comments (15)
src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.scss (2)

Line range hint 1-114: LGTM! Remember to use variables for colors

The changes look good and align well with the PR objectives. The SCSS structure is well-organized, and the use of variables and SCSS features is commendable.

As a general reminder, ensure that you're using variables for colors defined in src/content-helper/common/css/variables.scss instead of hardcoding values throughout the file.


24-26: 🛠️ Refactor suggestion

Convert pixel value to rem units using the to_rem function

The nested selector structure looks good. However, to adhere to the coding guidelines, please convert the pixel value to rem units using the to_rem function.

Apply this diff to convert the pixel value:

 .wp-parsely-excerpt-generator {
 	&.is-doc-set-panel {
-		margin-top: to_rem(20px);
+		margin-top: to_rem(20px);
 	}

Likely invalid or redundant comment.

src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.tsx (4)

5-5: LGTM: Imports are correctly added and follow standards.

The new imports are appropriately added and correctly sourced from their respective dependencies. They align with the WordPress coding standards and support the implementation of the new ExcerptDocumentSettingPanel component.

Also applies to: 7-7, 14-15, 17-17, 19-19


86-88: LGTM: Plugin render function updated correctly.

The ExcerptSuggestions function has been appropriately updated to use the new ExcerptDocumentSettingPanel component. This change aligns with the PR objectives and ensures that the excerpt suggestions feature is integrated into the PCH sidebar.


Line range hint 1-108: LGTM: Code structure and adherence to guidelines are excellent.

The overall structure of the file adheres to WordPress coding standards and best practices. JSDoc comments are present and include appropriate @SInCE tags. The implementation fulfills the PR objectives by successfully integrating the excerpt suggestions feature into the PCH sidebar.


Line range hint 1-108: Verify performance impact of the new panel.

While the implementation appears secure and generally performant, it would be beneficial to verify the performance impact of adding the new excerpt suggestions panel to the sidebar. Consider running performance tests to ensure that the addition doesn't significantly affect the editor's responsiveness, especially for posts with large content.

src/content-helper/editor-sidebar/smart-linking/component.tsx (2)

739-739: Approved: Improved code formatting.

The adjustment of the closing bracket improves code alignment and consistency without affecting functionality.


Line range hint 1-748: Verify compatibility with the latest WordPress version.

Ensure that all WordPress dependencies and functions used in this component are compatible with the latest WordPress version to avoid potential deprecation issues.

Run the following script to check for any deprecated functions or features:

src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx (7)

50-52: Proper definition of ExcerptSuggestionsPanelProps.

The isDocumentSettingPanel prop is correctly added as an optional boolean in the ExcerptSuggestionsPanelProps type.


58-60: JSDoc comments are updated appropriately.

The @since tag reflects the new version 3.17.0, and the documentation notes the renaming of the component and the addition of the isDocumentSettingPanel prop.


62-64: Component ExcerptSuggestionsPanel is correctly defined.

The component is exported with the new name and utilizes the isDocumentSettingPanel prop with a default value of false.


255-255: label prop is correctly assigned to textareaLabel.

The TextareaControl component properly uses the dynamic textareaLabel value.


310-310: Conditional rendering of generateWithParselyHeader is appropriate.

The header is correctly displayed when isDocumentSettingPanel is true, ensuring consistent UI in the document settings panel.


343-343: Repeated header rendering is acceptable.

Displaying generateWithParselyHeader here maintains consistency, showing the header above both the accept/discard buttons and the generate button.


365-375: Consistent use of documentation link for Parse.ly AI.

The href attribute correctly points to the excerpt generator documentation, matching the button's purpose.

Comment on lines +14 to +21
.editor-post-excerpt .excerpt-suggestions-text {
display: flex;
padding: to_rem(6px) 0 var(--grid-unit-20) 0;
flex-direction: column;
align-items: flex-start;
gap: to_rem(10px);
align-self: stretch;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Convert pixel values to rem units using the to_rem function

The class structure and use of flexbox look good. However, to adhere to the coding guidelines, please convert the pixel values to rem units using the to_rem function.

Apply this diff to convert pixel values:

 .editor-post-excerpt .excerpt-suggestions-text {
 	display: flex;
-	padding: to_rem(6px) 0 var(--grid-unit-20) 0;
+	padding: to_rem(6px) 0 var(--grid-unit-20) 0;
 	flex-direction: column;
 	align-items: flex-start;
-	gap: to_rem(10px);
+	gap: to_rem(10px);
 	align-self: stretch;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.editor-post-excerpt .excerpt-suggestions-text {
display: flex;
padding: to_rem(6px) 0 var(--grid-unit-20) 0;
flex-direction: column;
align-items: flex-start;
gap: to_rem(10px);
align-self: stretch;
}
.editor-post-excerpt .excerpt-suggestions-text {
display: flex;
padding: to_rem(6px) 0 var(--grid-unit-20) 0;
flex-direction: column;
align-items: flex-start;
gap: to_rem(10px);
align-self: stretch;
}

@@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { Panel, PanelBody } from '@wordpress/components';
import { PostTypeSupportCheck } from '@wordpress/editor';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update import path for PostTypeSupportCheck.

The PostTypeSupportCheck component should be imported from @wordpress/block-editor instead of @wordpress/editor to ensure compatibility with the latest version of WordPress and adherence to WordPress coding standards.

Apply this change:

-import { PostTypeSupportCheck } from '@wordpress/editor';
+import { PostTypeSupportCheck } from '@wordpress/block-editor';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { PostTypeSupportCheck } from '@wordpress/editor';
import { PostTypeSupportCheck } from '@wordpress/block-editor';

Comment on lines +64 to +85
{
permissions.ExcerptSuggestions &&
<PostTypeSupportCheck supportKeys="excerpt">
<PanelBody
title={ __( 'Excerpt Suggestions (Beta)', 'wp-parsely' ) }
initialOpen={ settings.ExcerptSuggestions.Open }
onToggle={ ( next ) => {
setSettings( {
ExcerptSuggestions: {
...settings.ExcerptSuggestions,
Open: next,
},
} );
trackToggle( 'excerpt_suggestions', next );
} }
>
<VerifyCredentials>
<ExcerptSuggestionsPanel />
</VerifyCredentials>
</PanelBody>
</PostTypeSupportCheck>
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

PostTypeSupportCheck Usage Detected Without Verified Imports

The PostTypeSupportCheck component is used in the following files:

  • src/content-helper/editor-sidebar/excerpt-suggestions/excerpt-suggestions.tsx
  • src/content-helper/editor-sidebar/tabs/sidebar-tools-tab.tsx

However, no corresponding import statements from @wordpress/block-editor were found. Please verify that PostTypeSupportCheck is correctly imported and compatible with the latest WordPress version.

🔗 Analysis chain

Ensure compatibility of PostTypeSupportCheck usage with the latest WordPress version.

Please verify that the PostTypeSupportCheck component and its usage are compatible with the latest version of WordPress, as there may have been changes to its API or location.

Run the following script to check all usages of PostTypeSupportCheck and confirm the correct import paths:

Review the results to ensure that PostTypeSupportCheck is imported correctly and used appropriately throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all import statements and usages of 'PostTypeSupportCheck'.

# Expected outcome: All imports should be from '@wordpress/block-editor', and usage should match the latest API.

# Find import statements
rg --type js "import.*PostTypeSupportCheck.*from '@wordpress/.+';" -A 0

# Find component usages
rg --type js "<PostTypeSupportCheck" -A 2

Length of output: 123


Script:

#!/bin/bash
# Description: Enhanced search for import statements and usages of 'PostTypeSupportCheck' and similar components.

# Search for import statements of any component containing 'PostTypeSupport'
rg --type js,ts,jsx,tsx "import.*PostTypeSupport.*from '@wordpress/.+';" -A 0

# Search for component usages of any component containing 'PostTypeSupport'
rg --type js,ts,jsx,tsx "<PostTypeSupport[^>]*" -A 2

Length of output: 216


Script:

#!/bin/bash
# Description: Corrected search for import statements and usages of 'PostTypeSupportCheck' and similar components.

# Search for import statements of any component containing 'PostTypeSupport'
rg --type js --type ts --type jsx --type tsx "import.*PostTypeSupport.*from '@wordpress/.+';" -A 0

# Search for component usages of any component containing 'PostTypeSupport'
rg --type js --type ts --type jsx --type tsx "<PostTypeSupport[^>]*" -A 2

Length of output: 238


Script:

#!/bin/bash
# Description: Search for import statements and usages of 'PostTypeSupportCheck' and similar components using glob patterns.

# Search for import statements of any component containing 'PostTypeSupport'
rg "<import.*PostTypeSupport.*from '@wordpress/[^']+'>" -g "*.{js,ts,jsx,tsx}" 

# Search for component usages of any component containing 'PostTypeSupport'
rg "<PostTypeSupport[^>]*" -g "*.{js,ts,jsx,tsx}"

Length of output: 376

Comment on lines +282 to +285
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt',
'wp-parsely',
) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unnecessary translation function from the URL.

URLs typically are not translated. Wrapping the href value with __() is unnecessary.

Apply this diff to fix the code:

- href={ __(
-     'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt',
-     'wp-parsely',
- ) }
+ href="https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt',
'wp-parsely',
) }
href="https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"

Comment on lines +238 to +245
href="https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta"
target="_blank"
variant="link"
>
{ __( 'Learn more about Parse.ly AI', 'wp-parsely' ) }
<Icon icon={ external } size={ 18 } className="parsely-external-link-icon" />
</Button>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the documentation link in the href attribute.

The href attribute points to an unrelated section (#h-smart-linking-beta). It should link to the Parse.ly AI or excerpt generator documentation to match the button text.

Apply this diff to update the link:

- href="https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta"
+ href="https://docs.parse.ly/plugin-content-helper/#h-excerpt-generator-beta"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
href="https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta"
target="_blank"
variant="link"
>
{ __( 'Learn more about Parse.ly AI', 'wp-parsely' ) }
<Icon icon={ external } size={ 18 } className="parsely-external-link-icon" />
</Button>
</div>
href="https://docs.parse.ly/plugin-content-helper/#h-excerpt-generator-beta"
target="_blank"
variant="link"
>
{ __( 'Learn more about Parse.ly AI', 'wp-parsely' ) }
<Icon icon={ external } size={ 18 } className="parsely-external-link-icon" />
</Button>
</div>

Comment on lines +227 to +231
let textareaLabel = __( 'Excerpt', 'wp-parsely' );
if ( isDocumentSettingPanel ) {
textareaLabel = __( 'Write an excerpt (optional)', 'wp-parsely' );
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplify textareaLabel assignment using a ternary operator.

To enhance readability and use const instead of let, consider assigning textareaLabel with a ternary operator:

Apply this diff to streamline the code:

- let textareaLabel = __( 'Excerpt', 'wp-parsely' );
- if ( isDocumentSettingPanel ) {
-     textareaLabel = __( 'Write an excerpt (optional)', 'wp-parsely' );
- }
+ const textareaLabel = isDocumentSettingPanel
+     ? __( 'Write an excerpt (optional)', 'wp-parsely' )
+     : __( 'Excerpt', 'wp-parsely' );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let textareaLabel = __( 'Excerpt', 'wp-parsely' );
if ( isDocumentSettingPanel ) {
textareaLabel = __( 'Write an excerpt (optional)', 'wp-parsely' );
}
const textareaLabel = isDocumentSettingPanel
? __( 'Write an excerpt (optional)', 'wp-parsely' )
: __( 'Excerpt', 'wp-parsely' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant