Skip to content

Added element and typography newsletter setting columns #23347

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 15, 2025

Conversation

kevinansfield
Copy link
Member

ref https://linear.app/ghost/issue/PROD-1684
ref https://linear.app/ghost/issue/PROD-1729
ref https://linear.app/ghost/issue/PROD-1725

  • adds newsletter columns ready for additional design settings to be implemented

Copy link
Contributor

coderabbitai bot commented May 14, 2025

## Walkthrough

This change introduces three new non-nullable string columns—`title_font_weight`, `link_style`, and `image_corners`—to the `newsletters` table, with associated default values and allowed value constraints defined in both the database migration and schema. The `Newsletter` model is updated to include default values for these new properties. The UI component for newsletter settings is updated to change the "Image corners" option from "Squircle" to "Rounded," modifying the key, label, tooltip, and value accordingly. The schema integrity test hash is updated to reflect these changes.

## Possibly related PRs

- TryGhost/Ghost#23190: Updates the "Image corners" control in the newsletter settings UI, directly related to the changes in button key and label for this control.
- TryGhost/Ghost#23322: Adds new styling-related columns to the `newsletters` table and updates newsletter model defaults, contextually related through similar schema and model modifications.

## 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.

🔧 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/NewsletterDetailModalPrototype.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.

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ 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.

✨ 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.

@github-actions github-actions bot added the migration [pull request] Includes migration for review label May 14, 2025
Copy link
Contributor

It looks like this PR contains a migration 👀
Here's the checklist for reviewing migrations:

General requirements

  • ⚠️ Tested on the staging database servers
  • Satisfies idempotency requirement (both up() and down())
  • Does not reference models
  • Filename is in the correct format (and correctly ordered)
  • Targets the next minor version
  • All code paths have appropriate log messages
  • Uses the correct utils
  • Contains a minimal changeset
  • Does not mix DDL/DML operations
  • Tested in MySQL and SQLite

Schema changes

  • Both schema change and related migration have been implemented
  • For index changes: has been performance tested for large tables
  • For new tables/columns: fields use the appropriate predefined field lengths
  • For new tables/columns: field names follow the appropriate conventions
  • Does not drop a non-alpha table outside of a major version

Data changes

  • Mass updates/inserts are batched appropriately
  • Does not loop over large tables/datasets
  • Defends against missing or invalid data
  • For settings updates: follows the appropriate guidelines

@kevinansfield kevinansfield force-pushed the newsletter-settings-migrations branch from 2ed0a9e to a5e7f2a Compare May 15, 2025 08:43
@kevinansfield kevinansfield changed the title Added element and typograhpy newsletter setting columns Added element and typography newsletter setting columns May 15, 2025
@kevinansfield kevinansfield requested a review from lsinger May 15, 2025 08:44
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: 0

🧹 Nitpick comments (2)
ghost/core/core/server/data/migrations/versions/5.120/2025-05-14-20-00-15-add-newsletters-setting-columns.js (2)

3-22: Migration looks good but consider adding database-level constraints for values.

The migration adds three new columns to the newsletters table with appropriate defaults and types. The non-transactional approach is a good choice for adding columns to potentially large tables.

While the schema validation constraints (as mentioned in the AI summary) will enforce value restrictions at the application level, consider adding CHECK constraints at the database level for additional data integrity protection.

For example, you could add CHECK constraints to ensure the columns only accept valid values:

 createAddColumnMigration('newsletters', 'title_font_weight', {
     type: 'string',
     maxlength: 50,
     nullable: false,
     defaultTo: 'bold'
+    // Add CHECK constraint: check (title_font_weight in ('normal', 'medium', 'semibold', 'bold'))
 }),

Note: The actual syntax for CHECK constraints would depend on your database system (MySQL, PostgreSQL, etc.).


1-22: Consider adding migration tests to verify column creation.

The migration appears well-structured, but it would be valuable to have tests that verify these columns are correctly created with their default values and constraints.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed0a9e and a5e7f2a.

⛔ Files ignored due to path filters (2)
  • ghost/core/test/e2e-api/admin/__snapshots__/members.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/newsletters.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalPrototype.tsx (1 hunks)
  • ghost/core/core/server/data/migrations/versions/5.120/2025-05-14-20-00-15-add-newsletters-setting-columns.js (1 hunks)
  • ghost/core/core/server/data/schema/schema.js (1 hunks)
  • ghost/core/core/server/models/newsletter.js (1 hunks)
  • ghost/core/test/unit/server/data/schema/integrity.test.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • ghost/core/core/server/models/newsletter.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalPrototype.tsx
  • ghost/core/test/unit/server/data/schema/integrity.test.js
  • ghost/core/core/server/data/schema/schema.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup
🔇 Additional comments (2)
ghost/core/core/server/data/migrations/versions/5.120/2025-05-14-20-00-15-add-newsletters-setting-columns.js (2)

1-2: Utility functions are appropriately imported for migration operations.

The code imports necessary utility functions to help with non-transactional migrations and column creation, following Ghost's established patterns for database migrations.


16-21: Verify UI component alignment for "image_corners" value changes.

According to the AI summary, the UI was updated to change "squircle" to "rounded", yet the default value here is "square". Ensure the UI component correctly handles both potential values and that this change is documented for any existing integrations.

Copy link
Contributor

@lsinger lsinger left a comment

Choose a reason for hiding this comment

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

LGTM! 🚢

Please make sure to create an issue to rename the icons (icon: 'squircle', in apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalPrototype.tsx; and as you said on Slack the same is true for button corners). Let's keep this PR focused on getting the migrations shipped, though.

@kevinansfield kevinansfield merged commit 3d72f15 into main May 15, 2025
24 checks passed
@kevinansfield kevinansfield deleted the newsletter-settings-migrations branch May 15, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration [pull request] Includes migration for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants