diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-30 02:58:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-30 02:58:45 +0300 |
commit | 1794d7d6a11019da7fe8bb56536f3fce69d1825d (patch) | |
tree | 4975bcf5629d6322feab02d1987676ef5fd5411d /app/assets/javascripts | |
parent | 5825f3338e723e631964bf67d259e3365014a442 (diff) |
Add latest changes from gitlab-org/security/gitlab@15-9-stable-ee
Diffstat (limited to 'app/assets/javascripts')
4 files changed, 30 insertions, 52 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/render_observability.js b/app/assets/javascripts/behaviors/markdown/render_observability.js index d5d46c10efd..704d85cf22e 100644 --- a/app/assets/javascripts/behaviors/markdown/render_observability.js +++ b/app/assets/javascripts/behaviors/markdown/render_observability.js @@ -7,36 +7,23 @@ export function getFrameSrc(url) { } const mountVueComponent = (element) => { - const { frameUrl, observabilityUrl } = element.dataset; + const url = [element.dataset.frameUrl]; - try { - if ( - !observabilityUrl || - !frameUrl || - new URL(frameUrl)?.host !== new URL(observabilityUrl).host - ) - return; - - // eslint-disable-next-line no-new - new Vue({ - el: element, - render(h) { - return h('iframe', { - style: { - height: '366px', - width: '768px', - }, - attrs: { - src: getFrameSrc(frameUrl), - frameBorder: '0', - }, - }); - }, - }); - } catch (e) { - // eslint-disable-next-line no-console - console.error(e); - } + return new Vue({ + el: element, + render(h) { + return h('iframe', { + style: { + height: '366px', + width: '768px', + }, + attrs: { + src: getFrameSrc(url), + frameBorder: '0', + }, + }); + }, + }); }; export default function renderObservability(elements) { diff --git a/app/assets/javascripts/pages/projects/project.js b/app/assets/javascripts/pages/projects/project.js index a4b3b83a855..5773737c41b 100644 --- a/app/assets/javascripts/pages/projects/project.js +++ b/app/assets/javascripts/pages/projects/project.js @@ -110,10 +110,9 @@ export default class Project { const urlParams = { [fieldName]: ref }; if (params.group === BRANCH_GROUP_NAME) { urlParams.ref_type = BRANCH_REF_TYPE; - } else if (params.group === TAG_GROUP_NAME) { + } else { urlParams.ref_type = TAG_REF_TYPE; } - link.href = mergeUrlParams(urlParams, linkTarget); } diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index 95e0c94527b..494e270a66c 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -2,7 +2,7 @@ import { GlButton } from '@gitlab/ui'; import Vue from 'vue'; import Vuex from 'vuex'; import { parseBoolean } from '~/lib/utils/common_utils'; -import { joinPaths, escapeFileUrl, visitUrl } from '~/lib/utils/url_utility'; +import { escapeFileUrl, visitUrl } from '~/lib/utils/url_utility'; import { __ } from '~/locale'; import initWebIdeLink from '~/pages/projects/shared/web_ide_link'; import PerformancePlugin from '~/performance/vue_performance_plugin'; @@ -121,7 +121,7 @@ export default function setupVueRepositoryList() { if (!refSwitcherEl) return false; - const { projectId, projectRootPath, refType } = refSwitcherEl.dataset; + const { projectId, projectRootPath } = refSwitcherEl.dataset; return new Vue({ el: refSwitcherEl, @@ -129,8 +129,7 @@ export default function setupVueRepositoryList() { return createElement(RefSelector, { props: { projectId, - value: refType ? joinPaths('refs', refType, ref) : ref, - useSymbolicRefNames: true, + value: ref, }, on: { input(selectedRef) { diff --git a/app/assets/javascripts/repository/utils/ref_switcher_utils.js b/app/assets/javascripts/repository/utils/ref_switcher_utils.js index bcad4a2c822..c62f7f709c4 100644 --- a/app/assets/javascripts/repository/utils/ref_switcher_utils.js +++ b/app/assets/javascripts/repository/utils/ref_switcher_utils.js @@ -16,29 +16,22 @@ const getNamespaceTargetRegex = (ref) => new RegExp(`(/-/(blob|tree))/${ref}/(.* * @param {string} selectedRef - The selected ref from the ref dropdown. */ export function generateRefDestinationPath(projectRootPath, ref, selectedRef) { - const url = new URL(window.location.href); - const currentPath = url.pathname; - let refType = null; + const currentPath = window.location.pathname; + const encodedHash = '%23'; let namespace = '/-/tree'; let target; - let actualRef = selectedRef; - - const matches = selectedRef.match(/^refs\/(heads|tags)\/(.+)/); - if (matches) { - [, refType, actualRef] = matches; - } - if (refType) { - url.searchParams.set('ref_type', refType); - } else { - url.searchParams.delete('ref_type'); - } - const NAMESPACE_TARGET_REGEX = getNamespaceTargetRegex(ref); const match = NAMESPACE_TARGET_REGEX.exec(currentPath); if (match) { [, namespace, , target] = match; } - url.pathname = joinPaths(projectRootPath, namespace, actualRef, target); - return url.toString(); + const destinationPath = joinPaths( + projectRootPath, + namespace, + encodeURI(selectedRef).replace(/#/g, encodedHash), + target, + ); + + return `${destinationPath}${window.location.hash}`; } |