Add latest changes from gitlab-org/gitlab@16-1-stable-ee

This commit is contained in:
GitLab Bot 2023-07-03 13:48:23 +00:00
parent 9b7331ec40
commit 4c6095ca93
4 changed files with 18 additions and 7 deletions

View File

@ -72,11 +72,14 @@ function fixElementSource(el) {
export function getSandboxFrameSrc() {
const path = joinPaths(gon.relative_url_root || '', SANDBOX_FRAME_PATH);
if (!darkModeEnabled()) {
return path;
let absoluteUrl = relativePathToAbsolute(path, getBaseURL());
if (darkModeEnabled()) {
absoluteUrl = setUrlParams({ darkMode: darkModeEnabled() }, absoluteUrl);
}
const absoluteUrl = relativePathToAbsolute(path, getBaseURL());
return setUrlParams({ darkMode: darkModeEnabled() }, absoluteUrl);
if (window.gon?.relative_url_root) {
absoluteUrl = setUrlParams({ relativeRootPath: window.gon.relative_url_root }, absoluteUrl);
}
return absoluteUrl;
}
function renderMermaidEl(el, source) {

View File

@ -1,6 +1,13 @@
import mermaid from 'mermaid';
import { getParameterByName } from '~/lib/utils/url_utility';
import { resetServiceWorkersPublicPath } from '~/lib/utils/webpack';
const resetWebpackPublicPath = () => {
window.gon = { relative_url_root: getParameterByName('relativeRootPath') };
resetServiceWorkersPublicPath();
};
resetWebpackPublicPath();
const setIframeRenderedSize = (h, w) => {
const { origin } = window.location;
window.parent.postMessage({ h, w }, origin);

View File

@ -16,8 +16,9 @@ RSpec.describe 'Sandboxed Mermaid rendering', :js, feature_category: :team_plann
MERMAID
end
let_it_be(:expected) do
%(<iframe src="/-/sandbox/mermaid" sandbox="allow-scripts allow-popups" frameborder="0" scrolling="no")
let(:expected) do
src = "http://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}/-/sandbox/mermaid"
%(<iframe src="#{src}" sandbox="allow-scripts allow-popups" frameborder="0" scrolling="no")
end
context 'in an issue' do

View File

@ -9,7 +9,7 @@ import renderMermaid, {
describe('Mermaid diagrams renderer', () => {
// Finders
const findMermaidIframes = () => document.querySelectorAll('iframe[src="/-/sandbox/mermaid"]');
const findMermaidIframes = () => document.querySelectorAll('iframe[src*="/-/sandbox/mermaid"]');
const findDangerousMermaidAlert = () =>
createWrapper(document.querySelector('[data-testid="alert-warning"]'));