Skip to content

Commit e9ca127

Browse files
trent-codecovkatia-sentryJerrySentry
authored
DISPLAY_SELF_HOSTED_EXPIRATION_BANNER probably (#3695)
Co-authored-by: katia-sentry <[email protected]> Co-authored-by: Jerry Feng <[email protected]>
1 parent 57a466b commit e9ca127

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

src/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const defaultConfig = {
1313
GH_APP: DEFAULT_GH_APP,
1414
GH_APP_AI: 'codecov-ai',
1515
SUNBURST_ENABLED: true,
16+
DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true,
1617
}
1718

1819
export function removeReactAppPrefix(obj) {
@@ -38,6 +39,11 @@ export function removeReactAppPrefix(obj) {
3839
keys['SUNBURST_ENABLED'] = keys['SUNBURST_ENABLED'].toLowerCase() === 'true'
3940
}
4041

42+
if ('DISPLAY_SELF_HOSTED_EXPIRATION_BANNER' in keys) {
43+
keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'] =
44+
keys['DISPLAY_SELF_HOSTED_EXPIRATION_BANNER'].toLowerCase() === 'true'
45+
}
46+
4147
if ('SENTRY_TRACING_SAMPLE_RATE' in keys) {
4248
keys['SENTRY_TRACING_SAMPLE_RATE'] = parseFloat(
4349
keys['SENTRY_TRACING_SAMPLE_RATE']

src/config.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ describe('config', () => {
7070
})
7171
})
7272

73+
describe('sets DISPLAY_SELF_HOSTED_EXPIRATION_BANNER to boolean', () => {
74+
it('sets to true', () => {
75+
const obj = { DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: 'true' }
76+
77+
expect(removeReactAppPrefix(obj)).toEqual({
78+
DISPLAY_SELF_HOSTED_EXPIRATION_BANNER: true,
79+
})
80+
})
81+
})
82+
7383
describe('sets IS_DEDICATED_NAMESPACE to boolean', () => {
7484
it('sets to true', () => {
7585
const obj = {

src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ describe('SelfHostedLicenseExpiration', () => {
165165
expect(resolveIssueButton).not.toBeInTheDocument()
166166
})
167167

168+
it('does not render the banner when disabled', async () => {
169+
config.IS_SELF_HOSTED = true
170+
config.IS_DEDICATED_NAMESPACE = true
171+
config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER = false
172+
setup({
173+
seatsUsed: 5,
174+
seatsLimit: 10,
175+
expirationDate: null,
176+
})
177+
render(<SelfHostedLicenseExpiration />, { wrapper: wrapper(['']) })
178+
179+
const resolveIssueButton = screen.queryByText(/Resolve issue/)
180+
expect(resolveIssueButton).not.toBeInTheDocument()
181+
})
182+
168183
it('does not render the banner when there are no seats used', async () => {
169184
config.IS_SELF_HOSTED = true
170185
config.IS_DEDICATED_NAMESPACE = true
@@ -200,6 +215,7 @@ describe('SelfHostedLicenseExpiration', () => {
200215
vi.setSystemTime(new Date('2023-08-01'))
201216
config.IS_SELF_HOSTED = true
202217
config.IS_DEDICATED_NAMESPACE = true
218+
config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER = true
203219
})
204220

205221
afterEach(() => {

src/shared/GlobalBanners/SelfHostedLicenseExpiration/SelfHostedLicenseExpiration.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ const SelfHostedLicenseExpiration = () => {
8181
const isLicenseExpiringWithin30Days = dateDiff < 31 && dateDiff >= 0
8282

8383
const shouldDisplayBanner =
84-
isSeatsLimitReached || isLicenseExpired || isLicenseExpiringWithin30Days
84+
(isSeatsLimitReached ||
85+
isLicenseExpired ||
86+
isLicenseExpiringWithin30Days) &&
87+
config.DISPLAY_SELF_HOSTED_EXPIRATION_BANNER
8588

8689
if (!shouldDisplayBanner) {
8790
return null

0 commit comments

Comments
 (0)