Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## About the changes ![image](https://github.com/Unleash/unleash/assets/2625371/afaaaedf-4539-4a0b-a0fb-916d858ac6d3) https://linear.app/unleash/issue/1-1038/strategy-creation-split-into-two-buttons
- Loading branch information
Showing
8 changed files
with
284 additions
and
79 deletions.
There are no files selected for viewing
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
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
70 changes: 70 additions & 0 deletions
70
...d/src/component/feature/FeatureStrategy/FeatureStrategyMenu/LegacyFeatureStrategyMenu.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,70 @@ | ||
import React, { useState } from 'react'; | ||
import PermissionButton, { | ||
IPermissionButtonProps, | ||
} from 'component/common/PermissionButton/PermissionButton'; | ||
import { CREATE_FEATURE_STRATEGY } from 'component/providers/AccessProvider/permissions'; | ||
import { Popover } from '@mui/material'; | ||
import { FeatureStrategyMenuCards } from './FeatureStrategyMenuCards/FeatureStrategyMenuCards'; | ||
|
||
interface IFeatureStrategyMenuProps { | ||
label: string; | ||
projectId: string; | ||
featureId: string; | ||
environmentId: string; | ||
variant?: IPermissionButtonProps['variant']; | ||
matchWidth?: boolean; | ||
} | ||
|
||
/** | ||
* Remove when removing feature flag strategySplittedButton | ||
* @deprecated | ||
*/ | ||
export const LegacyFeatureStrategyMenu = ({ | ||
label, | ||
projectId, | ||
featureId, | ||
environmentId, | ||
variant, | ||
matchWidth, | ||
}: IFeatureStrategyMenuProps) => { | ||
const [anchor, setAnchor] = useState<Element>(); | ||
const isPopoverOpen = Boolean(anchor); | ||
const popoverId = isPopoverOpen ? 'FeatureStrategyMenuPopover' : undefined; | ||
|
||
const onClose = () => { | ||
setAnchor(undefined); | ||
}; | ||
|
||
const onClick = (event: React.SyntheticEvent) => { | ||
setAnchor(event.currentTarget); | ||
}; | ||
|
||
return ( | ||
<div onClick={event => event.stopPropagation()}> | ||
<PermissionButton | ||
permission={CREATE_FEATURE_STRATEGY} | ||
projectId={projectId} | ||
environmentId={environmentId} | ||
onClick={onClick} | ||
aria-labelledby={popoverId} | ||
variant={variant} | ||
sx={{ minWidth: matchWidth ? '282px' : 'auto' }} | ||
> | ||
{label} | ||
</PermissionButton> | ||
<Popover | ||
id={popoverId} | ||
open={isPopoverOpen} | ||
anchorEl={anchor} | ||
onClose={onClose} | ||
onClick={onClose} | ||
> | ||
<FeatureStrategyMenuCards | ||
projectId={projectId} | ||
featureId={featureId} | ||
environmentId={environmentId} | ||
/> | ||
</Popover> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.