From 6cb33d498ec2c832d21112842b3723f37c7bee26 Mon Sep 17 00:00:00 2001 From: Trent Schmidt Date: Thu, 30 Jan 2025 16:38:36 -0500 Subject: [PATCH 1/5] DISPLAY_SELF_HOSTED_EXPIRATION_BANNER probably --- src/config.js | 5 +++++ src/config.test.js | 8 ++++++++ .../SelfHostedLicenseExpiration.test.tsx | 15 +++++++++++++++ .../SelfHostedLicenseExpiration.tsx | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index 3e02cde552..fcecc781d8 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,10 @@ 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..be8afea92b 100644 --- a/src/config.test.js +++ b/src/config.test.js @@ -70,6 +70,14 @@ 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..96e9acb72f 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 diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx index e96d34e9ee..5be43d5b9e 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx @@ -83,7 +83,7 @@ const SelfHostedLicenseExpiration = () => { const shouldDisplayBanner = isSeatsLimitReached || isLicenseExpired || isLicenseExpiringWithin30Days - if (!shouldDisplayBanner) { + if (!shouldDisplayBanner && config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER) { return null } From 45c0d0f82ace32f1e0721d0355ec8e418a210c4d Mon Sep 17 00:00:00 2001 From: katia-sentry Date: Thu, 30 Jan 2025 17:35:50 -0500 Subject: [PATCH 2/5] comment out test for now --- src/config.js | 3 ++- src/config.test.js | 4 +++- .../SelfHostedLicenseExpiration.test.tsx | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/config.js b/src/config.js index fcecc781d8..bd3aedf9e2 100644 --- a/src/config.js +++ b/src/config.js @@ -40,7 +40,8 @@ export function removeReactAppPrefix(obj) { } if ('DISPLAY_SELF_HOSTED_EXPIRATION_BANNER' in keys) { - keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'] = keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'].toLowerCase() === 'true' + keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'] = + keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'].toLowerCase() === 'true' } if ('SENTRY_TRACING_SAMPLE_RATE' in keys) { diff --git a/src/config.test.js b/src/config.test.js index be8afea92b..7519efb93d 100644 --- a/src/config.test.js +++ b/src/config.test.js @@ -74,7 +74,9 @@ describe('config', () => { it('sets to true', () => { const obj = { DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: 'true' } - expect(removeReactAppPrefix(obj)).toEqual({ DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true }) + expect(removeReactAppPrefix(obj)).toEqual({ + DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true, + }) }) }) diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx index 96e9acb72f..6d49a41dd8 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx @@ -241,7 +241,10 @@ describe('SelfHostedLicenseExpiration', () => { ) const resolveIssueButton = screen.queryByText(/Resolve issue/) - expect(resolveIssueButton).not.toBeInTheDocument() + + // Hide banner for Snowflake + // expect(resolveIssueButton).not.toBeInTheDocument() + expect(resolveIssueButton).toBeInTheDocument() }) describe('when license is expired and seats limit is reached', () => { From dc28487eac50a108c9f48cd2272ec15a82cae154 Mon Sep 17 00:00:00 2001 From: Jerry Feng Date: Thu, 30 Jan 2025 17:47:33 -0500 Subject: [PATCH 3/5] fix logic --- .../SelfHostedLicenseExpiration.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx index 5be43d5b9e..27a541cd86 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx @@ -81,9 +81,12 @@ const SelfHostedLicenseExpiration = () => { const isLicenseExpiringWithin30Days = dateDiff < 31 && dateDiff >= 0 const shouldDisplayBanner = - isSeatsLimitReached || isLicenseExpired || isLicenseExpiringWithin30Days + (isSeatsLimitReached || + isLicenseExpired || + isLicenseExpiringWithin30Days) && + config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER - if (!shouldDisplayBanner && config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER) { + if (!shouldDisplayBanner) { return null } From 8872af66787023f0e271d900257188a68443c139 Mon Sep 17 00:00:00 2001 From: Jerry Feng Date: Thu, 30 Jan 2025 17:48:56 -0500 Subject: [PATCH 4/5] bring back test --- .../SelfHostedLicenseExpiration.test.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx index 6d49a41dd8..4dba4df4a3 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx @@ -242,9 +242,7 @@ describe('SelfHostedLicenseExpiration', () => { const resolveIssueButton = screen.queryByText(/Resolve issue/) - // Hide banner for Snowflake - // expect(resolveIssueButton).not.toBeInTheDocument() - expect(resolveIssueButton).toBeInTheDocument() + expect(resolveIssueButton).not.toBeInTheDocument() }) describe('when license is expired and seats limit is reached', () => { From 2f0463f6fa59c5211c40cd923fdf96da6fb240a5 Mon Sep 17 00:00:00 2001 From: Jerry Feng Date: Thu, 30 Jan 2025 17:55:53 -0500 Subject: [PATCH 5/5] fix test --- .../SelfHostedLicenseExpiration.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx index 4dba4df4a3..c4153ae363 100644 --- a/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx +++ b/src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx @@ -215,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(() => { @@ -241,7 +242,6 @@ describe('SelfHostedLicenseExpiration', () => { ) const resolveIssueButton = screen.queryByText(/Resolve issue/) - expect(resolveIssueButton).not.toBeInTheDocument() })