Skip to content

Commit

Permalink
Feat/add enterprise badge to change req settings (#2585)
Browse files Browse the repository at this point in the history
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Disable change requests for Pro and oss
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
  • Loading branch information
3 people committed Dec 6, 2022
1 parent cfc347f commit 7af155f
Show file tree
Hide file tree
Showing 8 changed files with 548 additions and 390 deletions.
86 changes: 86 additions & 0 deletions frontend/src/component/common/PremiumFeature/PremiumFeature.tsx
@@ -0,0 +1,86 @@
import { ReactComponent as ProPlanIcon } from 'assets/icons/pro-enterprise-feature-badge.svg';
import { Box, Link, styled, Typography } from '@mui/material';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';

const PremiumFeatureWrapper = styled(Box)(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
padding: theme.spacing(1, 0.5),
}));

const StyledTitle = styled(Typography)(({ theme }) => ({
display: 'inline-flex',
alignItems: 'center',
fontWeight: theme.fontWeight.bold,
fontSize: theme.fontSizes.smallBody,
gap: theme.spacing(1),
}));

const StyledBody = styled(Typography)(({ theme }) => ({
fontSize: theme.fontSizes.smallBody,
margin: theme.spacing(1, 0),
}));

const StyledLink = styled(Link)(({ theme }) => ({
fontSize: theme.fontSizes.smallBody,
width: 'fit-content',
}));

enum FeatureLevelTitle {
PRO = 'Pro & Enterprise feature',
ENTERPRISE = 'Enterprise feature',
}

export enum PlausibleOrigin {
PROJECT = 'Projects',
ACCESS = 'Access',
CHANGE_REQUEST = 'Change Request',
}

export interface PremiumFeatureProps {
children: React.ReactNode;
origin?: PlausibleOrigin;
center?: boolean;
enterpriseOnly?: boolean;
}

export const PremiumFeature = ({
children,
origin,
center,
enterpriseOnly = false,
}: PremiumFeatureProps) => {
const tracker = usePlausibleTracker();

const handleClick = () => {
if (origin) {
tracker.trackEvent('upgrade_plan_clicked', {
props: { origin },
});
}
};

return (
<PremiumFeatureWrapper
sx={{
alignItems: center ? 'center' : 'start',
textAlign: center ? 'center' : 'left',
}}
>
<StyledTitle>
<ProPlanIcon />
{enterpriseOnly
? FeatureLevelTitle.ENTERPRISE
: FeatureLevelTitle.PRO}
</StyledTitle>
<StyledBody>{children}</StyledBody>
<StyledLink
href={'https://www.getunleash.io/plans'}
target="_blank"
onClick={handleClick}
>
Upgrade now
</StyledLink>
</PremiumFeatureWrapper>
);
};

This file was deleted.

@@ -1,25 +1,36 @@
import { styled } from '@mui/material';
import { Button, styled } from '@mui/material';

const StyledTab = styled('button')<{ selected: boolean }>(
const StyledTab = styled(Button)<{ selected: boolean }>(
({ theme, selected }) => ({
cursor: 'pointer',
border: 0,
backgroundColor: selected
? theme.palette.background.paper
: 'transparent',
borderLeft: `${theme.spacing(1)} solid ${
selected ? theme.palette.primary.main : 'transparent'
}`,
borderRadius: theme.shape.borderRadiusMedium,
padding: theme.spacing(2, 4),
color: theme.palette.text.primary,
fontSize: theme.fontSizes.bodySize,
fontWeight: selected ? theme.fontWeight.bold : theme.fontWeight.medium,
textAlign: 'left',
transition: 'background-color 0.2s ease',
'&.MuiButton-root': {
cursor: 'pointer',
height: theme.spacing(6.5),
border: 0,
backgroundColor: selected
? theme.palette.background.paper
: 'transparent',
borderLeft: `${theme.spacing(1)} solid ${
selected ? theme.palette.primary.main : 'transparent'
}`,
borderRadius: theme.shape.borderRadiusMedium,
justifyContent: 'start',
transition: 'background-color 0.2s ease',
color: theme.palette.text.primary,
textAlign: 'left',
padding: theme.spacing(2, 4),
fontSize: theme.fontSizes.bodySize,
fontWeight: selected
? theme.fontWeight.bold
: theme.fontWeight.medium,
lineHeight: 1.2,
},
'&:hover': {
backgroundColor: theme.palette.neutral.light,
},
'&.Mui-disabled': {
pointerEvents: 'auto',
},
justifyContent: 'space-between',
})
);

Expand All @@ -34,7 +45,15 @@ export const VerticalTab = ({
selected,
onClick,
}: IVerticalTabProps) => (
<StyledTab selected={Boolean(selected)} onClick={onClick}>
<StyledTab
selected={Boolean(selected)}
onClick={onClick}
disableRipple
disableElevation
disableFocusRipple
disableTouchRipple
fullWidth
>
{label}
</StyledTab>
);

0 comments on commit 7af155f

Please sign in to comment.