From a976585517256a04dc8ef558cbbb57161dfb58d2 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Tue, 21 May 2024 12:30:26 -0400 Subject: [PATCH 1/5] fix: temp NA listing of apis --- .../src/ce/selectors/entitiesSelector.ts | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/app/client/src/ce/selectors/entitiesSelector.ts b/app/client/src/ce/selectors/entitiesSelector.ts index d827a61899c7..87aff24c51f5 100644 --- a/app/client/src/ce/selectors/entitiesSelector.ts +++ b/app/client/src/ce/selectors/entitiesSelector.ts @@ -1499,30 +1499,33 @@ export const getQuerySegmentItems = createSelector( selectDatasourceIdToNameMap, (actions, plugins, datasourceIdToNameMap) => { const pluginGroups = keyBy(plugins, "id"); - const items: EntityItem[] = actions.map((action) => { - let group; - const iconUrl = getAssetUrl( - pluginGroups[action.config.pluginId]?.iconLocation, - ); - if (action.config.pluginType === PluginType.API) { - group = isEmbeddedRestDatasource(action.config.datasource) - ? "APIs" - : datasourceIdToNameMap[action.config.datasource.id] ?? "APIs"; - } else if (action.config.pluginType === PluginType.AI) { - group = isEmbeddedAIDataSource(action.config.datasource) - ? "AI Queries" - : datasourceIdToNameMap[action.config.datasource.id] ?? "AI Queries"; - } else { - group = datasourceIdToNameMap[action.config.datasource.id]; - } - return { - icon: ActionUrlIcon(iconUrl), - title: action.config.name, - key: action.config.id, - type: action.config.pluginType, - group, - }; - }); + const items: EntityItem[] = actions + .map((action) => { + let group; + const iconUrl = getAssetUrl( + pluginGroups[action.config.pluginId]?.iconLocation, + ); + if (action.config.pluginType === PluginType.API) { + group = isEmbeddedRestDatasource(action.config.datasource) + ? "APIs" + : datasourceIdToNameMap[action.config.datasource.id] ?? "APIs"; + } else if (action.config.pluginType === PluginType.AI) { + group = isEmbeddedAIDataSource(action.config.datasource) + ? "AI Queries" + : datasourceIdToNameMap[action.config.datasource.id] ?? + "AI Queries"; + } else { + group = datasourceIdToNameMap[action.config.datasource.id]; + } + return { + icon: ActionUrlIcon(iconUrl), + title: action.config.name, + key: action.config.id, + type: action.config.pluginType, + group, + }; + }) + .filter((a) => !!a.group); return items; }, ); From eeb8f4067fd18779380c0918ba9c4bd294b5134d Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Tue, 21 May 2024 12:30:47 -0400 Subject: [PATCH 2/5] fix: padding issues --- app/client/src/pages/Editor/IDE/EditorPane/JS/Add.tsx | 1 - app/client/src/pages/Editor/IDE/EditorPane/Query/Add.tsx | 1 - .../Editor/IDE/EditorPane/components/SegmentAddHeader.tsx | 8 +------- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/client/src/pages/Editor/IDE/EditorPane/JS/Add.tsx b/app/client/src/pages/Editor/IDE/EditorPane/JS/Add.tsx index 68cce2a0da86..c469ba2a4d2c 100644 --- a/app/client/src/pages/Editor/IDE/EditorPane/JS/Add.tsx +++ b/app/client/src/pages/Editor/IDE/EditorPane/JS/Add.tsx @@ -43,7 +43,6 @@ const AddJS = ({ containerProps, innerContainerProps }: AddProps) => { data-testid="t--ide-add-pane" height="100%" justifyContent="center" - p="spaces-3" {...containerProps} > { data-testid="t--ide-add-pane" height="100%" justifyContent="center" - p="spaces-3" {...containerProps} > { return ( - + {createMessage(props.titleMessage)} From adc484fd5d400dfcf03b6ba0883baf9740baf67d Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 22 May 2024 10:48:16 -0400 Subject: [PATCH 3/5] fix tests --- .../IDE/EditorPane/Query/QueryRender.test.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx b/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx index 264586fd9a52..193df51cf722 100644 --- a/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx +++ b/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx @@ -17,6 +17,7 @@ import { getIDETestState } from "test/factories/AppIDEFactoryUtils"; import { PageFactory } from "test/factories/PageFactory"; import { screen } from "@testing-library/react"; import { GoogleSheetFactory } from "test/factories/Actions/GoogleSheetFactory"; +import { datasourceFactory } from "test/factories/DatasourceFactory"; const FeatureFlags = { rollout_side_by_side_enabled: true, @@ -299,6 +300,10 @@ describe("IDE URL rendering of Queries", () => { }); describe("Postgres Routes", () => { + const mockDS = datasourceFactory().build({ + name: "Users", + id: "PostgresDatasourceID", + }); it("Renders Postgres routes in Full Screen", async () => { const page = PageFactory.build(); const anQuery = PostgresFactory.build({ @@ -308,6 +313,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [mockDS], tabs: { [EditorEntityTab.QUERIES]: ["query_id"], [EditorEntityTab.JS]: [], @@ -355,6 +361,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [mockDS], tabs: { [EditorEntityTab.QUERIES]: ["query_id"], [EditorEntityTab.JS]: [], @@ -403,6 +410,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [mockDS], tabs: { [EditorEntityTab.QUERIES]: ["query_id"], [EditorEntityTab.JS]: [], @@ -444,6 +452,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [mockDS], tabs: { [EditorEntityTab.QUERIES]: ["query_id"], [EditorEntityTab.JS]: [], @@ -478,7 +487,7 @@ describe("IDE URL rendering of Queries", () => { getByText(createMessage(EDITOR_PANE_TEXTS.queries_create_from_existing)); getByText("New datasource"); getByText("REST API"); - // Check new tab presence + // Check the new tab presence const newTab = getByTestId("t--ide-tab-new"); expect(newTab).not.toBeNull(); // Close button is rendered @@ -489,6 +498,10 @@ describe("IDE URL rendering of Queries", () => { }); describe("Google Sheets Routes", () => { + const gsheetsDS = datasourceFactory().build({ + name: "Sheet", + id: "GoogleSheetsDatasourceID", + }); it("Renders Google Sheets routes in Full Screen", async () => { const page = PageFactory.build(); const anQuery = GoogleSheetFactory.build({ @@ -499,6 +512,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [gsheetsDS], tabs: { [EditorEntityTab.QUERIES]: ["saas_api_id"], [EditorEntityTab.JS]: [], @@ -547,6 +561,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [gsheetsDS], tabs: { [EditorEntityTab.QUERIES]: ["saas_api_id"], [EditorEntityTab.JS]: [], @@ -640,6 +655,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], + datasources: [gsheetsDS], tabs: { [EditorEntityTab.QUERIES]: ["saas_api_id"], [EditorEntityTab.JS]: [], From 6777f1f302e8bcc87c9d059038f02ebc90bf341e Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 22 May 2024 10:52:46 -0400 Subject: [PATCH 4/5] avoid magic strings --- app/client/src/ce/selectors/entitiesSelector.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/client/src/ce/selectors/entitiesSelector.ts b/app/client/src/ce/selectors/entitiesSelector.ts index 87aff24c51f5..3f10a514e572 100644 --- a/app/client/src/ce/selectors/entitiesSelector.ts +++ b/app/client/src/ce/selectors/entitiesSelector.ts @@ -1507,13 +1507,13 @@ export const getQuerySegmentItems = createSelector( ); if (action.config.pluginType === PluginType.API) { group = isEmbeddedRestDatasource(action.config.datasource) - ? "APIs" + ? GROUP_TYPES.API : datasourceIdToNameMap[action.config.datasource.id] ?? "APIs"; } else if (action.config.pluginType === PluginType.AI) { group = isEmbeddedAIDataSource(action.config.datasource) - ? "AI Queries" + ? GROUP_TYPES.AI : datasourceIdToNameMap[action.config.datasource.id] ?? - "AI Queries"; + GROUP_TYPES.AI; } else { group = datasourceIdToNameMap[action.config.datasource.id]; } From 79f202998b1f6b923befb3f29db99723a62d4214 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 22 May 2024 11:19:48 -0400 Subject: [PATCH 5/5] one more test fix --- .../IDE/EditorPane/Query/QueryRender.test.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx b/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx index 193df51cf722..7621eb60ba20 100644 --- a/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx +++ b/app/client/src/pages/Editor/IDE/EditorPane/Query/QueryRender.test.tsx @@ -498,7 +498,7 @@ describe("IDE URL rendering of Queries", () => { }); describe("Google Sheets Routes", () => { - const gsheetsDS = datasourceFactory().build({ + const gSheetsDS = datasourceFactory().build({ name: "Sheet", id: "GoogleSheetsDatasourceID", }); @@ -512,7 +512,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], - datasources: [gsheetsDS], + datasources: [gSheetsDS], tabs: { [EditorEntityTab.QUERIES]: ["saas_api_id"], [EditorEntityTab.JS]: [], @@ -561,7 +561,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], - datasources: [gsheetsDS], + datasources: [gSheetsDS], tabs: { [EditorEntityTab.QUERIES]: ["saas_api_id"], [EditorEntityTab.JS]: [], @@ -647,7 +647,7 @@ describe("IDE URL rendering of Queries", () => { }); it("Renders Google Sheets add routes in Split Screen", async () => { const page = PageFactory.build(); - const anQuery = PostgresFactory.build({ + const anQuery = GoogleSheetFactory.build({ name: "Sheets4", id: "saas_api_id", pageId: page.pageId, @@ -655,7 +655,7 @@ describe("IDE URL rendering of Queries", () => { const state = getIDETestState({ actions: [anQuery], pages: [page], - datasources: [gsheetsDS], + datasources: [gSheetsDS], tabs: { [EditorEntityTab.QUERIES]: ["saas_api_id"], [EditorEntityTab.JS]: [], @@ -675,7 +675,7 @@ describe("IDE URL rendering of Queries", () => { }, ); - // There will be 1 Api4 text ( The tab ) + // There will be 1 Sheets4 text (The tab) expect(getAllByText("Sheets4").length).toEqual(1); // Tabs active state expect( @@ -690,7 +690,7 @@ describe("IDE URL rendering of Queries", () => { getByText(createMessage(EDITOR_PANE_TEXTS.queries_create_from_existing)); getByText("New datasource"); getByText("REST API"); - // Check new tab presence + // Check the new tab presence const newTab = getByTestId("t--ide-tab-new"); expect(newTab).not.toBeNull(); // Close button is rendered