mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: create project upgrade link (#8822)
This commit is contained in:
parent
4ded068de7
commit
c927c6f32b
@ -0,0 +1,55 @@
|
|||||||
|
import { render } from 'utils/testRenderer';
|
||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import { PremiumFeature } from './PremiumFeature';
|
||||||
|
|
||||||
|
test('Show plans comparison message and link by default - with tooltip', async () => {
|
||||||
|
render(<PremiumFeature feature='environments' tooltip={true} />);
|
||||||
|
|
||||||
|
const link = screen.getByText('Compare plans');
|
||||||
|
|
||||||
|
expect(link).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'https://www.getunleash.io/plans?feature=environments',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Show plans comparison message and link by default - without tooltip', async () => {
|
||||||
|
render(<PremiumFeature feature='environments' tooltip={false} />);
|
||||||
|
|
||||||
|
const link = screen.getByText('Compare plans');
|
||||||
|
|
||||||
|
expect(link).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'https://www.getunleash.io/plans?feature=environments',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Show upgrade message and link - with tooltip', async () => {
|
||||||
|
render(
|
||||||
|
<PremiumFeature feature='environments' tooltip={true} mode='upgrade' />,
|
||||||
|
);
|
||||||
|
|
||||||
|
const link = screen.getByText('View our Enterprise offering');
|
||||||
|
|
||||||
|
expect(link).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'https://www.getunleash.io/upgrade_unleash?utm_source=environments',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Show upgrade message and link - without tooltip', async () => {
|
||||||
|
render(
|
||||||
|
<PremiumFeature
|
||||||
|
feature='environments'
|
||||||
|
tooltip={false}
|
||||||
|
mode='upgrade'
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const link = screen.getByText('View our Enterprise offering');
|
||||||
|
|
||||||
|
expect(link).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'https://www.getunleash.io/upgrade_unleash?utm_source=environments',
|
||||||
|
);
|
||||||
|
});
|
@ -54,7 +54,7 @@ enum FeaturePlan {
|
|||||||
|
|
||||||
const PremiumFeatures = {
|
const PremiumFeatures = {
|
||||||
'adding-new-projects': {
|
'adding-new-projects': {
|
||||||
plan: FeaturePlan.PRO,
|
plan: FeaturePlan.ENTERPRISE,
|
||||||
url: '',
|
url: '',
|
||||||
label: 'Adding new projects',
|
label: 'Adding new projects',
|
||||||
},
|
},
|
||||||
@ -68,11 +68,6 @@ const PremiumFeatures = {
|
|||||||
url: 'https://docs.getunleash.io/reference/change-requests',
|
url: 'https://docs.getunleash.io/reference/change-requests',
|
||||||
label: 'Change Requests',
|
label: 'Change Requests',
|
||||||
},
|
},
|
||||||
segments: {
|
|
||||||
plan: FeaturePlan.PRO,
|
|
||||||
url: 'https://docs.getunleash.io/reference/segments',
|
|
||||||
label: 'Segments',
|
|
||||||
},
|
|
||||||
'service-accounts': {
|
'service-accounts': {
|
||||||
plan: FeaturePlan.ENTERPRISE,
|
plan: FeaturePlan.ENTERPRISE,
|
||||||
url: 'https://docs.getunleash.io/reference/service-accounts',
|
url: 'https://docs.getunleash.io/reference/service-accounts',
|
||||||
@ -137,18 +132,21 @@ const PremiumFeatures = {
|
|||||||
|
|
||||||
type PremiumFeatureType = keyof typeof PremiumFeatures;
|
type PremiumFeatureType = keyof typeof PremiumFeatures;
|
||||||
|
|
||||||
const UPGRADE_URL = 'https://www.getunleash.io/plans';
|
const PLANS_URL = 'https://www.getunleash.io/plans';
|
||||||
|
const UPGRADE_URL = 'https://www.getunleash.io/upgrade_unleash';
|
||||||
|
|
||||||
export interface PremiumFeatureProps {
|
export interface PremiumFeatureProps {
|
||||||
feature: PremiumFeatureType;
|
feature: PremiumFeatureType;
|
||||||
tooltip?: boolean;
|
tooltip?: boolean;
|
||||||
page?: boolean;
|
page?: boolean;
|
||||||
|
mode?: 'plans' | 'upgrade';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PremiumFeature = ({
|
export const PremiumFeature = ({
|
||||||
feature,
|
feature,
|
||||||
tooltip,
|
tooltip,
|
||||||
page,
|
page,
|
||||||
|
mode = 'plans',
|
||||||
}: PremiumFeatureProps) => {
|
}: PremiumFeatureProps) => {
|
||||||
const { url, plan, label } = PremiumFeatures[feature];
|
const { url, plan, label } = PremiumFeatures[feature];
|
||||||
|
|
||||||
@ -182,7 +180,8 @@ export const PremiumFeature = ({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const upgradeUrl = `${UPGRADE_URL}?feature=${feature}`;
|
const plansUrl = `${PLANS_URL}?feature=${feature}`;
|
||||||
|
const upgradeUrl = `${UPGRADE_URL}?utm_source=${feature}`;
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<PremiumFeatureWrapper tooltip={tooltip}>
|
<PremiumFeatureWrapper tooltip={tooltip}>
|
||||||
@ -204,14 +203,23 @@ export const PremiumFeature = ({
|
|||||||
</StyledTypography>
|
</StyledTypography>
|
||||||
</StyledBody>
|
</StyledBody>
|
||||||
<StyledButtonContainer>
|
<StyledButtonContainer>
|
||||||
<StyledLink
|
{mode === 'plans' ? (
|
||||||
href={upgradeUrl}
|
<StyledLink
|
||||||
target='_blank'
|
href={plansUrl}
|
||||||
rel='noreferrer'
|
target='_blank'
|
||||||
onClick={trackUpgradePlan}
|
onClick={trackUpgradePlan}
|
||||||
>
|
>
|
||||||
Compare plans
|
Compare plans
|
||||||
</StyledLink>
|
</StyledLink>
|
||||||
|
) : (
|
||||||
|
<StyledLink
|
||||||
|
href={upgradeUrl}
|
||||||
|
target='_blank'
|
||||||
|
onClick={trackUpgradePlan}
|
||||||
|
>
|
||||||
|
View our Enterprise offering
|
||||||
|
</StyledLink>
|
||||||
|
)}
|
||||||
</StyledButtonContainer>
|
</StyledButtonContainer>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@ -227,15 +235,26 @@ export const PremiumFeature = ({
|
|||||||
</StyledTypography>
|
</StyledTypography>
|
||||||
</StyledBody>
|
</StyledBody>
|
||||||
<StyledButtonContainer>
|
<StyledButtonContainer>
|
||||||
<Button
|
{mode === 'plans' ? (
|
||||||
variant='contained'
|
<Button
|
||||||
href={upgradeUrl}
|
variant='contained'
|
||||||
target='_blank'
|
href={plansUrl}
|
||||||
rel='noreferrer'
|
target='_blank'
|
||||||
onClick={trackUpgradePlan}
|
onClick={trackUpgradePlan}
|
||||||
>
|
>
|
||||||
Compare plans
|
Compare plans
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
variant='contained'
|
||||||
|
href={upgradeUrl}
|
||||||
|
target='_blank'
|
||||||
|
onClick={trackUpgradePlan}
|
||||||
|
>
|
||||||
|
View our Enterprise offering
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
href={url}
|
href={url}
|
||||||
target='_blank'
|
target='_blank'
|
||||||
|
@ -22,13 +22,18 @@ const NAVIGATE_TO_CREATE_PROJECT = 'NAVIGATE_TO_CREATE_PROJECT';
|
|||||||
function resolveCreateButtonData(
|
function resolveCreateButtonData(
|
||||||
isOss: boolean,
|
isOss: boolean,
|
||||||
hasAccess: boolean,
|
hasAccess: boolean,
|
||||||
|
mode: 'plans' | 'upgrade' = 'plans',
|
||||||
): ICreateButtonData {
|
): ICreateButtonData {
|
||||||
if (isOss) {
|
if (isOss) {
|
||||||
return {
|
return {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
titleComponent: (
|
titleComponent: (
|
||||||
<PremiumFeature feature='adding-new-projects' tooltip />
|
<PremiumFeature
|
||||||
|
feature='adding-new-projects'
|
||||||
|
mode={mode}
|
||||||
|
tooltip
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
sx: { maxWidth: '320px' },
|
sx: { maxWidth: '320px' },
|
||||||
variant: 'custom',
|
variant: 'custom',
|
||||||
@ -70,6 +75,7 @@ export const ProjectCreationButton: FC<ProjectCreationButtonProps> = ({
|
|||||||
const createButtonData = resolveCreateButtonData(
|
const createButtonData = resolveCreateButtonData(
|
||||||
isOss(),
|
isOss(),
|
||||||
hasAccess(CREATE_PROJECT),
|
hasAccess(CREATE_PROJECT),
|
||||||
|
'upgrade',
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user