diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 232c35bc8a6..6092c1da083 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -230,8 +230,6 @@ class Web_Editor(http.Controller): def video_url_data(self, video_url, autoplay=False, loop=False, hide_controls=False, hide_fullscreen=False, hide_yt_logo=False, hide_dm_logo=False, hide_dm_share=False): - if not request.env.user._is_internal(): - raise werkzeug.exceptions.Forbidden() return get_video_url_data( video_url, autoplay=autoplay, loop=loop, hide_controls=hide_controls, hide_fullscreen=hide_fullscreen, diff --git a/addons/web_editor/static/src/components/media_dialog/video_selector.js b/addons/web_editor/static/src/components/media_dialog/video_selector.js index c2e9985f52d..cf5960d53d0 100644 --- a/addons/web_editor/static/src/components/media_dialog/video_selector.js +++ b/addons/web_editor/static/src/components/media_dialog/video_selector.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { _t } from "@web/core/l10n/translation"; -import { useService } from '@web/core/utils/hooks'; +import { useAutofocus, useService } from '@web/core/utils/hooks'; import { debounce } from '@web/core/utils/timing'; import { Component, useState, useRef, onMounted, onWillStart } from "@odoo/owl"; @@ -9,6 +9,13 @@ import { Component, useState, useRef, onMounted, onWillStart } from "@odoo/owl"; class VideoOption extends Component {} VideoOption.template = 'web_editor.VideoOption'; +class VideoIframe extends Component { + static template = 'web_editor.VideoIframe'; + static props = { + src: { type: String }, + }; +} + export class VideoSelector extends Component { setup() { this.rpc = useService('rpc'); @@ -98,6 +105,8 @@ export class VideoSelector extends Component { })); }); + useAutofocus(); + this.onChangeUrl = debounce((ev) => this.updateVideo(ev.target.value), 500); } @@ -130,6 +139,12 @@ export class VideoSelector extends Component { this.state.options = []; this.state.platform = null; this.state.errorMessage = ''; + /** + * When the url input is emptied, we need to call the `selectMedia` + * callback function to notify the other components that the media + * has changed. + */ + this.props.selectMedia({}); return; } @@ -150,7 +165,13 @@ export class VideoSelector extends Component { options[option.id] = option.value; } } - const { embed_url: src, platform } = await this._getVideoURLData(url, options); + + const { + embed_url: src, + video_id: videoId, + params, + platform + } = await this._getVideoURLData(url, options); if (!src) { this.state.errorMessage = _t("The provided url is not valid"); @@ -173,7 +194,13 @@ export class VideoSelector extends Component { } this.state.src = src; - this.props.selectMedia({ id: src, src }); + this.props.selectMedia({ + id: src, + src, + platform, + videoId, + params + }); if (platform !== this.state.platform) { this.state.platform = platform; this.state.options = newOptions; @@ -213,6 +240,7 @@ VideoSelector.mediaExtraClasses = []; VideoSelector.tagNames = ['IFRAME', 'DIV']; VideoSelector.template = 'web_editor.VideoSelector'; VideoSelector.components = { + VideoIframe, VideoOption, }; VideoSelector.defaultProps = { diff --git a/addons/web_editor/static/src/components/media_dialog/video_selector.xml b/addons/web_editor/static/src/components/media_dialog/video_selector.xml index d43e275cbf2..d97e1273947 100644 --- a/addons/web_editor/static/src/components/media_dialog/video_selector.xml +++ b/addons/web_editor/static/src/components/media_dialog/video_selector.xml @@ -3,27 +3,37 @@
-
+ +