feat(external-sources): pass top level origin to the sources iframe
Description
Checklist
- [ ] Tests (if applicable)
- [ ] Documentation (if applicable)
- [ ] Changelog stub (or use conventional commit messages)
Summary by CodeRabbit
- New Features
- Enhanced iframe integration by sending the top-level origin to the embedded content for improved context awareness.
- Bug Fixes
- Added safeguards to reliably determine and communicate the top-level origin, even in cross-origin scenarios.
Walkthrough
This change introduces a mapping for external upload source types to alternative string identifiers, updates the construction of remote URLs to use these mappings and includes the top-level origin, and adds a utility for retrieving the top-level origin. It also adds a new localization key for "ngdrive" across multiple languages and renames an SVG icon ID to match the new identifier.
Changes
| File(s) | Change Summary |
|---|---|
| blocks/ExternalSource/ExternalSource.js | Added SOCIAL_SOURCE_MAPPING for source type remapping; updated remote URL construction to use mapping and top-level origin; added reactive toolbarVisible state and handler for toolbar-state-change messages. |
| utils/get-top-level-origin.js | Introduced getTopLevelOrigin utility to retrieve the top-level window's origin with cross-origin fallback. |
| blocks/themes/uc-basic/svg-sprite.js | Renamed SVG symbol ID from uc-icon-gdrive to uc-icon-ngdrive. |
| blocks/Config/initialConfig.js | Added new config property topLevelOrigin with default empty string. |
| blocks/Config/normalizeConfigValue.js | Added normalization for topLevelOrigin config property using asString. |
| blocks/ExternalSource/MessageBridge.js | Enabled TypeScript checking; extended MESSAGE_TYPE_WHITELIST to include 'toolbar-state-change'. |
| blocks/ExternalSource/types.js | Added new message type 'toolbar-state-change' with boolean isVisible field to InputMessageMap typedef. |
| types/exported.d.ts | Added topLevelOrigin: string property to ConfigType type definition. |
| locales/file-uploader/ar.js, az.js, ca.js, cs.js, da.js, de.js, el.js, en.js, es.js, et.js, | Added localization key 'src-type-ngdrive': 'Google Drive' to each respective language file. |
| fi.js, fr.js, he.js, hy.js, is.js, it.js, ja.js, ka.js, kk.js, ko.js, lv.js, nb.js, nl.js, | |
| pl.js, pt.js, ro.js, ru.js, sk.js, sr.js, sv.js, tr.js, uk.js, vi.js, zh-TW.js, zh.js |
Sequence Diagram(s)
sequenceDiagram
participant User
participant ExternalSource
participant getTopLevelOrigin
User->>ExternalSource: Select external source (e.g., GDRIVE)
ExternalSource->>getTopLevelOrigin: Retrieve top-level origin
getTopLevelOrigin-->>ExternalSource: Return origin (with fallback if cross-origin)
ExternalSource->>ExternalSource: Map source type via SOCIAL_SOURCE_MAPPING
ExternalSource->>ExternalSource: Construct remote URL with mapped type and origin
ExternalSource-->>User: Load external source iframe with constructed URL
Possibly related PRs
- uploadcare/file-uploader#746: Both PRs modify
blocks/themes/uc-basic/svg-sprite.jsconcerning SVG icon definitions, with this PR renaming a symbol ID and the related PR replacing the entire SVG sprite content to address icon leakage.
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
npm error Exit handler never called! npm error This is an error with npm itself. Please report this error at: npm error https://github.com/npm/cli/issues npm error A complete log of this run can be found in: /.npm/_logs/2025-06-09T11_01_19_492Z-debug-0.log
[!WARNING]
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 15b9ac7cadc4e3cd59dc8e4d0aff8e779cd2a6fe and 1c28d877b940db2be8cf8fc95e11800945789b73.
⛔ Files ignored due to path filters (1)
blocks/themes/uc-basic/icons/ngdrive.svgis excluded by!**/*.svg
📒 Files selected for processing (42)
blocks/Config/initialConfig.js(1 hunks)blocks/Config/normalizeConfigValue.js(1 hunks)blocks/ExternalSource/ExternalSource.js(7 hunks)blocks/ExternalSource/MessageBridge.js(1 hunks)blocks/ExternalSource/types.js(1 hunks)blocks/themes/uc-basic/svg-sprite.js(1 hunks)locales/file-uploader/ar.js(1 hunks)locales/file-uploader/az.js(1 hunks)locales/file-uploader/ca.js(1 hunks)locales/file-uploader/cs.js(1 hunks)locales/file-uploader/da.js(1 hunks)locales/file-uploader/de.js(1 hunks)locales/file-uploader/el.js(1 hunks)locales/file-uploader/en.js(1 hunks)locales/file-uploader/es.js(1 hunks)locales/file-uploader/et.js(1 hunks)locales/file-uploader/fi.js(1 hunks)locales/file-uploader/fr.js(1 hunks)locales/file-uploader/he.js(1 hunks)locales/file-uploader/hy.js(1 hunks)locales/file-uploader/is.js(1 hunks)locales/file-uploader/it.js(1 hunks)locales/file-uploader/ja.js(1 hunks)locales/file-uploader/ka.js(1 hunks)locales/file-uploader/kk.js(1 hunks)locales/file-uploader/ko.js(1 hunks)locales/file-uploader/lv.js(1 hunks)locales/file-uploader/nb.js(1 hunks)locales/file-uploader/nl.js(1 hunks)locales/file-uploader/pl.js(1 hunks)locales/file-uploader/pt.js(1 hunks)locales/file-uploader/ro.js(1 hunks)locales/file-uploader/ru.js(1 hunks)locales/file-uploader/sk.js(1 hunks)locales/file-uploader/sr.js(1 hunks)locales/file-uploader/sv.js(1 hunks)locales/file-uploader/tr.js(1 hunks)locales/file-uploader/uk.js(1 hunks)locales/file-uploader/vi.js(1 hunks)locales/file-uploader/zh-TW.js(1 hunks)locales/file-uploader/zh.js(1 hunks)types/exported.d.ts(1 hunks)
✅ Files skipped from review due to trivial changes (9)
- blocks/ExternalSource/MessageBridge.js
- locales/file-uploader/it.js
- blocks/Config/initialConfig.js
- blocks/Config/normalizeConfigValue.js
- blocks/ExternalSource/types.js
- locales/file-uploader/ru.js
- locales/file-uploader/uk.js
- types/exported.d.ts
- locales/file-uploader/cs.js
🚧 Files skipped from review as they are similar to previous changes (33)
- locales/file-uploader/hy.js
- locales/file-uploader/sr.js
- locales/file-uploader/ko.js
- locales/file-uploader/zh.js
- locales/file-uploader/ka.js
- locales/file-uploader/is.js
- locales/file-uploader/el.js
- locales/file-uploader/et.js
- locales/file-uploader/sv.js
- locales/file-uploader/tr.js
- locales/file-uploader/fi.js
- locales/file-uploader/pl.js
- locales/file-uploader/ca.js
- locales/file-uploader/es.js
- locales/file-uploader/he.js
- locales/file-uploader/nl.js
- locales/file-uploader/en.js
- locales/file-uploader/pt.js
- locales/file-uploader/kk.js
- locales/file-uploader/de.js
- locales/file-uploader/ja.js
- locales/file-uploader/ro.js
- locales/file-uploader/ar.js
- locales/file-uploader/sk.js
- locales/file-uploader/az.js
- locales/file-uploader/fr.js
- locales/file-uploader/da.js
- locales/file-uploader/zh-TW.js
- locales/file-uploader/lv.js
- locales/file-uploader/nb.js
- locales/file-uploader/vi.js
- blocks/ExternalSource/ExternalSource.js
- blocks/themes/uc-basic/svg-sprite.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.