From cde9778551c662b7ef7eb06b8ab4779787ce9343 Mon Sep 17 00:00:00 2001 From: Florent Benoit Date: Tue, 19 Oct 2021 09:57:28 +0200 Subject: [PATCH] feat: Allow to specify the path to the devfile with factory workflow Fixes https://github.com/eclipse/che/issues/20607 --- .../src/services/helpers/location.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/dashboard-frontend/src/services/helpers/location.ts b/packages/dashboard-frontend/src/services/helpers/location.ts index 3f939f8f1..99727893d 100644 --- a/packages/dashboard-frontend/src/services/helpers/location.ts +++ b/packages/dashboard-frontend/src/services/helpers/location.ts @@ -48,6 +48,16 @@ export function buildFactoryLoaderLocation(url?: string): Location { editor = editorParam.slice(); } fullUrl.searchParams.delete('che-editor'); + + // search for devfile switch and if there is one, remove it from the URL + const devfileFilenameAttribute = 'devfileFilename'; + const devfileFilenameParam = fullUrl.searchParams.get(devfileFilenameAttribute); + let devfileFilename; + if (devfileFilenameParam && typeof(devfileFilenameParam) === 'string') { + devfileFilename = devfileFilenameParam.slice(); + } + fullUrl.searchParams.delete(devfileFilenameAttribute); + const encodedUrl = encodeURIComponent(fullUrl.toString()); // if editor specified, add it as a new parameter @@ -55,6 +65,9 @@ export function buildFactoryLoaderLocation(url?: string): Location { if (editor) { pathAndQuery = `${pathAndQuery}&che-editor=${editor}`; } + if (devfileFilename) { + pathAndQuery = `${pathAndQuery}&override.devfileFilename=${devfileFilename}`; + } } return _buildLocationObject(pathAndQuery); }