@@ -23,6 +23,7 @@ import { ClipboardButton, getTTLInHumanReadableFormat } from '@Common/index'
2323import { CONTACT_SUPPORT_LINK , ENTERPRISE_SUPPORT_LINK } from '@Shared/constants'
2424import { AppThemeType } from '@Shared/Providers'
2525import { getThemeOppositeThemeClass } from '@Shared/Providers/ThemeProvider/utils'
26+ import { LicensingErrorCodes } from '@Shared/types'
2627
2728import { Button , ButtonComponentType , ButtonVariantType } from '../Button'
2829import { Icon } from '../Icon'
@@ -33,21 +34,85 @@ import './licenseCard.scss'
3334
3435const DAMPEN_FACTOR = 50
3536
37+ const LicenseCardSubText = ( {
38+ isFreemium,
39+ licenseStatus,
40+ licenseStatusError,
41+ } : Pick < DevtronLicenseCardProps , 'isFreemium' | 'licenseStatus' | 'licenseStatusError' > ) => {
42+ if ( licenseStatus === LicenseStatus . ACTIVE && ! isFreemium ) {
43+ return null
44+ }
45+
46+ const isLicenseValid = licenseStatus !== LicenseStatus . EXPIRED && ! licenseStatusError
47+ const freemiumLimitReached = licenseStatusError ?. code === LicensingErrorCodes . ClusterLimitExceeded
48+
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
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 && (
74+ < Button
75+ dataTestId = "mail-support"
76+ startIcon = { < Icon name = "ic-email" color = { null } /> }
77+ text = { ENTERPRISE_SUPPORT_LINK }
78+ variant = { ButtonVariantType . text }
79+ component = { ButtonComponentType . anchor }
80+ anchorProps = { { href : `mailto:${ ENTERPRISE_SUPPORT_LINK } ` } }
81+ />
82+ ) }
83+ < Button
84+ dataTestId = "contact-support"
85+ startIcon = { < ICChatSupport /> }
86+ text = "Contact support"
87+ variant = { ButtonVariantType . text }
88+ component = { ButtonComponentType . anchor }
89+ anchorProps = { { href : CONTACT_SUPPORT_LINK } }
90+ />
91+ </ div >
92+ ) : (
93+ < div className = "flexbox p-16 cn-9 fw-6 fs-13 lh-1-5 dc__align-items-center dc__content-space" >
94+ < span > Unlimited single cluster usage</ span >
95+ < Icon name = "ic-success" size = { 20 } color = { null } />
96+ </ div >
97+ )
98+ }
99+
36100export const DevtronLicenseCard = ( {
37101 enterpriseName,
38102 licenseKey,
39103 licenseSuffix,
40104 expiryDate,
41105 licenseStatus,
42106 isTrial,
107+ isFreemium,
43108 ttl,
44109 appTheme,
45110 handleCopySuccess,
111+ licenseStatusError,
46112} : DevtronLicenseCardProps ) => {
47113 const { bgColor, textColor } = getLicenseColorsAccordingToStatus ( licenseStatus )
48114 const remainingTime = getTTLInHumanReadableFormat ( ttl )
49115 const remainingTimeString = ttl < 0 ? `Expired ${ remainingTime } ago` : `${ remainingTime } remaining`
50- const isLicenseValid = licenseStatus !== LicenseStatus . EXPIRED
51116 const isThemeDark = appTheme === AppThemeType . dark
52117
53118 const cardRef = useRef < HTMLDivElement > ( null )
@@ -130,43 +195,30 @@ export const DevtronLicenseCard = ({
130195 ) }
131196 </ div >
132197 < div className = "flexbox dc__align-items-center dc__gap-4 flex-wrap fs-12" >
133- < span className = "font-ibm-plex-mono cn-9" > { expiryDate } </ span >
134- < span className = "cn-9" > ·</ span >
135- < span style = { { color : textColor } } > { remainingTimeString } </ span >
198+ < span className = "font-ibm-plex-mono cn-9" >
199+ { isFreemium ? 'VALID FOREVER' : expiryDate }
200+ </ span >
201+ { ! isFreemium && (
202+ < >
203+ < span className = "cn-9" > ·</ span >
204+ < span style = { { color : textColor } } > { remainingTimeString } </ span >
205+ </ >
206+ ) }
136207 </ div >
137208 </ div >
138209 </ div >
139- { isTrial && (
210+ { ( isTrial || isFreemium ) && (
140211 < span className = "trial-license-badge flexbox dc__align-items-center px-20 py-6 cn-9 fs-11 fw-5 lh-1-5 dc__zi-2" >
141- TRIAL LICENSE
212+ { isFreemium ? 'FREEMIUM' : ' TRIAL' } LICENSE
142213 </ span >
143214 ) }
144215 </ motion . div >
145216 </ div >
146- { licenseStatus !== LicenseStatus . ACTIVE && (
147- < div className = "p-16 fs-13 lh-1-5 flexbox-col dc__gap-8" >
148- < div className = "flexbox dc__gap-8" >
149- < span >
150- To renew your license mail us at
151- < a href = { `mailto:${ ENTERPRISE_SUPPORT_LINK } ` } > { ENTERPRISE_SUPPORT_LINK } </ a > or contact your
152- Devtron representative.
153- </ span >
154- < Icon
155- name = { isLicenseValid ? 'ic-timer' : 'ic-error' }
156- color = { isLicenseValid ? 'Y500' : 'R500' }
157- size = { 16 }
158- />
159- </ div >
160- < Button
161- dataTestId = "contact-support"
162- startIcon = { < ICChatSupport /> }
163- text = "Contact support"
164- variant = { ButtonVariantType . text }
165- component = { ButtonComponentType . anchor }
166- anchorProps = { { href : CONTACT_SUPPORT_LINK } }
167- />
168- </ div >
169- ) }
217+ < LicenseCardSubText
218+ isFreemium = { isFreemium }
219+ licenseStatusError = { licenseStatusError }
220+ licenseStatus = { licenseStatus }
221+ />
170222 </ div >
171223 )
172224}
0 commit comments