From 882ad85e23432fbf9db8be94a125b6d7726ff152 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 17 Apr 2025 13:36:42 +0530 Subject: [PATCH] chore: filter out AI Datasource during import (#40286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: https://github.com/user-attachments/assets/2954a270-b4e9-4871-b2f6-b9967f997d26 After: https://github.com/user-attachments/assets/b83762e3-7e21-4fff-bdc6-708412d3d3b3 /ok-to-test tags="@tag.Templates" > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: a3d4aa2d68f39deb5767936521c09a2d579dfbeb > Cypress dashboard. > Tags: `@tag.Templates` > Spec: >
Thu, 17 Apr 2025 07:16:52 UTC ## Summary by CodeRabbit - **Bug Fixes** - The "AI Datasource" will no longer appear in the reconnect datasource modal during partial application or template imports, improving clarity for users when reconnecting datasources. --- app/client/src/ce/sagas/ApplicationSagas.tsx | 44 ++++++++++++++------ app/client/src/sagas/TemplatesSagas.ts | 15 +++++-- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/app/client/src/ce/sagas/ApplicationSagas.tsx b/app/client/src/ce/sagas/ApplicationSagas.tsx index 283e52ea2f..64fbba0b3c 100644 --- a/app/client/src/ce/sagas/ApplicationSagas.tsx +++ b/app/client/src/ce/sagas/ApplicationSagas.tsx @@ -124,6 +124,8 @@ import { findDefaultPage } from "pages/utils"; export let windowReference: Window | null = null; +const AI_DATASOURCE_NAME = "AI Datasource"; + export function* publishApplicationSaga( requestAction: ReduxAction, ) { @@ -747,12 +749,22 @@ export function* forkApplicationSaga( yield take(ReduxActionTypes.INITIALIZE_EDITOR_SUCCESS); } - if (response.data.isPartialImport) { + // Temporary fix to remove AI Datasource from the unConfiguredDatasourceList + // so we can avoid showing the AI Datasource in reconnect datasource modal + const filteredUnConfiguredDatasourceList = ( + response?.data?.unConfiguredDatasourceList || [] + ).filter( + (datasource) => datasource.name !== AI_DATASOURCE_NAME, + ) as Datasource[]; + + if ( + response.data.isPartialImport && + filteredUnConfiguredDatasourceList.length > 0 + ) { yield put( showReconnectDatasourceModal({ application: response.data?.application, - unConfiguredDatasourceList: - response?.data.unConfiguredDatasourceList, + unConfiguredDatasourceList: filteredUnConfiguredDatasourceList, workspaceId: action.payload.workspaceId, }), ); @@ -796,7 +808,11 @@ export function* importApplicationSaga( action: ReduxAction, ) { try { - const response: ApiResponse = yield call( + const response: ApiResponse<{ + unConfiguredDatasourceList: Datasource[]; + application: ApplicationResponsePayload; + isPartialImport: boolean; + }> = yield call( ApplicationApi.importApplicationToWorkspace, action.payload, ); @@ -813,28 +829,29 @@ export function* importApplicationSaga( if (currentWorkspaceId || currentWorkspace.length > 0) { const { - // @ts-expect-error: response is of type unknown application: { pages }, - // @ts-expect-error: response is of type unknown isPartialImport, } = response.data; - // @ts-expect-error: response is of type unknown yield put(importApplicationSuccess(response.data?.application)); - if (isPartialImport) { + // Temporary fix to remove AI Datasource from the unConfiguredDatasourceList + // so we can avoid showing the AI Datasource in reconnect datasource modal + const filteredUnConfiguredDatasourceList = ( + response?.data?.unConfiguredDatasourceList || [] + ).filter( + (datasource) => datasource.name !== AI_DATASOURCE_NAME, + ) as Datasource[]; + + if (isPartialImport && filteredUnConfiguredDatasourceList.length > 0) { yield put( showReconnectDatasourceModal({ - // @ts-expect-error: response is of type unknown application: response.data?.application, - unConfiguredDatasourceList: - // @ts-expect-error: response is of type unknown - response?.data.unConfiguredDatasourceList, + unConfiguredDatasourceList: filteredUnConfiguredDatasourceList, workspaceId: action.payload.workspaceId, }), ); } else { - // @ts-expect-error: pages is of type any // TODO: Update route params here const { application } = response.data; const defaultPage = findDefaultPage(pages); @@ -844,6 +861,7 @@ export function* importApplicationSaga( if (isApplicationUrl) { const appId = application.id; + // @ts-expect-error: defaultPageId does not exist in the application response object const pageId = application.defaultPageId; yield put({ diff --git a/app/client/src/sagas/TemplatesSagas.ts b/app/client/src/sagas/TemplatesSagas.ts index e57989b0ec..687d4eccfc 100644 --- a/app/client/src/sagas/TemplatesSagas.ts +++ b/app/client/src/sagas/TemplatesSagas.ts @@ -48,6 +48,7 @@ import { failFastApiCalls } from "./InitSagas"; import { getAllPageIdentities } from "./selectors"; const isAirgappedInstance = isAirgapped(); +const AI_DATASOURCE_NAME = "AI Datasource"; function* getAllTemplatesSaga() { try { @@ -96,12 +97,20 @@ function* importTemplateToWorkspaceSaga( payload: response.data.application, }); - if (response.data.isPartialImport) { + // Temporary fix to remove AI Datasource from the unConfiguredDatasourceList + // so we can avoid showing the AI Datasource in reconnect datasource modal + const filteredUnConfiguredDatasourceList = ( + response.data.unConfiguredDatasourceList || [] + ).filter((datasource) => datasource.name !== AI_DATASOURCE_NAME); + + if ( + response.data.isPartialImport && + filteredUnConfiguredDatasourceList.length > 0 + ) { yield put( showReconnectDatasourceModal({ application: response.data.application, - unConfiguredDatasourceList: - response.data.unConfiguredDatasourceList, + unConfiguredDatasourceList: filteredUnConfiguredDatasourceList, workspaceId: action.payload.workspaceId, }), );