Skip to content

Commit 4e45cb5

Browse files
Merge pull request #983 from devtron-labs/feat/saas
feat: add utils required for devtron saas
2 parents 61bda34 + aab47cf commit 4e45cb5

File tree

13 files changed

+419
-29
lines changed

13 files changed

+419
-29
lines changed

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.22.0",
3+
"version": "1.22.1",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Illustration/img-celebration.svg

Lines changed: 149 additions & 0 deletions
Loading

src/Assets/Illustration/img-install-freemium-saas.svg

Lines changed: 40 additions & 0 deletions
Loading

src/Assets/Illustration/img-install-via-aws-marketplace.svg

Lines changed: 48 additions & 0 deletions
Loading
Lines changed: 81 additions & 0 deletions
Loading

src/Shared/Components/Illustration/Illustration.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@
22

33
import CreateBackupSchedule from '@Illustrations/create-backup-schedule.webp'
44
import CreateBackupSnapshot from '@Illustrations/create-backup-snapshot.webp'
5+
import { ReactComponent as ImgCelebration } from '@Illustrations/img-celebration.svg'
56
import ImgCode from '@Illustrations/img-code.webp'
67
import ImgDevtronFreemium from '@Illustrations/img-devtron-freemium.webp'
78
import { ReactComponent as ImgFolderEmpty } from '@Illustrations/img-folder-empty.svg'
9+
import { ReactComponent as ImgInstallFreemiumSaas } from '@Illustrations/img-install-freemium-saas.svg'
10+
import { ReactComponent as ImgInstallViaAwsMarketplace } from '@Illustrations/img-install-via-aws-marketplace.svg'
811
import ImgManOnRocket from '@Illustrations/img-man-on-rocket.webp'
912
import { ReactComponent as ImgMechanicalOperation } from '@Illustrations/img-mechanical-operation.svg'
1013
import { ReactComponent as ImgNoBackupLocation } from '@Illustrations/img-no-backup-location.svg'
1114
import { ReactComponent as ImgNoRestores } from '@Illustrations/img-no-restores.svg'
1215
import ImgNoResult from '@Illustrations/img-no-result.webp'
16+
import { ReactComponent as ImgPageNotFound } from '@Illustrations/img-page-not-found.svg'
1317
import NoClusterCostEnabled from '@Illustrations/no-cluster-cost-enabled.webp'
1418

1519
// eslint-disable-next-line no-restricted-imports
1620
import { IllustrationBase } from './IllustrationBase'
1721
import { IllustrationBaseProps } from './types'
1822

1923
export const illustrationMap = {
24+
'img-celebration': ImgCelebration,
2025
'img-folder-empty': ImgFolderEmpty,
26+
'img-install-freemium-saas': ImgInstallFreemiumSaas,
27+
'img-install-via-aws-marketplace': ImgInstallViaAwsMarketplace,
2128
'img-mechanical-operation': ImgMechanicalOperation,
2229
'img-no-backup-location': ImgNoBackupLocation,
2330
'img-no-restores': ImgNoRestores,
31+
'img-page-not-found': ImgPageNotFound,
2432
'create-backup-schedule': CreateBackupSchedule,
2533
'create-backup-snapshot': CreateBackupSnapshot,
2634
'img-code': ImgCode,

src/Shared/Components/License/DevtronLicenseCard.tsx

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { LicensingErrorCodes } from '@Shared/types'
2727

2828
import { Button, ButtonComponentType, ButtonVariantType } from '../Button'
2929
import { Icon } from '../Icon'
30-
import { DevtronLicenseCardProps, LicenseStatus } from './types'
30+
import { DevtronLicenseCardProps, LicenseCardSubTextProps, LicenseStatus } from './types'
3131
import { getLicenseColorsAccordingToStatus } from './utils'
3232

3333
import './licenseCard.scss'
@@ -49,10 +49,13 @@ const LicenseCardSubText = ({
4949
isFreemium,
5050
licenseStatus,
5151
licenseStatusError,
52-
}: Pick<DevtronLicenseCardProps, 'isFreemium' | 'licenseStatus' | 'licenseStatusError'>) => {
53-
if (isFreemium) {
54-
const freemiumLimitReached = licenseStatusError?.code === LicensingErrorCodes.ClusterLimitExceeded
52+
isFreeForever,
53+
}: LicenseCardSubTextProps) => {
54+
const freemiumLimitReached = isFreemium && licenseStatusError?.code === LicensingErrorCodes.ClusterLimitExceeded
55+
const showFreemiumMessage =
56+
isFreeForever || freemiumLimitReached || (isFreemium && licenseStatus === LicenseStatus.ACTIVE)
5557

58+
if (showFreemiumMessage) {
5659
return (
5760
<div className="p-16 fs-13 lh-1-5 flexbox-col dc__gap-8">
5861
<div className="flexbox dc__gap-8 dc__content-space fs-13 fw-4 lh-20 cn-9">
@@ -130,10 +133,17 @@ export const DevtronLicenseCard = ({
130133
appTheme,
131134
handleCopySuccess,
132135
licenseStatusError,
136+
isSaasInstance,
133137
}: DevtronLicenseCardProps) => {
134-
const { bgColor, textColor } = getLicenseColorsAccordingToStatus({ isFreemium, licenseStatus, licenseStatusError })
135-
const remainingTime = getTTLInHumanReadableFormat(ttl)
136-
const remainingTimeString = ttl < 0 ? `Expired ${remainingTime} ago` : `${remainingTime} remaining`
138+
const isFreeForever = isFreemium && !isSaasInstance
139+
140+
const { bgColor, textColor } = getLicenseColorsAccordingToStatus({
141+
isFreemium,
142+
licenseStatus,
143+
licenseStatusError,
144+
isSaasInstance,
145+
})
146+
137147
const isThemeDark = appTheme === AppThemeType.dark
138148

139149
const cardRef = useRef<HTMLDivElement>(null)
@@ -178,6 +188,15 @@ export const DevtronLicenseCard = ({
178188
? useMotionTemplate`linear-gradient(55deg, transparent, rgba(122, 127, 131, ${sheenOpacity}) ${sheenPosition}%, transparent)`
179189
: useMotionTemplate`linear-gradient(55deg, transparent, rgba(255, 255, 255, ${sheenOpacity}) ${sheenPosition}%, transparent)`
180190

191+
const getRemainingTimeString = () => {
192+
if (isFreeForever) {
193+
return null
194+
}
195+
196+
const remainingTime = getTTLInHumanReadableFormat(ttl)
197+
return ttl < 0 ? `Expired ${remainingTime} ago` : `${remainingTime} remaining`
198+
}
199+
181200
return (
182201
<div className="license-card-wrapper flexbox-col p-8 br-16" style={{ backgroundColor: bgColor }}>
183202
<div style={{ perspective: '1000px' }}>
@@ -217,12 +236,12 @@ export const DevtronLicenseCard = ({
217236
</div>
218237
<div className="flexbox dc__align-items-center dc__gap-4 flex-wrap fs-12">
219238
<span className="font-ibm-plex-mono cn-9">
220-
{isFreemium ? 'VALID FOREVER' : expiryDate}
239+
{isFreeForever ? 'VALID FOREVER' : expiryDate}
221240
</span>
222-
{!isFreemium && (
241+
{!isFreeForever && (
223242
<>
224243
<span className="cn-9">·</span>
225-
<span style={{ color: textColor }}>{remainingTimeString}</span>
244+
<span style={{ color: textColor }}>{getRemainingTimeString()}</span>
226245
</>
227246
)}
228247
</div>
@@ -239,6 +258,7 @@ export const DevtronLicenseCard = ({
239258
isFreemium={isFreemium}
240259
licenseStatusError={licenseStatusError}
241260
licenseStatus={licenseStatus}
261+
isFreeForever={isFreeForever}
242262
/>
243263
</div>
244264
)

src/Shared/Components/License/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
export { default as ActivateLicenseDialog } from './ActivateLicenseDialog'
1818
export { default as DevtronLicenseCard } from './DevtronLicenseCard'
1919
export { ICDevtronWithBorder, default as InstallationFingerprintInfo } from './License.components'
20+
export { activateLicense } from './services'
2021
export * from './types'
2122
export { parseDevtronLicenseData, parseDevtronLicenseDTOIntoLicenseCardData } from './utils'

src/Shared/Components/License/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export type DevtronLicenseCardProps = {
3232
isFreemium: boolean
3333
appTheme: AppThemeType
3434
licenseStatusError: LicenseErrorStruct
35+
isSaasInstance: boolean
3536
} & (
3637
| {
3738
licenseKey: string
@@ -45,6 +46,11 @@ export type DevtronLicenseCardProps = {
4546
}
4647
)
4748

49+
export interface LicenseCardSubTextProps
50+
extends Pick<DevtronLicenseCardProps, 'isFreemium' | 'licenseStatus' | 'licenseStatusError'> {
51+
isFreeForever: boolean
52+
}
53+
4854
export type DevtronLicenseInfo = Omit<DevtronLicenseCardProps, 'appTheme'> &
4955
Pick<DevtronLicenseDTO, 'fingerprint' | 'showLicenseData' | 'licenseStatusError' | 'moduleLimits'>
5056

0 commit comments

Comments
 (0)