Skip to content

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

Merged
sumerjabri merged 3 commits intocraftercms:developfrom
jvega190:enhancement/8329
Mar 13, 2026
Merged

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

Conversation

@jvega190
Copy link
Copy Markdown
Member

@jvega190 jvega190 commented Feb 19, 2026

craftercms/craftercms#8329

  • Added a control prop to enable/disable adding media
  • Updated no datasources message to No data sources are configured for this editor. Please contact your administrator to complete this configuration.

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
Copy Markdown

coderabbitai Bot commented Feb 19, 2026

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 | ✅ 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
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.
Description check ✅ Passed The PR description includes a ticket reference and lists key changes, but lacks detail about the implementation approach and rationale.

✏️ 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

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.

Copy link
Copy Markdown

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

Comment thread ui/guest/src/controls/rte.ts Outdated
@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
@sumerjabri sumerjabri merged commit 8e4cc69 into craftercms:develop Mar 13, 2026
3 of 4 checks passed
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.

3 participants