From 04cbb8591521a1f7444523b7f4d5353aca5f181a Mon Sep 17 00:00:00 2001 From: sneha122 Date: Wed, 22 Nov 2023 12:41:16 +0530 Subject: [PATCH] fix: order of plugins in most popular section fixed (#28957) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR fixes the order of plugins in most popular datasource section in create new datasource page, The correct order should be Gsheets, REST, Postgres, MySQL, MongoDB #### PR fixes following issue(s) Fixes #28931 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: “sneha122” <“sneha@appsmith.com”> --- .../src/ce/selectors/entitiesSelector.ts | 37 +++++++++++++---- .../CreateNewDatasourceTab.tsx | 30 ++++++++------ .../IntegrationEditor/DatasourceHome.tsx | 41 ++++++++++--------- 3 files changed, 67 insertions(+), 41 deletions(-) diff --git a/app/client/src/ce/selectors/entitiesSelector.ts b/app/client/src/ce/selectors/entitiesSelector.ts index eb16e38109..27ecd96ee7 100644 --- a/app/client/src/ce/selectors/entitiesSelector.ts +++ b/app/client/src/ce/selectors/entitiesSelector.ts @@ -46,6 +46,7 @@ import { getFormValues } from "redux-form"; import { TEMP_DATASOURCE_ID } from "constants/Datasource"; import { MAX_DATASOURCE_SUGGESTIONS } from "pages/Editor/Explorer/hooks"; import type { Module } from "@appsmith/constants/ModuleConstants"; +import type { Plugin } from "api/PluginApi"; export const getEntities = (state: AppState): AppState["entities"] => state.entities; @@ -393,15 +394,33 @@ export const getDBPlugins = createSelector(getPlugins, (plugins) => // Most popular datasources are hardcoded right now to include these 4 plugins and REST API // Going forward we may want to have separate list for each instance based on usage -export const getMostPopularPlugins = createSelector(getPlugins, (plugins) => - plugins.filter( - (plugin) => - plugin.packageName === PluginPackageName.POSTGRES || - plugin.packageName === PluginPackageName.MY_SQL || - plugin.packageName === PluginPackageName.MONGO || - plugin.packageName === PluginPackageName.GOOGLE_SHEETS, - ), -); +export const getMostPopularPlugins = createSelector(getPlugins, (plugins) => { + const popularPlugins: Plugin[] = []; + + const gsheetPlugin = plugins.find( + (plugin) => plugin.packageName === PluginPackageName.GOOGLE_SHEETS, + ); + const restPlugin = plugins.find( + (plugin) => plugin.packageName === PluginPackageName.REST_API, + ); + const postgresPlugin = plugins.find( + (plugin) => plugin.packageName === PluginPackageName.POSTGRES, + ); + const mysqlPlugin = plugins.find( + (plugin) => plugin.packageName === PluginPackageName.MY_SQL, + ); + const mongoPlugin = plugins.find( + (plugin) => plugin.packageName === PluginPackageName.MONGO, + ); + + gsheetPlugin && popularPlugins.push(gsheetPlugin); + restPlugin && popularPlugins.push(restPlugin); + postgresPlugin && popularPlugins.push(postgresPlugin); + mysqlPlugin && popularPlugins.push(mysqlPlugin); + mongoPlugin && popularPlugins.push(mongoPlugin); + + return popularPlugins; +}); export const getDBAndRemotePlugins = createSelector(getPlugins, (plugins) => plugins.filter( diff --git a/app/client/src/pages/Editor/IntegrationEditor/CreateNewDatasourceTab.tsx b/app/client/src/pages/Editor/IntegrationEditor/CreateNewDatasourceTab.tsx index c2d9252059..ec85cfd280 100644 --- a/app/client/src/pages/Editor/IntegrationEditor/CreateNewDatasourceTab.tsx +++ b/app/client/src/pages/Editor/IntegrationEditor/CreateNewDatasourceTab.tsx @@ -258,19 +258,25 @@ class CreateNewDatasourceTab extends React.Component< !this.props.currentApplicationIdForCreateNewApp && ( )} - {dataSources.length === 0 && - this.props.mockDatasources.length > 0 && - mockDataSection} + {dataSources.length === 0 && this.props.mockDatasources.length > 0 && ( + <> + {mockDataSection} + + + )} {isEnabledForStartWithData && ( - + <> + + + )} { {plugins.map((plugin, idx) => { - return ( + return plugin.type === PluginType.API ? ( + !!showMostPopularPlugins ? ( + this.handleOnClick()} + > + + New +

+ {createMessage(CREATE_NEW_DATASOURCE_REST_API)} +

+
+ {isCreating && } +
+ ) : null + ) : ( { ); })} - {!!showMostPopularPlugins ? ( - this.handleOnClick()} - > - - New -

- {createMessage(CREATE_NEW_DATASOURCE_REST_API)} -

-
- {isCreating && } -
- ) : null}
);