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 alert message in the FE when exceeded the API usage #4027

Merged

Conversation

novakzaballa
Copy link
Contributor

@novakzaballa novakzaballa commented May 24, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  • When the plan is Non Free
Screenshot 2024-05-29 at 1 28 19 PM
  • When the plan is Free
Screenshot 2024-05-29 at 1 29 00 PM

How did you test this code?

  • Use an organisation that exceeds the API usage

Copy link

vercel bot commented May 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 3:57pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 3:57pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jun 17, 2024 3:57pm

@novakzaballa novakzaballa requested review from a team and kyle-ssg and removed request for a team May 24, 2024 19:47
@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label May 24, 2024
@novakzaballa novakzaballa requested a review from zachaysan May 24, 2024 19:47
Copy link
Contributor

github-actions bot commented May 24, 2024

Uffizzi Preview deployment-52244 was deleted.

Copy link
Contributor

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

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

The code looks good to me, but just to be safe try to get @kyle-ssg to review it since he's better at frontend code review than I am.

Also, just a reminder that we discussed adding a feature flag for this. Please add it and share the flag name with me so we can test this on staging when we're ready.

Comment on lines 128 to 129
<b>{apiOrganisationUsage?.results[0].percent_usage}</b>
{'% '}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny nit: the % should be within the bold tag, since it looks weird to bold just the number without the percent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, also I added the flag name in the description PR.

@novakzaballa novakzaballa linked an issue May 27, 2024 that may be closed by this pull request
@kyle-ssg
Copy link
Member

kyle-ssg commented May 29, 2024

Is this feature tied to the following flag? I believe it's setup incorrectly - doesn't look like it should be permanent and was also never enabled.

image

@matthewelwell
Copy link
Contributor

@novakzaballa as discussed, this code should be mostly deleted (sorry!). We should reuse the code in frontend/web/components/OrganisationLimit.tsx and just update the logic to grab the current billing period as was added in the PR here.

@novakzaballa novakzaballa changed the title feat: Add butter bar in the FE for api-usage-notification endpoint feat: Add alert message in the FE when exceeded the API usage May 29, 2024
@novakzaballa novakzaballa requested a review from zachaysan May 29, 2024 17:35
Copy link
Contributor

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

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

Looks good from my perspective, but still try to get @kyle-ssg to look it over for FE bugs.

Comment on lines 38 to 46
<>
Your organisation has exceeded its API usage quota{' '}
<b>{`(${error}).`}</b>{' '}
{Utils.getPlanName(this.props.organisationPlan) === 'Free' ? (
<b>Please upgrade your plan to continue receiving service.</b>
) : (
<b>Automated billing for the overages may apply.</b>
)}
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

The bolding of the error amount looks weird because the end of the sentence extends into the next one. I recommend doing it like this:

Suggested change
<>
Your organisation has exceeded its API usage quota{' '}
<b>{`(${error}).`}</b>{' '}
{Utils.getPlanName(this.props.organisationPlan) === 'Free' ? (
<b>Please upgrade your plan to continue receiving service.</b>
) : (
<b>Automated billing for the overages may apply.</b>
)}
</>
<>
Your organisation has exceeded its API usage quota{' '}
{`(${error}).`}{' '}
{Utils.getPlanName(this.props.organisationPlan) === 'Free' ? (
<b>Please upgrade your plan to continue receiving service.</b>
) : (
<b>Automated billing for the overages may apply.</b>
)}
</>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jun 13, 2024
@novakzaballa
Copy link
Contributor Author

novakzaballa commented Jun 13, 2024

Can we fix the styling on this?

image
Screenshot 2024-06-13 at 4 41 15 PM Screenshot 2024-06-13 at 4 40 42 PM

@matthewelwell Done

body = { ...body, ...{ billing_period: 'current_billing_period' } }
}

const { data: totalApiCalls } = useGetOrganisationUsageQuery(body, {
Copy link
Member

@kyle-ssg kyle-ssg Jun 14, 2024

Choose a reason for hiding this comment

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

Can’t this just go into the new component ? It may as well be just self contained / can be added anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure I understand your suggestion. Are you suggesting using this hook in the new QuotaExceededMessagecomponent?

Copy link
Member

@kyle-ssg kyle-ssg Jun 17, 2024

Choose a reason for hiding this comment

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

Yes or just move the QuotaExceededMessagecomponent to this, it doesn't look like it's necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@novakzaballa novakzaballa added this pull request to the merge queue Jun 18, 2024
Merged via the queue into main with commit da46dab Jun 18, 2024
21 checks passed
@novakzaballa novakzaballa deleted the feat/add-a-butter-bar-in-the-fe-for-api-usage-notification branch June 18, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create butter bar frontend for API usage notification
4 participants