Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DISPLAY_SELF_HOSTED_EXPIRATION_BANNER probably #3695

Merged
merged 6 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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']
Expand Down
10 changes: 10 additions & 0 deletions src/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<SelfHostedLicenseExpiration />, { 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
Expand Down Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down