From dd4bee69b7d55620f7dc9db8c36b478bd4959755 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 12 Mar 2020 21:09:45 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../ide/components/preview/clientside.vue | 23 +++++++++++++--------- app/assets/javascripts/ide/index.js | 1 + app/assets/javascripts/ide/stores/state.js | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'app/assets/javascripts/ide') diff --git a/app/assets/javascripts/ide/components/preview/clientside.vue b/app/assets/javascripts/ide/components/preview/clientside.vue index beb179d0411..aa8d932da6e 100644 --- a/app/assets/javascripts/ide/components/preview/clientside.vue +++ b/app/assets/javascripts/ide/components/preview/clientside.vue @@ -21,7 +21,7 @@ export default { }; }, computed: { - ...mapState(['entries', 'promotionSvgPath', 'links']), + ...mapState(['entries', 'promotionSvgPath', 'links', 'codesandboxBundlerUrl']), ...mapGetters(['packageJson', 'currentProject']), normalizedEntries() { return Object.keys(this.entries).reduce((acc, path) => { @@ -106,12 +106,7 @@ export default { return this.loadFileContent(this.mainEntry) .then(() => this.$nextTick()) .then(() => { - this.initManager('#ide-preview', this.sandboxOpts, { - fileResolver: { - isFile: p => Promise.resolve(Boolean(this.entries[createPathWithExt(p)])), - readFile: p => this.loadFileContent(createPathWithExt(p)).then(content => content), - }, - }); + this.initManager(); this.listener = listen(e => { switch (e.type) { @@ -139,8 +134,18 @@ export default { this.manager.updatePreview(this.sandboxOpts); }, 250); }, - initManager(el, opts, resolver) { - this.manager = new Manager(el, opts, resolver); + initManager() { + const { codesandboxBundlerUrl: bundlerURL } = this; + + const settings = { + fileResolver: { + isFile: p => Promise.resolve(Boolean(this.entries[createPathWithExt(p)])), + readFile: p => this.loadFileContent(createPathWithExt(p)).then(content => content), + }, + ...(bundlerURL ? { bundlerURL } : {}), + }; + + this.manager = new Manager('#ide-preview', this.sandboxOpts, settings); }, }, }; diff --git a/app/assets/javascripts/ide/index.js b/app/assets/javascripts/ide/index.js index a3450522697..9e9d9df8f82 100644 --- a/app/assets/javascripts/ide/index.js +++ b/app/assets/javascripts/ide/index.js @@ -53,6 +53,7 @@ export function initIde(el, options = {}) { clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled), renderWhitespaceInCode: parseBoolean(el.dataset.renderWhitespaceInCode), editorTheme: window.gon?.user_color_scheme || DEFAULT_THEME, + codesandboxBundlerUrl: el.dataset.codesandboxBundlerUrl, }); }, methods: { diff --git a/app/assets/javascripts/ide/stores/state.js b/app/assets/javascripts/ide/stores/state.js index a714562c5b2..0fd6a448283 100644 --- a/app/assets/javascripts/ide/stores/state.js +++ b/app/assets/javascripts/ide/stores/state.js @@ -34,4 +34,5 @@ export default () => ({ clientsidePreviewEnabled: false, renderWhitespaceInCode: false, editorTheme: DEFAULT_THEME, + codesandboxBundlerUrl: null, }); -- cgit v1.2.1