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

feat: add banners for seats + license expiration #2440

Merged
merged 14 commits into from
Dec 13, 2023

Conversation

adrian-codecov
Copy link
Contributor

@adrian-codecov adrian-codecov commented Dec 6, 2023

Description

This PR adds a banner for self-hosted customers showing their expiration + seat count limitations.

Closes codecov/engineering-team#881

Notable Changes

  • Adds the SelfHostedLicenseExpiration component and a modal to show the items of interest. Adds this to the GlobalBanners component
  • Adds some links to the usenavlinks file
  • Renames hook for seats and license while adding the seatsLimit + seatsUsed keys (bloats the PR a bit, I apologize)
  • Adds tests to these ^

Screenshots

screen-capture.9.webm

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link

netlify bot commented Dec 6, 2023

Deploy Preview for gazebo-staging ready!

Name Link
🔨 Latest commit c0625a4
🔍 Latest deploy log https://app.netlify.com/sites/gazebo-staging/deploys/6579d13b59119500088a33a4
😎 Deploy Preview https://deploy-preview-2440--gazebo-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@adrian-codecov adrian-codecov marked this pull request as ready for review December 6, 2023 20:30
@codecov-qa
Copy link

codecov-qa bot commented Dec 6, 2023

Codecov Report

Merging #2440 (c0625a4) into main (aa54260) will increase coverage by 0.01%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2440      +/-   ##
==========================================
+ Coverage   98.09%   98.11%   +0.01%     
==========================================
  Files         767      770       +3     
  Lines        9786     9870      +84     
  Branches     2479     2510      +31     
==========================================
+ Hits         9600     9684      +84     
  Misses        184      184              
  Partials        2        2              
Files Coverage Δ
src/config.js 100.00% <100.00%> (ø)
...Tab/subroute/Fileviewer/ComponentsSelectCommit.tsx 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.js 100.00% <100.00%> (ø)
...ervices/selfHosted/useSelfHostedSeatsAndLicense.ts 100.00% <100.00%> (ø)
src/shared/GlobalBanners/GlobalBanners.jsx 100.00% <ø> (ø)
.../LicenseExpirationModal/LicenseExpirationModal.tsx 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.jsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 97.30% <ø> (ø)
Pages 98.96% <100.00%> (+<0.01%) ⬆️
Services 99.44% <100.00%> (+<0.01%) ⬆️
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.32% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa54260...c0625a4. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 6, 2023

Codecov Report

Merging #2440 (c0625a4) into main (aa54260) will increase coverage by 0.01%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2440      +/-   ##
==========================================
+ Coverage   98.09%   98.11%   +0.01%     
==========================================
  Files         767      770       +3     
  Lines        9786     9870      +84     
  Branches     2474     2496      +22     
==========================================
+ Hits         9600     9684      +84     
  Misses        184      184              
  Partials        2        2              
Files Coverage Δ
src/config.js 100.00% <100.00%> (ø)
...Tab/subroute/Fileviewer/ComponentsSelectCommit.tsx 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.js 100.00% <100.00%> (ø)
...ervices/selfHosted/useSelfHostedSeatsAndLicense.ts 100.00% <100.00%> (ø)
src/shared/GlobalBanners/GlobalBanners.jsx 100.00% <ø> (ø)
.../LicenseExpirationModal/LicenseExpirationModal.tsx 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.jsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 97.30% <ø> (ø)
Pages 98.96% <100.00%> (+<0.01%) ⬆️
Services 99.44% <100.00%> (+<0.01%) ⬆️
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.32% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa54260...c0625a4. Read the comment docs.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Merging #2440 (c0625a4) into main (aa54260) will increase coverage by 0.02%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #2440     +/-   ##
=======================================
+ Coverage   98.10   98.12   +0.02     
=======================================
  Files        767     770      +3     
  Lines       9786    9870     +84     
  Branches    2460    2466      +6     
=======================================
+ Hits        9600    9684     +84     
  Misses       184     184             
  Partials       2       2             
Files Coverage Δ
src/config.js 100.00% <100.00%> (ø)
...Tab/subroute/Fileviewer/ComponentsSelectCommit.tsx 100.00% <100.00%> (ø)
...rvices/navigation/useNavLinks/useStaticNavLinks.js 100.00% <100.00%> (ø)
...ervices/selfHosted/useSelfHostedSeatsAndLicense.ts 100.00% <100.00%> (ø)
src/shared/GlobalBanners/GlobalBanners.jsx 100.00% <ø> (ø)
.../LicenseExpirationModal/LicenseExpirationModal.tsx 100.00% <100.00%> (ø)
...dLicenseExpiration/SelfHostedLicenseExpiration.jsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 97.30% <ø> (ø)
Pages 98.96% <100.00%> (+<0.01%) ⬆️
Services 99.44% <100.00%> (+<0.01%) ⬆️
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.32% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa54260...c0625a4. Read the comment docs.

@@ -21,54 +21,56 @@ describe('useStaticNavLinks', () => {
const links = view.result.current

describe.each`
link | outcome
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the space to the right cause the name I made for the new variable didn't fit, that's why all of these changed, not unexpected

.object({
config: z
.object({
seatsUsed: z.number(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add these since the last time I made this hook

isLicenseExpiringWithin30Days: boolean
}

const LicenseExpirationModal = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1/2 files where the meat is for the PR

isLicenseExpiringWithin30Days: PropTypes.bool.isRequired,
}

const SelfHostedLicenseExpiration = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1/2 files where the meat is for the PR

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments to take a peak at. As well I'm a little concerned because we currently deploy "self-hosted" as our dedicated cloud and I did not see any specific checks to remove things for instance linking out to generating a new license, as dedicated cloud users really should not have that option.

@@ -19,28 +21,34 @@ export const SelfHostedLicenseSchema = z

export interface UseTierArgs {
provider: string
opts?: QueryOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you limit these options to just what you require, i.e. enabled in this case. There are typing issues if you just pass the whole options for instance select is totally broken when just using the standard QueryOptions type because there is no type information for the return type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see a fix for this in the future tho ...

Comment on lines 13 to 19
const LicenseExpirationModal = ({
isModalOpen,
setIsModalOpen,
isSeatsLimitReached,
isLicenseExpired,
isLicenseExpiringWithin30Days,
}: LicenseExpirationModalArgs) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest swapping this over to:

const LicenseExpirationModal: React.FC<LicenseExpirationModalArgs> = ({ /* ... */ }) => {
  // ...
}

That way you get the correct return type checks

Comment on lines +80 to +88
<div className="flex gap-2">
{/* @ts-expect-error */}
<Button
to={{ pageName: 'generateSelfHostedLicense' }}
showExternalIcon={false}
>
Generate New License
</Button>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So because we're technically running self hosted for dedicated cloud, I believe this will still show for those users as well? We don't have any checks afaik that differentiate between the two.

})
afterEach(() => jest.resetAllMocks())

it('does not render the banner when it should not be displayed', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this title to be a little more specific as to why it should not be displayed? Just to give a little more context as to what this is testing.

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment to keep in mind for the future, pending the checks for dedicated cloud everything else looks great 👍

@@ -160,7 +160,7 @@ describe('SelfHostedLicenseExpiration', () => {
})
afterEach(() => jest.resetAllMocks())

it('does not render the banner when it should not be displayed', async () => {
it('does not render the banner when there is not a seat limit or when the license has not expired/will expire within 30 days', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just being super picky here, no changes required for this PR, but for the future if you find yourself with one of these really long strings, you can always take it apart and wrap the it block inside of a describe so in this case something like the following, as well I might break this up into two tests even if it's checking the same outcome:

describe('when there is not a seat limit', () => {
 it('does not render the banner', () => { /* ... */)
}

describe('when the license has not expired/will expire within 30 days', () => {
  it('does not render the banner', () => {})
})

@adrian-codecov adrian-codecov merged commit 0349f80 into main Dec 13, 2023
50 checks passed
@adrian-codecov adrian-codecov deleted the 881-self-hosted-expiration-banner branch December 13, 2023 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Client] - Create Banner to Surface Self Hosted License Expiration Date
2 participants