Skip to content

[8329] Do not show insert icon in RTE Insert Media and Insert Video when no datasource is configured#4812

Open
jvega190 wants to merge 3 commits intocraftercms:developfrom
jvega190:enhancement/8329
Open

[8329] Do not show insert icon in RTE Insert Media and Insert Video when no datasource is configured#4812
jvega190 wants to merge 3 commits intocraftercms:developfrom
jvega190:enhancement/8329

Conversation

@jvega190
Copy link
Member

@jvega190 jvega190 commented Feb 19, 2026

craftercms/craftercms#8329

Summary by CodeRabbit

  • New Features

    • Added an "Add Media" configuration option to the Rich Text Editor to enable or disable media upload controls.
  • Improvements

    • Updated no-data-sources message to clearly instruct users to contact their administrator for setup.
    • When Add Media is disabled, the editor will hide/disable media upload UI for a cleaner experience.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds an addMedia configuration for the Rich Text Editor, plus a new validation key and mapping; updates content-type processing to emit the addMedia validation; guest RTE now conditionally enables TinyMCE's media picker based on that flag. Also revises an admin-facing "no data sources" message.

Changes

Cohort / File(s) Summary
Admin messages & descriptor
ui/app/src/assets/guestMessages.ts, ui/app/src/components/ContentTypeManagement/descriptors/controls/rte.ts
Updated the default admin-facing "no data sources" message; added an addMedia field to the RTE descriptor and included it in the Options section.
Types & mappings
ui/app/src/models/ContentType.ts, ui/app/src/utils/contentType.ts
Extended ValidationKeys to include 'addMedia'; added addMedia entry to systemValidationsKeysMap.
Content type processing
ui/app/src/services/contentTypes.ts
Added handling to convert the addMedia descriptor field into a validation entry when building data-source validations; imported ValidationKeys.
Guest RTE behavior
ui/guest/src/controls/rte.ts
Reads validations.addMedia (defaults true) and conditionally enables/disables TinyMCE's file_picker_callback (disables media insertion when false).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • rart
  • sumerjabri
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The description only contains a GitHub issue link without elaborating on the changes, objectives, or implementation details as expected by the template. Expand the description to explain what changes were made, why they were necessary, and how they address the issue beyond just linking to it.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: hiding the insert icon in RTE media controls when no datasource is configured, which matches the implementation across all modified files.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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)
ui/guest/src/controls/rte.ts (1)

164-165: Nit: comment wording is slightly misleading.

The comment says "if the allowAddMedia validation is set to false", but the callback is also null when validations.addMedia is entirely absent (which is the common case for legacy configs). If you apply the fix above this becomes moot; otherwise the comment should read something like "…or when the addMedia validation is absent."

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

In `@ui/guest/src/controls/rte.ts` around lines 164 - 165, The comment for
file_picker_callback: allowAddMedia is misleading about when the callback is
null; update the comment near the file_picker_callback assignment (and any
reference to allowAddMedia) to state that the callback will be unset either when
validations.addMedia is explicitly false or when the addMedia validation is
absent (legacy configs), so the UI won't show add media/file options in both
cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/guest/src/controls/rte.ts`:
- Line 117: The current ternary sets allowAddMedia to false whenever
validations.addMedia is missing, causing older RTEs with datasources to lose the
media picker; change the logic so that if validations exists but
validations.addMedia is undefined you default allowAddMedia to true, and only
set it false when validations is absent or validations.addMedia.value is
explicitly false. Update the calculation of allowAddMedia (the const named
allowAddMedia used to decide file_picker_callback and the media button
visibility) accordingly so imageManager/videoManager/etc. remain usable for
legacy content types.

---

Nitpick comments:
In `@ui/guest/src/controls/rte.ts`:
- Around line 164-165: The comment for file_picker_callback: allowAddMedia is
misleading about when the callback is null; update the comment near the
file_picker_callback assignment (and any reference to allowAddMedia) to state
that the callback will be unset either when validations.addMedia is explicitly
false or when the addMedia validation is absent (legacy configs), so the UI
won't show add media/file options in both cases.

@jvega190 jvega190 marked this pull request as ready for review February 19, 2026 19:50
@jvega190 jvega190 requested a review from rart as a code owner February 19, 2026 19:50
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

Comments