From 17cb7bc30e68640f00fbdef6f646653423fced85 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Thu, 25 Apr 2024 10:38:19 +0530 Subject: [PATCH] fix: Check page permission to show widget add panel (#32913) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description When the user does not have permission to edit a page, they should not be shown the widget pane with widgets Fixes #32708 ## Automation /ok-to-test tags="@tag.IDE, @tag.AccessControl" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 113a1477b4cfb3727ad392b83633ba878c90188f > Cypress dashboard url: Click here! ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ x ] No ## Summary by CodeRabbit - **New Features** - Enhanced security by implementing permission checks before rendering widgets in the editor UI. --- .../pages/Editor/IDE/EditorPane/UI/index.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/client/src/pages/Editor/IDE/EditorPane/UI/index.tsx b/app/client/src/pages/Editor/IDE/EditorPane/UI/index.tsx index d8e7e90c70..73552867fc 100644 --- a/app/client/src/pages/Editor/IDE/EditorPane/UI/index.tsx +++ b/app/client/src/pages/Editor/IDE/EditorPane/UI/index.tsx @@ -13,11 +13,28 @@ import { } from "constants/routes"; import ListWidgets from "./List"; import AddWidgets from "./Add"; +import { useSelector } from "react-redux"; +import { getPagePermissions } from "selectors/editorSelectors"; +import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; +import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; +import { getHasManagePagePermission } from "@appsmith/utils/BusinessFeatures/permissionPageHelpers"; const UISegment = () => { const { path } = useRouteMatch(); const [focusSearchInput, setFocusSearchInput] = React.useState(false); + const pagePermissions = useSelector(getPagePermissions); + const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled); + + const canManagePages = getHasManagePagePermission( + isFeatureEnabled, + pagePermissions, + ); + + if (!canManagePages) { + return ; + } + return (