From 4ae09fdb055e8ba8bec02768d53aa5dbe3a044ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Mon, 3 Mar 2025 17:11:50 +0100 Subject: [PATCH] fix: copy strategy is allowed to copy to self (duplicate) (#9407) When checking for permissions we were checking if the user was allowed to copy to other environments but it can also copy to the same environment. Before the change: ![image](https://github.com/user-attachments/assets/3bb1b738-8a4b-4c1b-b45f-c48895454c0a) After the change: ![image](https://github.com/user-attachments/assets/869e0fed-b7da-436c-93b4-fc50b6830e45) --- .../component/changeRequest/ChangeRequestPermissions.test.tsx | 2 +- .../CopyStrategyIconMenu/CopyStrategyIconMenu.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx b/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx index 65af54ff10..7aa2c57288 100644 --- a/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx @@ -278,7 +278,7 @@ const copyButtonsActiveInOtherEnv = async () => { // production const productionStrategyCopyButton = copyButtons[0]; - expect(productionStrategyCopyButton).toBeDisabled(); + expect(productionStrategyCopyButton).toBeEnabled(); // custom env const customEnvStrategyCopyButton = copyButtons[1]; diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/CopyStrategyIconMenu/CopyStrategyIconMenu.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/CopyStrategyIconMenu/CopyStrategyIconMenu.tsx index 0497624f28..e67ef49c34 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/CopyStrategyIconMenu/CopyStrategyIconMenu.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/CopyStrategyIconMenu/CopyStrategyIconMenu.tsx @@ -95,11 +95,11 @@ export const CopyStrategyIconMenu: VFC = ({ onClose(); }; - const enabled = environments.some((environment) => + const enabled = [...environments, environmentId].some((environment) => checkAccess(CREATE_FEATURE_STRATEGY, environment), ); - const label = `Copy to environment${enabled ? '' : ' (Access denied)'}`; + const label = `Copy to environment${enabled ? '' : ` (Access denied, missing ${CREATE_FEATURE_STRATEGY} permission)`}`; return (