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: display warning and prevent creation on limit #2526

Merged

Conversation

novakzaballa
Copy link
Contributor

@novakzaballa novakzaballa commented Jul 26, 2023

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

  • I have run pre-commit to check linting
  • 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

  • Add limit Alerts If number of features, segments, and segments Overrides exceeds 90% of the limit or if the API calls exceed 70% of the limit.
  • The buttons for creating features, segments, and segments overrides are disabled when the limit is reached.
  • Return limits in the API response for projects and, environments.

How did you test this code?

Unit test added

@vercel
Copy link

vercel bot commented Jul 26, 2023

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

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 14, 2023 6:40pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 14, 2023 6:40pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 14, 2023 6:40pm

@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard api Issue related to the REST API labels Jul 26, 2023
@novakzaballa novakzaballa changed the title feature: display warning and prevent creation on limit feat: display warning and prevent creation on limit Jul 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 27, 2023

Uffizzi Preview deployment-32784 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.07% ⚠️

Comparison is base (34f9a5b) 95.52% compared to head (c6836cd) 95.46%.
Report is 12 commits behind head on main.

❗ Current head c6836cd differs from pull request most recent head c9c2ace. Consider uploading reports for the commit c9c2ace to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2526      +/-   ##
==========================================
- Coverage   95.52%   95.46%   -0.07%     
==========================================
  Files         993      986       -7     
  Lines       28031    27689     -342     
==========================================
- Hits        26778    26434     -344     
- Misses       1253     1255       +2     

see 32 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

This looks good to me now. A minor nitpick would be to ask if we could add a little more margin between the 'Request more API calls' button and the items in the list above it. Maybe even making that button slightly smaller.

@@ -37,6 +37,12 @@ const AppActions = Object.assign({}, require('./base/_app-actions'), {
projectId,
})
},
getEnv(environmentId) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why we need to get the environment this way? It adds to tech debt, ideally it would be an action in useEnvironment.ts

@@ -77,6 +78,7 @@ const Aside = class extends Component {
? {}
: { live_from_after: new Date().toISOString() },
)
AppActions.getEnv(this.props.environmentId)
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this, we're already getting the project's environments in AppActions.getProject

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is triggered every time we change environments. It is done this way because we need to save the response to the store so we can use its data to determine the content of the alert and whether it will be displayed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use the environment endpoint because the project one doesn't have the limits information we need, and Matt asked to keep it this way since it will be more efficient in terms of querying the DB

Copy link
Member

Choose a reason for hiding this comment

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

After our conversation, I think this can now be removed.

@@ -484,6 +507,31 @@ const App = class extends Component {
</div>
) : (
<Fragment>
<Row>
{user &&
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned on slack, I think this should be componentised so that you can use hooks to get the data.

@@ -83,6 +84,14 @@ const controller = {
store.saved()
})
},
getEnv: (envId) => {
data.get(`${Project.api}environments/${envId}/`).then((environment) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is this used anymore?

@@ -50,6 +50,7 @@ const Aside = class extends Component {
? {}
: { live_from_after: new Date().toISOString() },
)
AppActions.getEnv(this.props.environmentId)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to do this

@@ -288,6 +299,17 @@ const App = class extends Component {
)
const dismissed = flagsmith.getTrait('dismissed_announcement')
const showBanner = !dismissed || dismissed !== announcementValue.id
const maxApiCallsPercentage = Utils.calculateRemainingLimitsPercentage(
Copy link
Member

Choose a reason for hiding this comment

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

Is this used anymore

@@ -70,6 +74,13 @@ const App = class extends Component {
AccountStore.getOrganisation()?.id &&
this.state.activeOrganisation !== AccountStore.getOrganisation().id
) {
getSubscriptionMetadata(getStore(), {
Copy link
Member

Choose a reason for hiding this comment

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

Is this used anymore

@novakzaballa novakzaballa merged commit 000be2b into main Sep 18, 2023
@novakzaballa novakzaballa deleted the feature/display-warning-and-prevent-creation-on-limit branch September 18, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants