From 2a312957a3e0532ba9aa8c997ee7f69714e290c7 Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Tue, 8 Oct 2024 17:31:05 +0300 Subject: [PATCH] fix: TemporaryStorageField widget Signed-off-by: Oleksii Orel --- packages/common/src/dto/api/index.ts | 2 -- .../src/routes/api/devworkspaceResources.ts | 6 ++-- .../__snapshots__/index.spec.tsx.snap | 8 ++--- .../__snapshots__/index.spec.tsx.snap | 8 ++--- .../TemporaryStorageField/index.tsx | 2 +- .../__tests__/helpers.spec.ts | 29 ++----------------- .../src/services/workspace-client/helpers.ts | 1 - .../store/Workspaces/devWorkspaces/index.ts | 12 +------- 8 files changed, 16 insertions(+), 52 deletions(-) diff --git a/packages/common/src/dto/api/index.ts b/packages/common/src/dto/api/index.ts index ecbe10176..2fe73124c 100644 --- a/packages/common/src/dto/api/index.ts +++ b/packages/common/src/dto/api/index.ts @@ -182,8 +182,6 @@ export interface IDevWorkspaceList { export interface IDevWorkspaceResources { devfileContent: string | undefined; editorPath: string | undefined; - pluginRegistryUrl: string | undefined; - editorId: string | undefined; editorContent: string | undefined; } diff --git a/packages/dashboard-backend/src/routes/api/devworkspaceResources.ts b/packages/dashboard-backend/src/routes/api/devworkspaceResources.ts index b722ca5f6..8347506e4 100644 --- a/packages/dashboard-backend/src/routes/api/devworkspaceResources.ts +++ b/packages/dashboard-backend/src/routes/api/devworkspaceResources.ts @@ -31,14 +31,14 @@ export function registerDevworkspaceResourcesRoute(instance: FastifyInstance) { `${baseApiPath}/devworkspace-resources`, getSchema({ tags, body: devWorkspaceResourcesSchema }), async function (request: FastifyRequest) { - const { devfileContent, editorPath, pluginRegistryUrl, editorId, editorContent } = + const { devfileContent, editorPath, editorContent } = request.body as api.IDevWorkspaceResources; const context = await generator.generateDevfileContext( { devfileContent, editorPath, - pluginRegistryUrl, - editorEntry: editorId, + pluginRegistryUrl: undefined, + editorEntry: undefined, editorContent, projects: [], }, diff --git a/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/CreateNewIfExistingField/__tests__/__snapshots__/index.spec.tsx.snap b/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/CreateNewIfExistingField/__tests__/__snapshots__/index.spec.tsx.snap index 50f116d12..c8800ecd0 100644 --- a/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/CreateNewIfExistingField/__tests__/__snapshots__/index.spec.tsx.snap +++ b/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/CreateNewIfExistingField/__tests__/__snapshots__/index.spec.tsx.snap @@ -26,7 +26,7 @@ exports[`TemporaryStorageField switched off snapshot 1`] = ` data-ouia-component-id="OUIA-Generated-Switch-1" data-ouia-component-type="PF4/Switch" data-ouia-safe={true} - htmlFor="temporary-storage-switch" + htmlFor="adv-temporary-storage-switch" > @@ -92,7 +92,7 @@ exports[`TemporaryStorageField switched on snapshot 1`] = ` data-ouia-component-id="OUIA-Generated-Switch-2" data-ouia-component-type="PF4/Switch" data-ouia-safe={true} - htmlFor="temporary-storage-switch" + htmlFor="adv-temporary-storage-switch" > diff --git a/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/__tests__/__snapshots__/index.spec.tsx.snap b/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/__tests__/__snapshots__/index.spec.tsx.snap index 50f116d12..c8800ecd0 100644 --- a/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/__tests__/__snapshots__/index.spec.tsx.snap +++ b/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/__tests__/__snapshots__/index.spec.tsx.snap @@ -26,7 +26,7 @@ exports[`TemporaryStorageField switched off snapshot 1`] = ` data-ouia-component-id="OUIA-Generated-Switch-1" data-ouia-component-type="PF4/Switch" data-ouia-safe={true} - htmlFor="temporary-storage-switch" + htmlFor="adv-temporary-storage-switch" > @@ -92,7 +92,7 @@ exports[`TemporaryStorageField switched on snapshot 1`] = ` data-ouia-component-id="OUIA-Generated-Switch-2" data-ouia-component-type="PF4/Switch" data-ouia-safe={true} - htmlFor="temporary-storage-switch" + htmlFor="adv-temporary-storage-switch" > diff --git a/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/index.tsx b/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/index.tsx index 429e3f6b6..ca341f437 100644 --- a/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/index.tsx +++ b/packages/dashboard-frontend/src/components/ImportFromGit/RepoOptionsAccordion/AdvancedOptions/TemporaryStorageField/index.tsx @@ -48,7 +48,7 @@ export class TemporaryStorageField extends React.PureComponent { return ( this.handleChange(value)} diff --git a/packages/dashboard-frontend/src/services/workspace-client/__tests__/helpers.spec.ts b/packages/dashboard-frontend/src/services/workspace-client/__tests__/helpers.spec.ts index 41afa6271..faa0d9087 100644 --- a/packages/dashboard-frontend/src/services/workspace-client/__tests__/helpers.spec.ts +++ b/packages/dashboard-frontend/src/services/workspace-client/__tests__/helpers.spec.ts @@ -269,7 +269,6 @@ describe('Workspace-client helpers', () => { }); describe('Look for the custom editor', () => { - const pluginRegistryUrl = 'https://dummy-plugin-registry'; let optionalFilesContent: { [fileName: string]: string }; let editor: devfileApi.Devfile; @@ -285,7 +284,6 @@ describe('Workspace-client helpers', () => { it('should return undefined without optionalFilesContent', async () => { const store = new FakeStoreBuilder().build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -300,7 +298,6 @@ describe('Workspace-client helpers', () => { const store = new FakeStoreBuilder().build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -324,7 +321,6 @@ describe('Workspace-client helpers', () => { const store = new FakeStoreBuilder().build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -342,12 +338,7 @@ describe('Workspace-client helpers', () => { let errorText: string | undefined; try { - await getCustomEditor( - pluginRegistryUrl, - optionalFilesContent, - store.dispatch, - store.getState, - ); + await getCustomEditor(optionalFilesContent, store.dispatch, store.getState); } catch (e) { errorText = common.helpers.errors.getMessage(e); } @@ -393,7 +384,6 @@ describe('Workspace-client helpers', () => { .build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -452,7 +442,6 @@ describe('Workspace-client helpers', () => { .build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -505,12 +494,7 @@ describe('Workspace-client helpers', () => { let errorText: string | undefined; try { - await getCustomEditor( - pluginRegistryUrl, - optionalFilesContent, - store.dispatch, - store.getState, - ); + await getCustomEditor(optionalFilesContent, store.dispatch, store.getState); } catch (e) { errorText = common.helpers.errors.getMessage(e); } @@ -539,7 +523,6 @@ describe('Workspace-client helpers', () => { .build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -573,7 +556,6 @@ describe('Workspace-client helpers', () => { .build(); const customEditor = await getCustomEditor( - pluginRegistryUrl, optionalFilesContent, store.dispatch, store.getState, @@ -602,12 +584,7 @@ describe('Workspace-client helpers', () => { let errorText: string | undefined; try { - await getCustomEditor( - pluginRegistryUrl, - optionalFilesContent, - store.dispatch, - store.getState, - ); + await getCustomEditor(optionalFilesContent, store.dispatch, store.getState); } catch (e) { errorText = common.helpers.errors.getMessage(e); } diff --git a/packages/dashboard-frontend/src/services/workspace-client/helpers.ts b/packages/dashboard-frontend/src/services/workspace-client/helpers.ts index f2e7b6946..2d76acb84 100644 --- a/packages/dashboard-frontend/src/services/workspace-client/helpers.ts +++ b/packages/dashboard-frontend/src/services/workspace-client/helpers.ts @@ -137,7 +137,6 @@ export const CHE_EDITOR_YAML_PATH = '.che/che-editor.yaml'; * Look for the custom editor in .che/che-editor.yaml */ export async function getCustomEditor( - pluginRegistryUrl: string | undefined, optionalFilesContent: { [fileName: string]: string }, dispatch: ThunkDispatch, getState: () => AppState, diff --git a/packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/index.ts b/packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/index.ts index 2249bf6df..8b0b590c6 100644 --- a/packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/index.ts +++ b/packages/dashboard-frontend/src/store/Workspaces/devWorkspaces/index.ts @@ -721,10 +721,8 @@ export const actionCreators: ActionCreators = { editorContent = updateEditorDevfile(editorContent, editorImage); } const resourcesContent = await fetchResources({ - pluginRegistryUrl, devfileContent: dump(defaultsDevfile), editorPath: undefined, - editorId: undefined, editorContent, }); const resources = loadResourcesContent(resourcesContent); @@ -877,7 +875,6 @@ export const actionCreators: ActionCreators = { ): AppThunk> => async (dispatch, getState): Promise => { const state = getState(); - const pluginRegistryUrl = selectPluginRegistryUrl(state); let devWorkspaceResource: devfileApi.DevWorkspace; let devWorkspaceTemplateResource: devfileApi.DevWorkspaceTemplate; let editorContent: string | undefined; @@ -895,12 +892,7 @@ export const actionCreators: ActionCreators = { } else { // do we have the custom editor in `.che/che-editor.yaml` ? try { - editorContent = await getCustomEditor( - pluginRegistryUrl, - optionalFilesContent, - dispatch, - getState, - ); + editorContent = await getCustomEditor(optionalFilesContent, dispatch, getState); if (!editorContent) { console.warn('No custom editor found'); } @@ -932,10 +924,8 @@ export const actionCreators: ActionCreators = { } editorContent = updateEditorDevfile(editorContent, params.editorImage); const resourcesContent = await fetchResources({ - pluginRegistryUrl, devfileContent: dump(devfile), editorPath: undefined, - editorId: undefined, editorContent: editorContent, }); const resources = loadResourcesContent(resourcesContent);