diff --git a/src/config.js b/src/config.js index 3e02cde552..bd3aedf9e2 100644 --- a/src/config.js +++ b/src/config.js @@ -13,6 +13,7 @@ const defaultConfig = { GH_APP: DEFAULT_GH_APP, GH_APP_AI: 'codecov-ai', SUNBURST_ENABLED: true, + DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true, } export function removeReactAppPrefix(obj) { @@ -38,6 +39,11 @@ export function removeReactAppPrefix(obj) { keys['SUNBURST_ENABLED'] = keys['SUNBURST_ENABLED'].toLowerCase() === 'true' } + if ('DISPLAY_SELF_HOSTED_EXPIRATION_BANNER' in keys) { + keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'] = + keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'].toLowerCase() === 'true' + } + if ('SENTRY_TRACING_SAMPLE_RATE' in keys) { keys['SENTRY_TRACING_SAMPLE_RATE'] = parseFloat( keys['SENTRY_TRACING_SAMPLE_RATE'] diff --git a/src/config.test.js b/src/config.test.js index 96bc73b2ff..7519efb93d 100644 --- a/src/config.test.js +++ b/src/config.test.js @@ -70,6 +70,16 @@ describe('config', () => { }) }) + describe('sets DISPLAY_SELF_HOSTED_EXPIRATION_BANNER to boolean', () => { + it('sets to true', () => { + const obj = { DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: 'true' } + + expect(removeReactAppPrefix(obj)).toEqual({ + DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true, + }) + }) + }) + describe('sets IS_DEDICATED_NAMESPACE to boolean', () => { it('sets to true', () => { const obj = { diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx index 713a72c565..c4153ae363 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx @@ -165,6 +165,21 @@ describe('SelfHostedLicenseExpiration', () => { expect(resolveIssueButton).not.toBeInTheDocument() }) + it('does not render the banner when disabled', async () => { + config.IS_SELF_HOSTED = true + config.IS_DEDICATED_NAMESPACE = true + config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER = false + setup({ + seatsUsed: 5, + seatsLimit: 10, + expirationDate: null, + }) + render(, { wrapper: wrapper(['']) }) + + const resolveIssueButton = screen.queryByText(/Resolve issue/) + expect(resolveIssueButton).not.toBeInTheDocument() + }) + it('does not render the banner when there are no seats used', async () => { config.IS_SELF_HOSTED = true config.IS_DEDICATED_NAMESPACE = true @@ -200,6 +215,7 @@ describe('SelfHostedLicenseExpiration', () => { vi.setSystemTime(new Date('2023-08-01')) config.IS_SELF_HOSTED = true config.IS_DEDICATED_NAMESPACE = true + config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER = true }) afterEach(() => { diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx index e96d34e9ee..27a541cd86 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx @@ -81,7 +81,10 @@ const SelfHostedLicenseExpiration = () => { const isLicenseExpiringWithin30Days = dateDiff < 31 && dateDiff >= 0 const shouldDisplayBanner = - isSeatsLimitReached || isLicenseExpired || isLicenseExpiringWithin30Days + (isSeatsLimitReached || + isLicenseExpired || + isLicenseExpiringWithin30Days) && + config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER if (!shouldDisplayBanner) { return null