Skip to content

feat: add custom HTML fields for portals#233

Merged
gabrieljablonski merged 1 commit intomainfrom
gabrieljablonski/feat-portal-custom-code
Mar 9, 2026
Merged

feat: add custom HTML fields for portals#233
gabrieljablonski merged 1 commit intomainfrom
gabrieljablonski/feat-portal-custom-code

Conversation

@gabrieljablonski
Copy link
Member

@gabrieljablonski gabrieljablonski commented Mar 9, 2026

Pull Request Template

Description

Please include a summary of the change and issue(s) fixed. Also, mention relevant motivation, context, and any dependencies that this change requires.
Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

This change is Reviewable

Summary by CodeRabbit

Release Notes

  • New Features
    • Portal administrators can now inject custom HTML code into the head and body sections of their portal pages
    • New editable "Custom Head HTML" and "Custom Body HTML" fields added to portal settings
    • Custom content renders on published portals (excluding plain layouts)

@gabrieljablonski gabrieljablonski self-assigned this Mar 9, 2026
@gabrieljablonski
Copy link
Member Author

@coderabbitai review

@codex review

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

@gabrieljablonski Sure! I'll review the changes in this PR now.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 254bd23e-f11b-496f-aec0-0e05afbf4d4c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gabrieljablonski/feat-portal-custom-code

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

This pull request adds custom HTML injection support to portals. Changes include database schema extensions for two new text fields (custom_head_html and custom_body_html), backend parameter whitelisting and validation, frontend form UI for editing, API serialization, portal layout template rendering logic, and internationalization strings.

Changes

Cohort / File(s) Summary
Database Schema & Migration
db/migrate/20260309131532_add_custom_html_to_portals.rb, db/schema.rb
Adds two new text columns (custom_head_html, custom_body_html) to portals table and updates schema version.
Backend Model & Validation
app/models/portal.rb
Adds length validations (max 15,000 characters) for the two new custom HTML attributes.
API Controller & Response
app/controllers/api/v1/accounts/portals_controller.rb, app/views/api/v1/accounts/portals/_portal.json.jbuilder
Whitelists new attributes in portal_params and includes them in JSON serialization.
Frontend UI & Component State
app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue
Adds form fields for editing custom HTML, state management for the new attributes, and emits them in portal update payload.
Internationalization
app/javascript/dashboard/i18n/locale/en/helpCenter.json, app/javascript/dashboard/i18n/locale/pt_BR/helpCenter.json
Adds translation keys for labels, placeholders, and helper text for both custom HTML fields in English and Portuguese Brazilian locales.
Portal Layout Rendering
app/views/layouts/portal.html.erb
Conditionally injects custom HTML into page head and body when present and layout is not plain, using .html_safe.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Whiskers twitch with portal glee,
Custom HTML, wild and free!
Head and body, inject with care,
Pretty portals everywhere!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add custom HTML fields for portals' directly and clearly summarizes the main change in the changeset, which adds custom_head_html and custom_body_html fields across the database, API, UI, and locale files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gabrieljablonski/feat-portal-custom-code

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 622594cabb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@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: 1

🧹 Nitpick comments (1)
app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue (1)

363-410: Consider extracting the duplicated custom-HTML field block.

Both sections only vary by binding and i18n key prefix. A small config-driven render or subcomponent would keep future validation or accessibility tweaks in one place.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue`
around lines 363 - 410, The two duplicated textarea blocks in
PortalBaseSettings.vue (bound to state.customHeadHtml and state.customBodyHtml
and using i18n keys HELP_CENTER.PORTAL_SETTINGS.FORM.CUSTOM_HEAD_HTML /
CUSTOM_BODY_HTML) should be consolidated: extract them into a single reusable
subcomponent (e.g., CustomHtmlField) or a small render helper that accepts props
for the v-model key and the i18n prefix, then replace both blocks with that
component/call; ensure the new component forwards the v-model, placeholder,
rows, classes, and help text so future validation or accessibility changes are
made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue`:
- Around line 372-403: The two unbounded textareas bound to state.customHeadHtml
and state.customBodyHtml in PortalBaseSettings.vue need a client-side size cap
to mirror the server-side limit: add maxlength attributes to both textarea
elements (using the same max bytes/characters enforced by the server) and
implement a simple inline counter/error bound to those model values (e.g.,
computed remainingChars or isOverLimit) to display remaining characters and a
validation message preventing submit when exceeded; update any submit
handler/validation method (the form submit or save routine in this component) to
check the same limit before sending to the server.

---

Nitpick comments:
In
`@app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue`:
- Around line 363-410: The two duplicated textarea blocks in
PortalBaseSettings.vue (bound to state.customHeadHtml and state.customBodyHtml
and using i18n keys HELP_CENTER.PORTAL_SETTINGS.FORM.CUSTOM_HEAD_HTML /
CUSTOM_BODY_HTML) should be consolidated: extract them into a single reusable
subcomponent (e.g., CustomHtmlField) or a small render helper that accepts props
for the v-model key and the i18n prefix, then replace both blocks with that
component/call; ensure the new component forwards the v-model, placeholder,
rows, classes, and help text so future validation or accessibility changes are
made in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a4e200f0-4503-4e40-bb46-92085fc03918

📥 Commits

Reviewing files that changed from the base of the PR and between 0fd008f and 622594c.

📒 Files selected for processing (9)
  • app/controllers/api/v1/accounts/portals_controller.rb
  • app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue
  • app/javascript/dashboard/i18n/locale/en/helpCenter.json
  • app/javascript/dashboard/i18n/locale/pt_BR/helpCenter.json
  • app/models/portal.rb
  • app/views/api/v1/accounts/portals/_portal.json.jbuilder
  • app/views/layouts/portal.html.erb
  • db/migrate/20260309131532_add_custom_html_to_portals.rb
  • db/schema.rb

@gabrieljablonski gabrieljablonski merged commit eaac65c into main Mar 9, 2026
2 checks passed
@gabrieljablonski gabrieljablonski deleted the gabrieljablonski/feat-portal-custom-code branch March 9, 2026 14:47
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