-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1541 from redpanda-data/CONSOLE-67-self-service-l…
…icense-trials-and-graceful-license-expiry-merge Console 67 self service license trials and graceful license expiry merge
- Loading branch information
Showing
20 changed files
with
765 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 28 additions & 22 deletions
50
backend/pkg/protogen/redpanda/api/dataplane/v1alpha2/error.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
frontend/src/components/license/FeatureLicenseNotification.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import { Alert, AlertDescription, AlertIcon, Box, Button, Flex, Link, Text } from '@redpanda-data/ui'; | ||
import { observer } from 'mobx-react'; | ||
import { FC, ReactElement, useEffect } from 'react'; | ||
import { | ||
License, | ||
License_Type, | ||
ListEnterpriseFeaturesResponse_Feature, | ||
} from '../../protogen/redpanda/api/console/v1alpha1/license_pb'; | ||
import { | ||
getEnterpriseCTALink, | ||
getMillisecondsToExpiration, | ||
getPrettyExpirationDate, | ||
getPrettyTimeToExpiration, | ||
LICENSE_WEIGHT, | ||
MS_IN_DAY, | ||
coreHasEnterpriseFeatures, | ||
UploadLicenseButton, | ||
UpgradeButton, | ||
} from './licenseUtils'; | ||
import { api } from '../../state/backendApi'; | ||
|
||
const getLicenseAlertContentForFeature = ( | ||
featureName: 'rbac' | 'reassignPartitions', | ||
license: License | undefined, | ||
enterpriseFeaturesUsed: ListEnterpriseFeaturesResponse_Feature[], | ||
): { message: ReactElement; status: 'warning' | 'info' } | null => { | ||
if (license === undefined || license.type !== License_Type.TRIAL) { | ||
return null; | ||
} | ||
|
||
const msToExpiration = getMillisecondsToExpiration(license); | ||
|
||
// Redpanda | ||
if (api.isRedpanda) { | ||
if ( | ||
msToExpiration > 15 * MS_IN_DAY && | ||
msToExpiration < 30 * MS_IN_DAY && | ||
coreHasEnterpriseFeatures(enterpriseFeaturesUsed) | ||
) { | ||
return { | ||
message: ( | ||
<Box> | ||
<Text>This is an enterprise feature, active until {getPrettyExpirationDate(license)}.</Text> | ||
<Flex gap={2} my={2}> | ||
<UploadLicenseButton /> | ||
<UpgradeButton /> | ||
</Flex> | ||
</Box> | ||
), | ||
status: 'info', | ||
}; | ||
} else if ( | ||
msToExpiration > 0 && | ||
msToExpiration < 15 * MS_IN_DAY && | ||
coreHasEnterpriseFeatures(enterpriseFeaturesUsed) | ||
) { | ||
return { | ||
message: ( | ||
<Box> | ||
<Text> | ||
Your Redpanda Enterprise trial is expiring in {getPrettyTimeToExpiration(license)}; at that point, your | ||
enterprise features will become unavailable. To get a full Redpanda Enterprise license,{' '} | ||
<Link href={getEnterpriseCTALink('upgrade')} target="_blank"> | ||
contact us | ||
</Link> | ||
. | ||
</Text> | ||
<Flex gap={2} my={2}> | ||
<UploadLicenseButton /> | ||
<UpgradeButton /> | ||
</Flex> | ||
</Box> | ||
), | ||
status: 'warning', | ||
}; | ||
} | ||
} else { | ||
// Kafka | ||
if (msToExpiration > 15 * MS_IN_DAY && msToExpiration < 30 * MS_IN_DAY) { | ||
if (license.type === License_Type.TRIAL) { | ||
return { | ||
message: ( | ||
<Box> | ||
<Text>This is an enterprise feature. Your trial is active until {getPrettyExpirationDate(license)}</Text> | ||
<Flex gap={2} my={2}> | ||
<UploadLicenseButton /> | ||
<UpgradeButton /> | ||
</Flex> | ||
</Box> | ||
), | ||
status: 'info', | ||
}; | ||
} else { | ||
return { | ||
message: ( | ||
<Box> | ||
<Text> | ||
This is a Redpanda Enterprise feature. Try it with our{' '} | ||
<Link href={getEnterpriseCTALink('tryEnterprise')} target="_blank"> | ||
Redpanda Enterprise Trial | ||
</Link> | ||
. | ||
</Text> | ||
</Box> | ||
), | ||
status: 'info', | ||
}; | ||
} | ||
} else if (msToExpiration > 0 && msToExpiration < 15 * MS_IN_DAY && license.type === License_Type.TRIAL) { | ||
return { | ||
message: ( | ||
<Box> | ||
<Text> | ||
Your Redpanda Enterprise trial is expiring in {getPrettyTimeToExpiration(license)}; at that point, your | ||
enterprise features will become unavailable. To get a full Redpanda Enterprise license,{' '} | ||
<Link href={getEnterpriseCTALink('upgrade')} target="_blank"> | ||
contact us | ||
</Link> | ||
. | ||
</Text> | ||
<Flex gap={2} my={2}> | ||
<UploadLicenseButton /> | ||
<UpgradeButton /> | ||
</Flex> | ||
</Box> | ||
), | ||
status: 'warning', | ||
}; | ||
} | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export const FeatureLicenseNotification: FC<{ featureName: 'reassignPartitions' | 'rbac' }> = observer( | ||
({ featureName }) => { | ||
useEffect(() => { | ||
void api.refreshClusterOverview(); | ||
void api.listLicenses(); | ||
}, []); | ||
|
||
const license = api.licenses | ||
.filter((license) => license.type === License_Type.TRIAL || license.type === License_Type.COMMUNITY) | ||
.sort((a, b) => LICENSE_WEIGHT[a.type] - LICENSE_WEIGHT[b.type]) // Sort by priority | ||
.first(); | ||
|
||
const enterpriseFeaturesUsed = api.enterpriseFeaturesUsed; | ||
const alertContent = getLicenseAlertContentForFeature(featureName, license, enterpriseFeaturesUsed); | ||
|
||
// This component needs info about whether we're using Redpanda or Kafka, without fetching clusterOverview first, we might get a malformed result | ||
if (api.clusterOverview === null) { | ||
return null; | ||
} | ||
|
||
if (!license) { | ||
return null; | ||
} | ||
|
||
if (alertContent === null) { | ||
return null; | ||
} | ||
|
||
const { message, status } = alertContent; | ||
|
||
return ( | ||
<Box> | ||
<Alert mb={4} status={status} variant="subtle"> | ||
<AlertIcon /> | ||
<AlertDescription>{message}</AlertDescription> | ||
</Alert> | ||
</Box> | ||
); | ||
}, | ||
); |
Oops, something went wrong.