Skip to content

Commit 1635623

Browse files
authored
Do not dispatch a warning, if the git provider is not supported (#1306)
1 parent a67105b commit 1635623

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import SessionStorageService, { SessionStorageKey } from '@/services/session-sto
3737
import { RootState } from '@/store';
3838
import { selectBranding } from '@/store/Branding';
3939
import { factoryResolverActionCreators, selectFactoryResolver } from '@/store/FactoryResolver';
40+
import { FACTORY_RESOLVER_NOT_FOUND_ERROR_MESSAGE } from '@/store/Workspaces/devWorkspaces/actions/actionCreators/const';
4041
import { selectAllWorkspaces } from '@/store/Workspaces/selectors';
4142

4243
export class ApplyingDevfileError extends Error {
@@ -212,8 +213,7 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
212213
}
213214
if (
214215
errorMessage === 'Failed to fetch devfile' ||
215-
errorMessage ===
216-
'Cannot build factory with any of the provided parameters. Please check parameters correctness, and resend query.' ||
216+
errorMessage === FACTORY_RESOLVER_NOT_FOUND_ERROR_MESSAGE ||
217217
errorMessage.startsWith('Could not reach devfile')
218218
) {
219219
this.setState({ useDefaultDevfile: true });

packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/actions/actionCreators/__tests__/startWorkspace.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,34 @@ describe('devWorkspaces, actions', () => {
201201
expect(actions[2]).toEqual(devWorkspacesErrorAction(expect.any(String)));
202202
});
203203

204+
it('should not dispatch a warning for unsupported provider', async () => {
205+
const mockError = {
206+
response: {
207+
data: {
208+
message: 'Invalid token',
209+
},
210+
},
211+
};
212+
213+
(OAuthService.refreshTokenIfProjectExists as jest.Mock).mockRejectedValueOnce(mockError);
214+
(getWarningFromResponse as jest.Mock).mockReturnValueOnce(
215+
'Cannot build factory with any of the provided parameters. Please check parameters correctness, and resend query.',
216+
);
217+
218+
// let's stop the workspace start at this point
219+
// as we want to test the warning dispatch only
220+
(checkRunningDevWorkspacesClusterLimitExceeded as jest.Mock).mockImplementationOnce(() => {
221+
throw new Error('Cluster limit exceeded');
222+
});
223+
224+
await expect(store.dispatch(startWorkspace(mockWorkspace))).rejects.toThrow();
225+
226+
const actions = store.getActions();
227+
expect(actions).toHaveLength(2);
228+
expect(actions[0]).toEqual(devWorkspacesRequestAction());
229+
expect(actions[1]).toEqual(devWorkspacesErrorAction(expect.any(String)));
230+
});
231+
204232
it('should dispatch update action on successful start', async () => {
205233
await store.dispatch(startWorkspace(mockWorkspace));
206234

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2018-2024 Red Hat, Inc.
3+
* This program and the accompanying materials are made
4+
* available under the terms of the Eclipse Public License 2.0
5+
* which is available at https://www.eclipse.org/legal/epl-2.0/
6+
*
7+
* SPDX-License-Identifier: EPL-2.0
8+
*
9+
* Contributors:
10+
* Red Hat, Inc. - initial API and implementation
11+
*/
12+
13+
export const FACTORY_RESOLVER_NOT_FOUND_ERROR_MESSAGE =
14+
'Cannot build factory with any of the provided parameters. Please check parameters correctness, and resend query.';

packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/actions/actionCreators/startWorkspace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
devWorkspacesClusterActionCreators,
2222
} from '@/store/DevWorkspacesCluster';
2323
import { verifyAuthorized } from '@/store/SanityCheck';
24+
import { FACTORY_RESOLVER_NOT_FOUND_ERROR_MESSAGE } from '@/store/Workspaces/devWorkspaces/actions/actionCreators/const';
2425
import {
2526
checkDevWorkspaceNextStartAnnotation,
2627
checkRunningWorkspacesLimit,
@@ -61,9 +62,9 @@ export const startWorkspace =
6162
await OAuthService.refreshTokenIfProjectExists(workspace);
6263
} catch (e: unknown) {
6364
// Do not interrupt the workspace start, but show a warning notification.
64-
6565
const warnMessage = getWarningFromResponse(e);
66-
if (warnMessage) {
66+
// Do not dispatch a warning, if the git provider is not supported.
67+
if (warnMessage && warnMessage !== FACTORY_RESOLVER_NOT_FOUND_ERROR_MESSAGE) {
6768
dispatch(devWorkspaceWarningUpdateAction({ workspace, warning: warnMessage }));
6869
}
6970
}

0 commit comments

Comments
 (0)