Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use the correct hook for permissions and CR (#3050)
## About the changes When checking for permissions we have 2 methods, one that is not change request aware and one that is. We were using the one that is not aware of CR while the feature we developed is aware of CR. This PR switches to the correct method and documents the hooks
- Loading branch information
Gastón Fournier
committed
Feb 6, 2023
1 parent
e7f68ee
commit fbd2d99
Showing
3 changed files
with
53 additions
and
28 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...tureVariants/FeatureEnvironmentVariants/PushVariantsButton/PermissionCheckboxMenuItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FC } from 'react'; | ||
import { useHasProjectEnvironmentAccess } from 'hooks/useHasAccess'; | ||
import { Checkbox, MenuItem } from '@mui/material'; | ||
|
||
interface PermissionCheckboxMenuItemProps { | ||
permission: string | string[]; | ||
projectId: string; | ||
environment: string; | ||
checked: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
export const PermissionCheckboxMenuItem: FC< | ||
PermissionCheckboxMenuItemProps | ||
> = ({ permission, projectId, environment, checked, onClick, ...props }) => { | ||
const hasPermissions = useHasProjectEnvironmentAccess( | ||
permission, | ||
projectId, | ||
environment | ||
); | ||
|
||
return ( | ||
<MenuItem disabled={!hasPermissions} onClick={onClick} {...props}> | ||
<Checkbox checked={checked} /> | ||
{environment} | ||
</MenuItem> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters