diff --git a/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/__tests__/index.spec.tsx b/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/__tests__/index.spec.tsx index c95621cd2..7e6949e78 100644 --- a/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/__tests__/index.spec.tsx +++ b/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/__tests__/index.spec.tsx @@ -32,6 +32,7 @@ const editorImage = 'custom-editor-image'; describe('Samples List', () => { const sampleUrl = 'https://github.com/che-samples/quarkus-quickstarts/tree/devfilev2'; + const origin = window.location.origin; let storeBuilder: FakeStoreBuilder; beforeEach(() => { @@ -51,7 +52,7 @@ describe('Samples List', () => { tags: ['Community', 'Java', 'Quarkus', 'OpenJDK', 'Maven', 'Debian'], icon: '/images/quarkus.svg', links: { - v2: sampleUrl, + v2: `${sampleUrl}?df=devfile2.yaml`, devWorkspaces: { 'che-incubator/che-code/insiders': 'registry-url/devfile-registry/devfiles/quarkus/devworkspace-che-code-insiders.yaml', @@ -106,9 +107,7 @@ describe('Samples List', () => { userEvent.click(sampleCardButton); expect(mockWindowOpen).toHaveBeenCalledWith( - `/load-factory?url=${encodeURIComponent( - sampleUrl, - )}&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=${preferredPvcStrategy}`, + `${origin}#${sampleUrl}?df=devfile2.yaml&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=${preferredPvcStrategy}`, '_blank', ); }); @@ -126,9 +125,7 @@ describe('Samples List', () => { userEvent.click(sampleCardButton); expect(mockWindowOpen).toHaveBeenCalledWith( - `/load-factory?url=${encodeURIComponent( - sampleUrl, - )}&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=ephemeral`, + `${origin}#${sampleUrl}?df=devfile2.yaml&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=ephemeral`, '_blank', ); expect(mockWindowOpen).toHaveBeenCalledTimes(1); @@ -169,9 +166,7 @@ describe('Samples List', () => { userEvent.click(sampleCardButton); expect(mockWindowOpen).toHaveBeenCalledWith( - `/load-factory?url=${encodeURIComponent( - sampleUrl, - )}&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=${preferredPvcStrategy}`, + `${origin}#${sampleUrl}?df=devfile2.yaml&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=${preferredPvcStrategy}`, '_blank', ); }); @@ -189,9 +184,7 @@ describe('Samples List', () => { userEvent.click(sampleCardButton); expect(mockWindowOpen).toHaveBeenCalledWith( - `/load-factory?url=${encodeURIComponent( - sampleUrl, - )}&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=persistent`, + `${origin}#${sampleUrl}?df=devfile2.yaml&che-editor=che-incubator%2Fche-code%2Finsiders&devWorkspace=registry-url%2Fdevfile-registry%2Fdevfiles%2Fquarkus%2Fdevworkspace-che-code-insiders.yaml&editor-image=custom-editor-image&storageType=persistent`, '_blank', ); expect(mockWindowOpen).toHaveBeenCalledTimes(1); diff --git a/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/index.tsx b/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/index.tsx index a5aa1a112..800029f4d 100644 --- a/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/index.tsx +++ b/packages/dashboard-frontend/src/pages/GetStarted/SamplesList/index.tsx @@ -26,7 +26,6 @@ import { connect, ConnectedProps } from 'react-redux'; import SamplesListGallery from '@/pages/GetStarted/SamplesList/Gallery'; import SamplesListToolbar from '@/pages/GetStarted/SamplesList/Toolbar'; import { EDITOR_ATTR, EDITOR_IMAGE_ATTR } from '@/services/helpers/factoryFlow/buildFactoryParams'; -import { buildFactoryLocation, toHref } from '@/services/helpers/location'; import { che } from '@/services/models'; import { AppState } from '@/store'; import { @@ -72,7 +71,9 @@ class SamplesList extends React.PureComponent { private async handleSampleCardClick(metadata: DevfileRegistryMetadata): Promise { const { editorDefinition, editorImage } = this.props; - const factoryUrlParams = new URLSearchParams({ url: metadata.links.v2 }); + const url = new URL(metadata.links.v2); + + const factoryUrlParams = new URLSearchParams(url.searchParams); if (editorDefinition !== undefined) { factoryUrlParams.append(EDITOR_ATTR, editorDefinition); @@ -90,10 +91,8 @@ class SamplesList extends React.PureComponent { const storageType = this.getStorageType(); factoryUrlParams.append('storageType', storageType); - const factoryLocation = buildFactoryLocation(); - factoryLocation.search = factoryUrlParams.toString(); - - const factoryLink = toHref(this.props.history, factoryLocation); + url.search = factoryUrlParams.toString(); + const factoryLink = `${window.location.origin}#${url.toString()}`; window.open(factoryLink, '_blank'); } diff --git a/packages/dashboard-frontend/src/pages/GetStarted/__tests__/devfileMetadata.json b/packages/dashboard-frontend/src/pages/GetStarted/__tests__/devfileMetadata.json index b886f9fbf..d0967520e 100644 --- a/packages/dashboard-frontend/src/pages/GetStarted/__tests__/devfileMetadata.json +++ b/packages/dashboard-frontend/src/pages/GetStarted/__tests__/devfileMetadata.json @@ -173,9 +173,7 @@ { "displayName": "Empty Workspace", "description": "Start an empty remote development environment and create files or clone a git repository afterwards", - "tags": [ - "Empty" - ], + "tags": ["Empty"], "icon": "/images/empty.svg", "links": { "v2": "/devfiles/empty.yaml" @@ -187,22 +185,14 @@ "displayName": ".NET 5.0", "description": ".NET 5.0 application", "type": "stack", - "tags": [ - ".NET", - ".NET 5.0", - "Devfile.io" - ], + "tags": [".NET", ".NET 5.0", "Devfile.io"], "icon": "https://github.com/dotnet/brand/raw/main/logo/dotnet-logo.png", "projectType": "dotnet", "language": ".NET", "links": { "v2": "devfile-catalog/dotnet50:1.0.3" }, - "resources": [ - "devfile.yaml" - ], - "starterProjects": [ - "dotnet50-example" - ] + "resources": ["devfile.yaml"], + "starterProjects": ["dotnet50-example"] } ] diff --git a/packages/dashboard-frontend/src/pages/GetStarted/__tests__/plugins.json b/packages/dashboard-frontend/src/pages/GetStarted/__tests__/plugins.json index 0e5028c4c..3edcbd74c 100644 --- a/packages/dashboard-frontend/src/pages/GetStarted/__tests__/plugins.json +++ b/packages/dashboard-frontend/src/pages/GetStarted/__tests__/plugins.json @@ -155,4 +155,4 @@ "version": "latest", "icon": "/v3/images/notebook.svg" } -] \ No newline at end of file +] diff --git a/yarn.lock b/yarn.lock index 5d674c04b..604f8cd91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6191,7 +6191,7 @@ inversify@^6.0.0, inversify@^6.0.1: resolved "https://registry.yarnpkg.com/inversify/-/inversify-6.0.2.tgz#dc7fa0348213d789d35ffb719dea9685570989c7" integrity sha512-i9m8j/7YIv4mDuYXUAcrpKPSaju/CIly9AHK5jvCBeoiM/2KEsuCQTTP+rzSWWpLYWRukdXFSl6ZTk2/uumbiA== -ip@2.0.1, ip@^2.0.0: +ip@^2.0.0, ip@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.1.tgz#e8f3595d33a3ea66490204234b77636965307105" integrity sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ== @@ -11495,7 +11495,7 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici@5.28.3, undici@^5.19.1: +undici@^5.19.1, undici@^5.28.3: version "5.28.3" resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.3.tgz#a731e0eff2c3fcfd41c1169a869062be222d1e5b" integrity sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==