Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jvorcak committed Dec 2, 2024
1 parent 36bb8c9 commit 6276546
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 40 deletions.
29 changes: 18 additions & 11 deletions frontend/src/components/license/FeatureLicenseNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import {
} from '../../protogen/redpanda/api/console/v1alpha1/license_pb';
import { api } from '../../state/backendApi';
import {
LICENSE_WEIGHT,
MS_IN_DAY,
UpgradeButton,
UploadLicenseButton,
coreHasEnterpriseFeatures,
getEnterpriseCTALink,
getMillisecondsToExpiration,
getPrettyExpirationDate,
getPrettyTimeToExpiration, ENTERPRISE_FEATURES_DOCS_LINK,
LICENSE_WEIGHT,
MS_IN_DAY,
UpgradeButton,
UploadLicenseButton,
coreHasEnterpriseFeatures,
getEnterpriseCTALink,
getMillisecondsToExpiration,
getPrettyExpirationDate,
getPrettyTimeToExpiration,
ENTERPRISE_FEATURES_DOCS_LINK,
} from './licenseUtils';

const getLicenseAlertContentForFeature = (
Expand Down Expand Up @@ -56,7 +57,10 @@ const getLicenseAlertContentForFeature = (
<Box>
<Text>
Your Redpanda Enterprise trial is expiring in {getPrettyTimeToExpiration(license)}; at that point, your
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">enterprise features</Link> will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">
enterprise features
</Link>{' '}
will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={getEnterpriseCTALink('upgrade')} target="_blank">
contact us
</Link>
Expand Down Expand Up @@ -109,7 +113,10 @@ const getLicenseAlertContentForFeature = (
<Box>
<Text>
Your Redpanda Enterprise trial is expiring in {getPrettyTimeToExpiration(license)}; at that point, your
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">enterprise features</Link> will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">
enterprise features
</Link>{' '}
will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={getEnterpriseCTALink('upgrade')} target="_blank">
contact us
</Link>
Expand Down
54 changes: 39 additions & 15 deletions frontend/src/components/license/LicenseNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import { Fragment } from 'react';
import { Link as ReactRouterLink, useLocation } from 'react-router-dom';
import { License_Source, License_Type } from '../../protogen/redpanda/api/console/v1alpha1/license_pb';
import { api } from '../../state/backendApi';
import { coreHasEnterpriseFeatures, getMillisecondsToExpiration, getPrettyTimeToExpiration, licenseIsExpired, licenseSoonToExpire, MS_IN_DAY, prettyLicenseType } from './licenseUtils';
import {
coreHasEnterpriseFeatures,
getMillisecondsToExpiration,
getPrettyTimeToExpiration,
licenseIsExpired,
licenseSoonToExpire,
MS_IN_DAY,
prettyLicenseType,
} from './licenseUtils';
import { capitalizeFirst, titleCase } from '../../utils/utils';

export const LicenseNotification = observer(() => {
Expand All @@ -18,7 +26,8 @@ export const LicenseNotification = observer(() => {
const visibleExpiredEnterpriseLicenses = enterpriseLicenses.filter(licenseIsExpired) ?? [];
const soonToExpireLicenses = enterpriseLicenses.filter((license) => licenseSoonToExpire(license)) ?? [];

const showSomeLicenseExpirationInfo = (visibleExpiredEnterpriseLicenses.length > 0 && api.licenseViolation) || soonToExpireLicenses.length;
const showSomeLicenseExpirationInfo =
(visibleExpiredEnterpriseLicenses.length > 0 && api.licenseViolation) || soonToExpireLicenses.length;

if (api.licensesLoaded === undefined) {
return null;
Expand Down Expand Up @@ -53,26 +62,39 @@ export const LicenseNotification = observer(() => {
status={
visibleExpiredLicenses.length > 0 ||
api.licenseViolation ||
soonToExpireLicenses.some(license => {
const msToExpiration = getMillisecondsToExpiration(license);
return (msToExpiration > -1 && msToExpiration < 15 * MS_IN_DAY)
soonToExpireLicenses.some((license) => {
const msToExpiration = getMillisecondsToExpiration(license);
return msToExpiration > -1 && msToExpiration < 15 * MS_IN_DAY;
})
? 'warning' : 'info'}
? 'warning'
: 'info'
}
variant="subtle"
>
<AlertIcon />
<AlertDescription>
{visibleSoonToExpireLicenses.length > 0 && (
<Fragment>
{capitalizeFirst(visibleSoonToExpireLicenses.map(license => `your ${prettyLicenseType(license, true)} license will expire in ${getPrettyTimeToExpiration(license)}`).join(' and '))}.{' '}
{capitalizeFirst(
visibleSoonToExpireLicenses
.map(
(license) =>
`your ${prettyLicenseType(license, true)} license will expire in ${getPrettyTimeToExpiration(license)}`,
)
.join(' and '),
)}
.{' '}
</Fragment>
)}

{visibleExpiredLicenses.length > 0 && api.licenseViolation && (
<Fragment>
{capitalizeFirst(visibleExpiredLicenses.map((license, idx) => (
`your ${prettyLicenseType(license, true)} license has expired`
)).join(' and '))}.{' '}
{capitalizeFirst(
visibleExpiredLicenses
.map((license, idx) => `your ${prettyLicenseType(license, true)} license has expired`)
.join(' and '),
)}
.{' '}
</Fragment>
)}

Expand All @@ -81,11 +103,13 @@ export const LicenseNotification = observer(() => {
You're using {activeEnterpriseFeatures.length === 1 ? 'an enterprise feature' : 'enterprise features'}{' '}
<strong>{activeEnterpriseFeatures.map((x) => x.name).join(', ')}</strong> in your connected Redpanda
cluster.{' '}
{api.licenseViolation && <>
{activeEnterpriseFeatures.length === 1
? 'This feature requires a license.'
: 'These features require a license.'}
</>}
{api.licenseViolation && (
<>
{activeEnterpriseFeatures.length === 1
? 'This feature requires a license.'
: 'These features require a license.'}
</>
)}
</Fragment>
)}

Expand Down
27 changes: 17 additions & 10 deletions frontend/src/components/license/OverviewLicenseNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { type FC, type ReactElement, useEffect } from 'react';
import { type License, License_Type } from '../../protogen/redpanda/api/console/v1alpha1/license_pb';
import { api } from '../../state/backendApi';
import {
DISABLE_SSO_DOCS_LINK,
MS_IN_DAY,
UpgradeButton,
UploadLicenseButton,
consoleHasEnterpriseFeature,
getEnterpriseCTALink,
getMillisecondsToExpiration,
getPrettyTimeToExpiration, ENTERPRISE_FEATURES_DOCS_LINK,
DISABLE_SSO_DOCS_LINK,
MS_IN_DAY,
UpgradeButton,
UploadLicenseButton,
consoleHasEnterpriseFeature,
getEnterpriseCTALink,
getMillisecondsToExpiration,
getPrettyTimeToExpiration,
ENTERPRISE_FEATURES_DOCS_LINK,
} from './licenseUtils';

const getLicenseAlertContent = (
Expand Down Expand Up @@ -70,7 +71,10 @@ const getLicenseAlertContent = (
<Box>
<Text>
Your Redpanda Enterprise trial is expiring in {getPrettyTimeToExpiration(license)}; at that point, your
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">enterprise features</Link> will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">
enterprise features
</Link>{' '}
will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={getEnterpriseCTALink('upgrade')} target="_blank">
contact us
</Link>
Expand Down Expand Up @@ -118,7 +122,10 @@ const getLicenseAlertContent = (
<Box>
<Text>
Your Redpanda Enterprise trial is expiring in {getPrettyTimeToExpiration(license)}; at that point, your
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">enterprise features</Link> will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">
enterprise features
</Link>{' '}
will become unavailable. To get a full Redpanda Enterprise license,{' '}
<Link href={getEnterpriseCTALink('upgrade')} target="_blank">
contact us
</Link>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/license/licenseUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ export const getEnterpriseCTALink = (type: EnterpriseLinkType): string => {

export const DISABLE_SSO_DOCS_LINK = 'https://docs.redpanda.com/current/console/config/configure-console/';

export const ENTERPRISE_FEATURES_DOCS_LINK = 'https://docs.redpanda.com/current/get-started/licenses/#redpanda-enterprise-edition';
export const ENTERPRISE_FEATURES_DOCS_LINK =
'https://docs.redpanda.com/current/get-started/licenses/#redpanda-enterprise-edition';

export const UploadLicenseButton = () =>
api.isAdminApiConfigured ? (
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/pages/admin/UploadLicensePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ export default class UploadLicensePage extends PageComponent<{}> {
A restart will be needed to use Redpanda Console's enterprise features.
</Text>
<Text fontWeight="normal">
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">Enterprise features</Link> in your Redpanda cluster will be available right away.
<Link href={ENTERPRISE_FEATURES_DOCS_LINK} target="_blank">
Enterprise features
</Link>{' '}
in your Redpanda cluster will be available right away.
</Text>
</Box>
<Box>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ export function titleCase(str: string): string {
}

export function capitalizeFirst(str: string): string {
if (!str) return str; // Handle empty or falsy strings
return str.charAt(0).toUpperCase() + str.slice(1);
if (!str) return str; // Handle empty or falsy strings
return str.charAt(0).toUpperCase() + str.slice(1);
}

/**
Expand Down

0 comments on commit 6276546

Please sign in to comment.