Skip to content

Commit c57701e

Browse files
committed
Start workspace from default devfile on private repository SSH url
1 parent e3d2d8d commit c57701e

File tree

2 files changed

+8
-72
lines changed
  • packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile

2 files changed

+8
-72
lines changed

packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/__tests__/index.spec.tsx

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
/* eslint-disable @typescript-eslint/no-non-null-assertion */
1414

1515
import { FACTORY_LINK_ATTR } from '@eclipse-che/common';
16-
import { AlertVariant } from '@patternfly/react-core';
1716
import { cleanup, screen, waitFor } from '@testing-library/react';
1817
import userEvent, { UserEvent } from '@testing-library/user-event';
1918
import React from 'react';
@@ -695,31 +694,6 @@ describe('Creating steps, fetching a devfile', () => {
695694
const protocol = 'http://';
696695
const factoryUrl = 'git@github.com:user/repository-name.git';
697696
const emptyStore = new MockStoreBuilder().build();
698-
const sshPrivateRepoAllertItem = expect.objectContaining({
699-
title: 'Warning',
700-
variant: AlertVariant.warning,
701-
children: (
702-
<ExpandableWarning
703-
textBefore="Devfile resolve from a privatre repositry via an SSH url is not supported."
704-
errorMessage="Could not reach devfile"
705-
textAfter="Apply a Personal Access Token to fetch the devfile.yaml content."
706-
/>
707-
),
708-
actionCallbacks: [
709-
expect.objectContaining({
710-
title: 'Continue with default devfile',
711-
callback: expect.any(Function),
712-
}),
713-
expect.objectContaining({
714-
title: 'Reload',
715-
callback: expect.any(Function),
716-
}),
717-
expect.objectContaining({
718-
title: 'Open Documentation page',
719-
callback: expect.any(Function),
720-
}),
721-
],
722-
});
723697

724698
let spyWindowLocation: jest.SpyInstance;
725699
let location: Location;
@@ -771,32 +745,32 @@ describe('Creating steps, fetching a devfile', () => {
771745
expect(mockOnError).not.toHaveBeenCalled();
772746
});
773747

774-
it('should show warning on SSH url', async () => {
748+
it('should use default devfile on private SSH url', async () => {
775749
searchParams = new URLSearchParams({
776750
[FACTORY_URL_ATTR]: 'git@github.com:user/repository.git',
777751
});
778752

779753
renderComponent(emptyStore, searchParams, location);
780754

781755
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS);
782-
await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled);
756+
await waitFor(() => expect(mockOnNextStep).toHaveBeenCalled());
783757

784758
expect(mockOpenOAuthPage).not.toHaveBeenCalled();
785-
expect(mockOnError).toHaveBeenCalledWith(sshPrivateRepoAllertItem);
759+
expect(mockOnError).not.toHaveBeenCalled();
786760
});
787761

788-
it('should show warning on bitbucket-server SSH url', async () => {
762+
it('should use default devfile on bitbucket-server SSH url', async () => {
789763
searchParams = new URLSearchParams({
790764
[FACTORY_URL_ATTR]: 'ssh://git@bitbucket-server.com/~user/repository.git',
791765
});
792766

793767
renderComponent(emptyStore, searchParams, location);
794768

795769
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS);
796-
await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled);
770+
await waitFor(() => expect(mockOnNextStep).toHaveBeenCalled);
797771

798772
expect(mockOpenOAuthPage).not.toHaveBeenCalled();
799-
expect(mockOnError).toHaveBeenCalledWith(sshPrivateRepoAllertItem);
773+
expect(mockOnError).not.toHaveBeenCalled();
800774
});
801775
});
802776
});

packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/index.tsx

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ export class UnsupportedGitProviderError extends Error {
5353
}
5454
}
5555

56-
export class SSHPrivateRepositoryUrlError extends Error {
57-
constructor(message: string) {
58-
super(message);
59-
this.name = 'UnsupportedGitProviderError';
60-
}
61-
}
62-
6356
const RELOADS_LIMIT = 2;
6457
type ReloadsInfo = {
6558
[url: string]: number;
@@ -188,10 +181,6 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
188181
this.clearStepError();
189182
}
190183

191-
protected handleOpenDocumentationPage(): void {
192-
window.open(this.props.branding.docs.startWorkspaceFromGit, '_blank');
193-
}
194-
195184
protected handleTimeout(): void {
196185
const timeoutError = new Error(
197186
`Devfile hasn't been resolved in the last ${TIMEOUT_TO_RESOLVE_SEC} seconds.`,
@@ -235,7 +224,8 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
235224
) {
236225
// check if the source url is an SSH url
237226
if (this.sshPattern.test(sourceUrl)) {
238-
throw new SSHPrivateRepositoryUrlError(errorMessage);
227+
this.setState({ useDefaultDevfile: true });
228+
return true;
239229
} else {
240230
throw new UnsupportedGitProviderError(errorMessage);
241231
}
@@ -383,34 +373,6 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
383373
],
384374
};
385375
}
386-
if (error instanceof SSHPrivateRepositoryUrlError) {
387-
return {
388-
key,
389-
title: 'Warning',
390-
variant: AlertVariant.warning,
391-
children: (
392-
<ExpandableWarning
393-
textBefore="Devfile resolve from a privatre repositry via an SSH url is not supported."
394-
errorMessage={helpers.errors.getMessage(error)}
395-
textAfter="Apply a Personal Access Token to fetch the devfile.yaml content."
396-
/>
397-
),
398-
actionCallbacks: [
399-
{
400-
title: 'Continue with default devfile',
401-
callback: () => this.handleDefaultDevfile(key),
402-
},
403-
{
404-
title: 'Reload',
405-
callback: () => this.handleRestart(key),
406-
},
407-
{
408-
title: 'Open Documentation page',
409-
callback: () => this.handleOpenDocumentationPage(),
410-
},
411-
],
412-
};
413-
}
414376
return {
415377
key,
416378
title: 'Failed to create the workspace',

0 commit comments

Comments
 (0)