Skip to content

Wired up alpha button style setting #23343

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

Merged
merged 1 commit into from
May 14, 2025
Merged

Conversation

kevinansfield
Copy link
Member

ref https://linear.app/ghost/issue/PROD-1717

  • copied style setting from prototype to alpha newsletter details modal
  • updated EmailRenderer data fetching/passthrough to include setting
    • can be used with {{#if hasOutlineButtons}} in the main template/partials where we don't have string matching available in handlebars
    • full setting value is passed through to cards under the design.buttonStyle option

ref https://linear.app/ghost/issue/PROD-1717

- copied style setting from prototype to alpha newsletter details modal
- updated EmailRenderer data fetching/passthrough to include setting
  - can be used with `{{#if hasOutlineButtons}}` in the main template/partials where we don't have string matching available in handlebars
  - full setting value is passed through to cards under the `design.buttonStyle` option
Copy link
Contributor

coderabbitai bot commented May 14, 2025

Walkthrough

This change introduces a new UI control in the newsletter settings sidebar that allows users to select the button style ("Fill" or "Outline") for newsletters. The selected style is stored in the newsletter's button_style property and is integrated into the design options for email rendering. The email rendering logic is updated to support this new property, making the button style available in the template data for rendering emails. The unit tests are refactored and expanded to cover the new button_style property, ensuring correct propagation and template data handling.

Possibly related PRs

Suggested labels

migration

Suggested reviewers

  • lsinger
  • ErisDS

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.31.1)
ghost/core/test/unit/server/services/email-service/email-renderer.test.js
🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalAlpha.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/apps/admin-x-settings".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in "apps/admin-x-settings/.eslintrc.cjs".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 915b52e and fa0dd21.

📒 Files selected for processing (3)
  • apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalAlpha.tsx (1 hunks)
  • ghost/core/core/server/services/email-service/EmailRenderer.js (3 hunks)
  • ghost/core/test/unit/server/services/email-service/email-renderer.test.js (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
ghost/core/core/server/services/email-service/EmailRenderer.js (2)
ghost/core/test/unit/server/services/email-service/email-renderer.test.js (16)
  • newsletter (100-100)
  • newsletter (359-359)
  • newsletter (933-936)
  • newsletter (942-945)
  • newsletter (951-954)
  • newsletter (961-964)
  • newsletter (1000-1004)
  • newsletter (1011-1015)
  • newsletter (1023-1027)
  • newsletter (1033-1037)
  • newsletter (1043-1047)
  • newsletter (1284-1290)
  • newsletter (1304-1310)
  • newsletter (1359-1365)
  • newsletter (1399-1401)
  • newsletter (1433-1435)
ghost/core/test/unit/server/services/email-service/email-helpers.test.js (10)
  • labs (19-23)
  • labs (40-44)
  • labs (65-69)
  • labs (90-94)
  • labs (108-112)
  • labs (133-137)
  • labs (152-156)
  • labs (169-173)
  • labs (186-190)
  • labs (203-207)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Lint
🔇 Additional comments (9)
apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalAlpha.tsx (1)

406-430: Implementation of button style setting looks good!

The button style control is well-implemented, following the same pattern as other UI controls in this file. The approach correctly:

  • Uses consistent ButtonGroup component with appropriate icons and tooltips
  • Properly handles the default style ('fill')
  • Correctly updates the newsletter settings when a style is selected
ghost/core/core/server/services/email-service/EmailRenderer.js (3)

327-329: Successfully extended design options with button styling

This change correctly passes both the button corners and button style to the renderer, enabling consistent styling across email components.


1000-1003: Correctly implemented hasOutlineButtons flag

The implementation properly:

  • Creates a boolean flag for template usage
  • Checks for the required lab feature (emailCustomizationAlpha)
  • Only sets the flag to true when button style is explicitly 'outline'

This approach enables the use of {{#if hasOutlineButtons}} conditionals in Handlebars templates as mentioned in the PR objectives.


1158-1158: Successfully exposed the flag to templates

Adding the hasOutlineButtons flag to the template data makes it available for use in the email templates, allowing for conditional styling based on the selected button style.

ghost/core/test/unit/server/services/email-service/email-renderer.test.js (5)

2097-2098: New button_style property added to newsletter model.

The test is now including the new button_style: 'outline' property in the newsletter model, which will be used to test the email renderer's handling of different button styles.


2112-2113: Verification of button style properties passed to lexical renderer.

Good addition to verify that both buttonCorners and buttonStyle properties are correctly passed to the lexical renderer in the design options object.


2553-2571: Well-designed generic helper for testing template data properties.

This new testDataProperty function is a good refactoring that abstracts the testing of newsletter settings against expected template data properties. It makes the code more maintainable and will simplify adding tests for new newsletter properties in the future.


2573-2577: Refactored testButtonBorderRadius to use new generic helper.

Good refactoring to use the new generic testDataProperty helper, making the code more concise and consistent.


2595-2611: Comprehensive testing of hasOutlineButtons property.

The new testHasOutlineButtons helper function thoroughly tests all cases for the button style setting:

  • nullhasOutlineButtons: false
  • 'fill'hasOutlineButtons: false
  • 'outline'hasOutlineButtons: true

This ensures proper template behavior based on the newsletter's button style setting.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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

Successfully merging this pull request may close these issues.

1 participant