Skip to content

Commit

Permalink
feat: Allow to specify the path to the devfile with factory workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitf committed Oct 19, 2021
1 parent 86893cd commit cde9778
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/dashboard-frontend/src/services/helpers/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,26 @@ 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
pathAndQuery = ROUTE.LOAD_FACTORY_URL.replace(':url', encodedUrl);
if (editor) {
pathAndQuery = `${pathAndQuery}&che-editor=${editor}`;
}
if (devfileFilename) {
pathAndQuery = `${pathAndQuery}&override.devfileFilename=${devfileFilename}`;
}
}
return _buildLocationObject(pathAndQuery);
}
Expand Down

0 comments on commit cde9778

Please sign in to comment.