[8329] Do not show insert icon in RTE Insert Media and Insert Video when no datasource is configured#4812
[8329] Do not show insert icon in RTE Insert Media and Insert Video when no datasource is configured#4812jvega190 wants to merge 3 commits intocraftercms:developfrom
Conversation
…hen no datasource is configured
|
No actionable comments were generated in the recent review. 🎉 WalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
nullwhenvalidations.addMediais 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.
…ds compatibility.
craftercms/craftercms#8329
Summary by CodeRabbit
New Features
Improvements