Skip to content

feat: add show author option to portal settings and update related views#225

Merged
gabrieljablonski merged 3 commits intomainfrom
gabrieljablonski/feat-faq-show-author
Feb 26, 2026
Merged

feat: add show author option to portal settings and update related views#225
gabrieljablonski merged 3 commits intomainfrom
gabrieljablonski/feat-faq-show-author

Conversation

@gabrieljablonski
Copy link
Member

@gabrieljablonski gabrieljablonski commented Feb 26, 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
    • Added "Show Author" toggle in Help Center portal settings to control whether article authors appear on category pages and category views
    • Administrators can now manage author visibility at the portal level, with author information conditionally displayed throughout the help center based on this setting

@gabrieljablonski gabrieljablonski self-assigned this Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 17:10
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 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.

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
📝 Walkthrough

Walkthrough

The changes introduce a "Show Author" feature that allows portal administrators to toggle whether article authors are displayed on category pages. This involves backend config handling, frontend UI components, API updates, conditional view rendering, and localization.

Changes

Cohort / File(s) Summary
Backend Configuration & Model
app/controllers/api/v1/accounts/portals_controller.rb, app/models/portal.rb
Adds merged_portal_params helper method for proper config merging, extends CONFIG_JSON_KEYS with show_author, and introduces show_author? instance method that returns true when not explicitly false.
Frontend UI & Internationalization
app/javascript/dashboard/components-next/.../PortalBaseSettings.vue, app/javascript/dashboard/i18n/locale/en/helpCenter.json, app/javascript/dashboard/i18n/locale/pt_BR/helpCenter.json
Adds new Switch component toggle for "Show Author" with state initialization from portal config, includes label and helper text. Provides English and Portuguese translations for the new UI option.
API Response & View Templates
app/views/api/v1/accounts/portals/_portal.json.jbuilder, app/views/public/api/v1/portals/_category-block.html.erb, app/views/public/api/v1/portals/categories/_category-hero.html.erb
Adds show_author field to JSON config output and conditionally renders author information blocks in category views based on @portal.show_author?.
Tests
spec/controllers/api/v1/accounts/portals_controller_spec.rb
Updates portal update endpoint test to expect show_author: true in the config response.

Sequence Diagram

sequenceDiagram
    actor User
    participant Frontend as Frontend UI<br/>(Vue Component)
    participant API as Backend API<br/>(PortalsController)
    participant Model as Portal Model
    participant DB as Database
    participant Views as Public Views

    User->>Frontend: Toggle "Show Author" switch
    Frontend->>API: PUT /portals/{slug} with config:{show_author: boolean}
    API->>API: merged_portal_params()<br/>merges new config with<br/>existing `@portal.config`
    API->>Model: update(merged_portal_params)
    Model->>DB: persist merged config
    DB-->>Model: confirmation
    Model->>API: updated portal instance
    API->>API: render portal.json<br/>includes show_author field
    API-->>Frontend: JSON response with config
    Frontend-->>User: UI updated
    
    User->>Views: Visit category page
    Views->>Model: check `@portal.show_author`?
    alt show_author is true
        Views->>Views: Render authors block
    else show_author is false
        Views->>Views: Skip authors block
    end
    Views-->>User: Display category with/without authors
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A toggle for authors, now finally shown,
Through configs and views, the feature's been sown,
From Vue to the model, translations aligned,
Category pages with choice redesigned! ✨

🚥 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 clearly and specifically describes the main feature: adding a show author option to portal settings and updating related views.

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

✨ 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-faq-show-author

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.

@gabrieljablonski
Copy link
Member Author

@coderabbitai preview

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@gabrieljablonski I'll fetch the details of this PR to provide you with a preview.


🏁 Script executed:

#!/bin/bash
# Get PR details
gh pr view 225 --json title,body,state,author,additions,deletions,changedFiles,files

# Get the diff
gh pr diff 225

Length of output: 11855


@gabrieljablonski Here's a preview of PR #225:

📋 Overview

Feature: Add "Show Author" option to portal settings

Stats: 9 files changed (+47/-4 lines)

🎯 What This PR Does

This PR adds a new configuration option that allows portal administrators to control whether article author information is displayed on category pages in the help center.

🔧 Key Changes

Backend (Ruby/Rails)

  • Portal Controller (portals_controller.rb):

    • Added show_author to permitted config parameters
    • Implemented merged_portal_params method to properly merge config updates without overwriting existing settings
  • Portal Model (portal.rb):

    • Added show_author to CONFIG_JSON_KEYS
    • Created show_author? helper method (defaults to true)
  • API Response (_portal.json.jbuilder):

    • Exposed show_author setting in portal JSON responses

Frontend (Vue.js)

  • Portal Settings (PortalBaseSettings.vue):

    • Added Switch component for toggling author visibility
    • Integrated with form state management
    • Defaults to true (show authors)
  • Internationalization:

    • Added translations for English and Portuguese (Brazil)
    • Label: "Show article authors"
    • Help text: "Display author information on category pages"

View Templates (ERB)

  • Category Block & Hero (_category-block.html.erb, _category-hero.html.erb):
    • Conditionally render author information based on @portal.show_author?
    • Preserves existing UI structure when enabled

Tests

  • Updated controller specs to verify the new show_author config option

✨ Default Behavior

Author information is shown by default (show_author: true), maintaining backward compatibility with existing portals.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new portal setting to control whether article authors are displayed on public help center category pages, exposing the flag via the accounts portal API and wiring it into the dashboard settings UI.

Changes:

  • Introduces show_author as a portal config flag (defaulting to enabled) and exposes it in the portal JSON config.
  • Adds a dashboard toggle (with en/pt-BR copy) to update config.show_author.
  • Updates public category views to conditionally render the authors block based on the portal setting.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/models/portal.rb Adds show_author to allowed config keys and defines show_author? default behavior.
app/controllers/api/v1/accounts/portals_controller.rb Permits config.show_author and merges config updates to avoid overwriting other config keys.
app/views/api/v1/accounts/portals/_portal.json.jbuilder Includes show_author inside the config payload.
app/views/public/api/v1/portals/categories/_category-hero.html.erb Conditionally renders authors section based on the portal flag.
app/views/public/api/v1/portals/_category-block.html.erb Conditionally renders authors section based on the portal flag.
app/javascript/dashboard/components-next/HelpCenter/Pages/PortalSettingsPage/PortalBaseSettings.vue Adds a switch to edit config.show_author and initializes it from API payload.
app/javascript/dashboard/i18n/locale/en/helpCenter.json Adds English label/help text for the new toggle.
app/javascript/dashboard/i18n/locale/pt_BR/helpCenter.json Adds pt-BR label/help text for the new toggle.
spec/controllers/api/v1/accounts/portals_controller_spec.rb Updates expectation to include config.show_author in the response.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

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

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: 2

🧹 Nitpick comments (1)
spec/controllers/api/v1/accounts/portals_controller_spec.rb (1)

134-135: Consider adding a negative-path assertion for show_author: false.

This expectation covers the default path, but a companion update test with config: { show_author: false } would protect the new toggle behavior end-to-end.

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

In `@spec/controllers/api/v1/accounts/portals_controller_spec.rb` around lines 134
- 135, Add a negative-path spec that exercises the toggle when config: {
show_author: false } and asserts the controller response contains 'show_author'
=> false; specifically, in
spec/controllers/api/v1/accounts/portals_controller_spec.rb add a test case
(mirroring the existing positive case) that builds the request payload with
config: { 'show_author' => false }, calls the same action (the example that
currently returns the hash with 'show_author' => true) and expects the parsed
response JSON to include 'show_author' => false to ensure the toggle is honored
end-to-end.
🤖 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/controllers/api/v1/accounts/portals_controller.rb`:
- Around line 86-89: In merged_portal_params, guard against `@portal.config` being
nil before calling merge: when update_params has a 'config' key, merge the
incoming config into a safe hash derived from `@portal.config` (e.g. use
(`@portal.config` || {}).merge(update_params['config']) or
`@portal.config.to_h.merge`(...)) so the method never calls merge on nil; update
the logic in merged_portal_params to use that safe fallback.

In `@app/models/portal.rb`:
- Around line 49-51: The show_author? method currently only checks for literal
false and misinterprets string values like "false"; update show_author? to
coerce config['show_author'] into a real boolean before comparing (e.g., use
ActiveModel::Type::Boolean.new.cast or similar) so values like "false" or "0"
are treated as false; reference the show_author? method and
config['show_author'] key when making the change so the method reliably returns
a boolean regardless of whether the config value came from the frontend, API, or
raw SQL.

---

Nitpick comments:
In `@spec/controllers/api/v1/accounts/portals_controller_spec.rb`:
- Around line 134-135: Add a negative-path spec that exercises the toggle when
config: { show_author: false } and asserts the controller response contains
'show_author' => false; specifically, in
spec/controllers/api/v1/accounts/portals_controller_spec.rb add a test case
(mirroring the existing positive case) that builds the request payload with
config: { 'show_author' => false }, calls the same action (the example that
currently returns the hash with 'show_author' => true) and expects the parsed
response JSON to include 'show_author' => false to ensure the toggle is honored
end-to-end.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c026ee2 and 092c10c.

📒 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/public/api/v1/portals/_category-block.html.erb
  • app/views/public/api/v1/portals/categories/_category-hero.html.erb
  • spec/controllers/api/v1/accounts/portals_controller_spec.rb

@gabrieljablonski gabrieljablonski merged commit 21007bd into main Feb 26, 2026
1 check passed
@gabrieljablonski gabrieljablonski deleted the gabrieljablonski/feat-faq-show-author branch February 26, 2026 17:32
@coderabbitai coderabbitai bot mentioned this pull request Mar 9, 2026
12 tasks
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.

2 participants