Skip to content

Commit 4945840

Browse files
committed
feat: handle license card expiry states for freemium
1 parent 6118d11 commit 4945840

4 files changed

Lines changed: 73 additions & 48 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.19.0-beta-4",
3+
"version": "1.19.0-beta-5",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/License/DevtronLicenseCard.tsx

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ import './licenseCard.scss'
3434

3535
const DAMPEN_FACTOR = 50
3636

37+
const ContactSupportButton = () => (
38+
<Button
39+
dataTestId="contact-support"
40+
startIcon={<ICChatSupport />}
41+
text="Contact support"
42+
variant={ButtonVariantType.text}
43+
component={ButtonComponentType.anchor}
44+
anchorProps={{ href: CONTACT_SUPPORT_LINK }}
45+
/>
46+
)
47+
3748
const LicenseCardSubText = ({
3849
isFreemium,
3950
licenseStatus,
@@ -43,34 +54,29 @@ const LicenseCardSubText = ({
4354
return null
4455
}
4556

46-
const isLicenseValid = licenseStatus !== LicenseStatus.EXPIRED && !licenseStatusError
4757
const freemiumLimitReached = licenseStatusError?.code === LicensingErrorCodes.ClusterLimitExceeded
4858

49-
return licenseStatus !== LicenseStatus.ACTIVE ? (
50-
<div className="p-16 fs-13 lh-1-5 flexbox-col dc__gap-8">
51-
<div className="flexbox dc__gap-8">
52-
{freemiumLimitReached ? (
53-
<div className="flexbox-col dc__gap-4 fs-13 fw-4 lh-20 cn-9">
54-
<span className="fw-6">Multiple Clusters Detected</span>
55-
<span>
56-
Your account is connected to multiple clusters, which isn’t allowed on the freemium plan.
57-
Upgrade to an Enterprise license or contact us.
58-
</span>
59-
</div>
60-
) : (
61-
<span>
62-
To renew your license mail us at&nbsp;
63-
<a href={`mailto:${ENTERPRISE_SUPPORT_LINK}`}>{ENTERPRISE_SUPPORT_LINK}</a> or contact your
64-
Devtron representative.
65-
</span>
66-
)}
67-
<Icon
68-
name={isLicenseValid ? 'ic-timer' : 'ic-error'}
69-
color={isLicenseValid ? 'Y500' : 'R500'}
70-
size={16}
71-
/>
72-
</div>
73-
{freemiumLimitReached && (
59+
if (licenseStatus === LicenseStatus.ACTIVE && isFreemium) {
60+
return (
61+
<div className="p-16 fs-13 lh-1-5 flexbox-col dc__gap-8">
62+
<div className="flexbox dc__gap-8 dc__content-space fs-13 fw-4 lh-20 cn-9">
63+
{freemiumLimitReached ? (
64+
<div className="flexbox-col dc__gap-4">
65+
<span className="fw-6">Multiple Clusters Detected</span>
66+
<span>
67+
Your account is connected to multiple clusters, which isn’t allowed on the freemium
68+
plan. Upgrade to an Enterprise license or contact us.
69+
</span>
70+
</div>
71+
) : (
72+
<span className="fw-6">Unlimited single cluster usage</span>
73+
)}
74+
<Icon
75+
name={freemiumLimitReached ? 'ic-error' : 'ic-success'}
76+
color={freemiumLimitReached ? 'R500' : 'G500'}
77+
size={20}
78+
/>
79+
</div>
7480
<div className="mail-support">
7581
<Button
7682
dataTestId="mail-support"
@@ -81,20 +87,28 @@ const LicenseCardSubText = ({
8187
anchorProps={{ href: `mailto:${ENTERPRISE_SUPPORT_LINK}` }}
8288
/>
8389
</div>
84-
)}
85-
<Button
86-
dataTestId="contact-support"
87-
startIcon={<ICChatSupport />}
88-
text="Contact support"
89-
variant={ButtonVariantType.text}
90-
component={ButtonComponentType.anchor}
91-
anchorProps={{ href: CONTACT_SUPPORT_LINK }}
92-
/>
93-
</div>
94-
) : (
95-
<div className="flexbox p-16 cn-9 fw-6 fs-13 lh-1-5 dc__align-items-center dc__content-space">
96-
<span>Unlimited single cluster usage</span>
97-
<Icon name="ic-success" size={20} color={null} />
90+
<ContactSupportButton />
91+
</div>
92+
)
93+
}
94+
95+
const isLicenseExpired = licenseStatus === LicenseStatus.EXPIRED
96+
97+
return (
98+
<div className="p-16 fs-13 lh-1-5 flexbox-col dc__gap-8">
99+
<div className="flexbox dc__gap-8 dc__content-space">
100+
<span>
101+
To renew your license mail us at&nbsp;
102+
<a href={`mailto:${ENTERPRISE_SUPPORT_LINK}`}>{ENTERPRISE_SUPPORT_LINK}</a> or contact your Devtron
103+
representative.
104+
</span>
105+
<Icon
106+
name={isLicenseExpired ? 'ic-error' : 'ic-timer'}
107+
color={isLicenseExpired ? 'R500' : 'Y500'}
108+
size={16}
109+
/>
110+
</div>
111+
<ContactSupportButton />
98112
</div>
99113
)
100114
}
@@ -112,7 +126,7 @@ export const DevtronLicenseCard = ({
112126
handleCopySuccess,
113127
licenseStatusError,
114128
}: DevtronLicenseCardProps) => {
115-
const { bgColor, textColor } = getLicenseColorsAccordingToStatus(licenseStatus)
129+
const { bgColor, textColor } = getLicenseColorsAccordingToStatus({ isFreemium, licenseStatus, licenseStatusError })
116130
const remainingTime = getTTLInHumanReadableFormat(ttl)
117131
const remainingTimeString = ttl < 0 ? `Expired ${remainingTime} ago` : `${remainingTime} remaining`
118132
const isThemeDark = appTheme === AppThemeType.dark

src/Shared/Components/License/utils.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,25 @@ import moment from 'moment'
1818

1919
import { DATE_TIME_FORMATS } from '@Common/Constants'
2020
import { getUrlWithSearchParams } from '@Common/index'
21-
import { DevtronLicenseDTO } from '@Shared/types'
21+
import { DevtronLicenseDTO, LicensingErrorCodes } from '@Shared/types'
2222

2323
import { ALLOWED_CLUSTER_IN_FREEMIUM } from './constants'
2424
import { DevtronLicenseCardProps, DevtronLicenseInfo, LicenseStatus } from './types'
2525

26-
export const getLicenseColorsAccordingToStatus = (
27-
licenseStatus: LicenseStatus,
28-
): { bgColor: string; textColor: string } => {
26+
export const getLicenseColorsAccordingToStatus = ({
27+
isFreemium,
28+
licenseStatus,
29+
licenseStatusError,
30+
}: Pick<DevtronLicenseCardProps, 'licenseStatus' | 'isFreemium' | 'licenseStatusError'>): {
31+
bgColor: string
32+
textColor: string
33+
} => {
34+
if (isFreemium) {
35+
const freemiumLimitReached = licenseStatusError?.code === LicensingErrorCodes.ClusterLimitExceeded
36+
return freemiumLimitReached
37+
? { bgColor: 'var(--R100)', textColor: 'var(--R500)' }
38+
: { bgColor: 'var(--G100)', textColor: 'var(--G500)' }
39+
}
2940
switch (licenseStatus) {
3041
case LicenseStatus.ACTIVE:
3142
return { bgColor: 'var(--G100)', textColor: 'var(--G500)' }

0 commit comments

Comments
 (0)