From 5855115abb5a1193c12f761af1b4accf7258c780 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Mon, 23 Dec 2024 20:27:36 +0530 Subject: [PATCH] chore: Adding no access state for Datasource tab based on permissions given via GAC (#38268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - Today, when a user gives only View/Edit access to a Datasource, the schema tables are still being seen on the Datasource tabs while it doesn't show on the Datasource Editor page. This has been fixed with this PR. It should only be seen when Datasource has create action permissions, hence we show the "We can’t show the schema for this datasource" screen in this case. - When the user has not given View access to a Datasource, the UI is broken in Datasource tab. This has been fixed with this PR. We now show the No access state in this case. **BEFORE**: When view access is not given: Screenshot 2024-12-20 at 5 52 58 PM When create action permission is not given but view access is given: Screenshot 2024-12-20 at 5 54 10 PM **AFTER**: When view access is not given: Screenshot 2024-12-20 at 5 58 22 PM When create action permission is not given but view access is given: Screenshot 2024-12-20 at 5 57 53 PM Fixes [#38093](https://github.com/appsmithorg/appsmith/issues/38093) ## Automation /ok-to-test tags="@tag.Sanity, @tag.Datasource, @tag.IDE, @tag.JS, @tag.Git" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: ee5bc1774c02b4b29a702c8baefbad35390708c3 > Cypress dashboard. > Tags: `@tag.Sanity, @tag.Datasource, @tag.IDE, @tag.JS, @tag.Git` > Spec: >
Mon, 23 Dec 2024 08:29:06 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Introduced new icons and improved conditional rendering for datasource components. - Added a "not found" message for empty datasource options. - Enhanced user feedback with clearer messaging for missing resources. - **Bug Fixes** - Adjusted rendering logic to ensure edit buttons only appear when both conditions are met. - **Enhancements** - Improved permission checks and logic for managing datasource visibility. - Streamlined component logic for better readability and maintainability. - Enhanced error handling practices in saga functions. - **Tests** - Simplified test structure by removing unnecessary context providers. - **Chores** - Updated import statements and component names for consistency. --- .../DatasourceTab/CurrentDataSource.tsx | 24 ++- .../DatasourceTab/CurrentDataSourceLink.tsx | 7 +- .../DatasourceTab/DatasourceInfo.tsx | 2 +- .../PluginDatasourceSelector.tsx | 20 ++- .../DatasourceSelector/index.tsx | 11 +- .../{Datasource.tsx => DatasourceTab.tsx} | 70 +++++--- .../components/DatasourceTab/index.tsx | 2 +- .../hooks/usePluginActionResponseTabs.tsx | 14 +- app/client/src/ce/constants/messages.ts | 1 + .../src/ce/selectors/appIDESelectors.ts | 8 +- .../src/ce/selectors/entitiesSelector.ts | 4 +- .../permissionPageHelpers.tsx | 11 ++ app/client/src/ce/utils/permissionHelpers.tsx | 3 + .../IDE/EditorPane/Query/QueryRender.test.tsx | 41 +---- app/client/src/pages/Editor/IDE/hooks.ts | 12 +- .../Editor/QueryEditor/QueryDebuggerTabs.tsx | 8 +- app/client/src/sagas/DatasourcesSagas.ts | 150 ++++++++++-------- 17 files changed, 217 insertions(+), 171 deletions(-) rename app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/{Datasource.tsx => DatasourceTab.tsx} (72%) diff --git a/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSource.tsx b/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSource.tsx index e2ed7ece14..59ed5b49a2 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSource.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSource.tsx @@ -1,32 +1,30 @@ import React from "react"; -import { Flex } from "@appsmith/ads"; +import { Flex, Icon } from "@appsmith/ads"; import { getAssetUrl } from "ee/utils/airgapHelpers"; import { EntityIcon } from "pages/Editor/Explorer/ExplorerIcons"; import { useSelector } from "react-redux"; -import { - getPluginIdFromDatasourceId, - getPluginImages, -} from "ee/selectors/entitiesSelector"; +import { getPluginImages } from "ee/selectors/entitiesSelector"; interface Props { - datasourceId: string; datasourceName: string; + pluginId: string; } -const CurrentDataSource = ({ datasourceId, datasourceName }: Props) => { - const { pluginId, pluginImages } = useSelector((state) => ({ - pluginId: getPluginIdFromDatasourceId(state, datasourceId), - pluginImages: getPluginImages(state), - })); +const CurrentDataSource = ({ datasourceName, pluginId }: Props) => { + const pluginImages = useSelector((state) => getPluginImages(state)); const datasourceIcon = pluginId ? pluginImages?.[pluginId] : undefined; return ( - entityIcon + {datasourceIcon ? ( + entityIcon + ) : ( + + )} - {datasourceName} + {datasourceName || "NA"} ); }; diff --git a/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSourceLink.tsx b/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSourceLink.tsx index 8ba3acdf1e..e23378a474 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSourceLink.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/CurrentDataSourceLink.tsx @@ -6,9 +6,11 @@ import { useGoToDatasource } from "PluginActionEditor/components/PluginActionRes const CurrentDataSourceLink = ({ datasourceId, datasourceName, + pluginId, }: { datasourceId: string; datasourceName: string; + pluginId: string; }) => { const { goToDatasource } = useGoToDatasource(); @@ -19,10 +21,7 @@ const CurrentDataSourceLink = ({ return ( - + ); }; diff --git a/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx b/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx index acfa335718..6c4dac8e1c 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionResponse/components/DatasourceTab/DatasourceInfo.tsx @@ -55,7 +55,7 @@ const DatasourceInfo = ({ datasourceName={datasourceName} plugin={plugin} /> - {showEditButton && ( + {showEditButton && datasourceName && (