1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-04 00:18:40 +01:00

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)
This commit is contained in:
Gastón Fournier 2025-03-03 17:11:50 +01:00 committed by GitHub
parent f3ede7681f
commit 4ae09fdb05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -278,7 +278,7 @@ const copyButtonsActiveInOtherEnv = async () => {
// production // production
const productionStrategyCopyButton = copyButtons[0]; const productionStrategyCopyButton = copyButtons[0];
expect(productionStrategyCopyButton).toBeDisabled(); expect(productionStrategyCopyButton).toBeEnabled();
// custom env // custom env
const customEnvStrategyCopyButton = copyButtons[1]; const customEnvStrategyCopyButton = copyButtons[1];

View File

@ -95,11 +95,11 @@ export const CopyStrategyIconMenu: VFC<ICopyStrategyIconMenuProps> = ({
onClose(); onClose();
}; };
const enabled = environments.some((environment) => const enabled = [...environments, environmentId].some((environment) =>
checkAccess(CREATE_FEATURE_STRATEGY, 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 ( return (
<div> <div>