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

Usage limits for KoboToolbox-hosted servers #4578

Merged
merged 79 commits into from Aug 22, 2023
Merged

Usage limits for KoboToolbox-hosted servers #4578

merged 79 commits into from Aug 22, 2023

Conversation

LMNTL
Copy link
Contributor

@LMNTL LMNTL commented Aug 10, 2023

Checklist

  1. If you've added code that should be tested, add tests
  2. If you've changed APIs, update (or create!) the documentation
  3. Ensure the tests pass
  4. Make sure that your code lints and that you've followed our coding style
  5. Write a description of your work suitable for publishing on our forum
  6. Mention any related issues in this repository (as #ISSUE) and in other repositories (as kobotoolbox/other#ISSUE)
  7. Open an issue in the docs if there are UI/UX changes

Description

Add usage limits on submissions, data, and NLP for users on KoboToolbox-hosted servers.

Notes

Changes:

  • Usage page (/#/account/usage) has been updated to reflect total usage for a user's organization.
  • When Stripe is enabled:
    • /api/v2/service_usage now calculates usage based on a subscriber's plan start date
    • Usage page now reflects account limits based on Stripe settings and/or FREE_TIER_THRESHOLDS constance config
    • Usage page now displays warnings when the user is approaching (> 80%) or over (> 100%) an account limit
    • Warning banners will appear on the My Projects page when a user is over their limits
    • A modal will pop up on My Projects once a day for users that have gone over their limits
    • 2FA is disabled for users without a paid plan unless they have MFA per-user availability set

Depends on kobocat#889; without the code changes and migrations from that PR, usage will be calculated incorrectly.

LMNTL and others added 30 commits May 17, 2023 15:47
LMNTL and others added 27 commits August 2, 2023 13:01
 # Conflicts:
 #	kpi/tests/api/test_api_environment.py
 #	kpi/views/environment.py
* add button color option for dark blue

* Added props to style koboModal header and footer

* Modal for any limits exceeding and calculating those limits.

* Add translation function

* Add css padding and aria labels

* Linting and formating

* update kobo-common version

* Updated lock file with version kobo-compose

* Updated color and kobo common version to older version

* Bug fix for initial load not rendering update to limits

* ran install to fix build error

* Fixed package lock from merge conflict

* initial style for limit banner

* Add dark red button styles

* updated to use bytes not GB

* Linting and formatting fixes

* Updated banner to only show when dismissed is true and cleaned up some code

* Clean  up and PR updates

* added initial check for constant free_tier_thresholds

* removed console logs

* added line for data being set to submission limits for free tier thresholds

* PR updates to refactor and fix small style bugs
…o-projects-page

Add Modal and Banner for when user goes over limits to my projects page
* add usage limits to usage page

* add recurring property to price

* add highlights for usage over limits with very basic styling

* add warning icon

* prevent subscriptionStore from sending multiple simultaneous fetches

* install prettybytes

* add amber to icon color options

* update usage page structure to match figma

* fix ts error in subscriptionStore

* allow service_usage to accept POST requests

* refactor getUsage to optionally send organization_id

* update usage page

* show monthly/annual usage data based on plan type, add loading state

* fix some ts/linting errors

* remove unused file dataUsageStore.ts

* extract UsageContainer component

* extract some logic to *.api.* files

* remove unused imports

* add missing usageContainer tsx and scss files

* finalize styling

* get usage by organization in overlimits banners/modal

* extract USAGE_WARNING_RATIO to a constant

* run prettier/eslint

* remove unused imports from subscriptionStore

* try/catch call to getOrganization

* refactor date formatting utils

* use refactored formatDate instead of recreating it

* fix misleading type

* refactor isLoaded to isInitialised

* try/catch in getUsageForOrganization

* extract usage.loaded to separate booleans

* handle null return from getUsageForOrganization

* remove duplicate visuallyhidden class

* refactor RecurringInterval to type instead of enum

* extract AriaText component to common components library

* change dates to use time tags

* add story for AriaText

* use base kobo colors instead of modifying opacity in usageContainer

* remove mobx observables from react dep arrays

* pull truncate into a utility function

* remove some unnecessary brackets around JSX string args
@LMNTL LMNTL marked this pull request as ready for review August 22, 2023 16:55
@jnm jnm merged commit 645c490 into beta Aug 22, 2023
4 checks passed
@jnm jnm deleted the feature/usage-limits branch August 22, 2023 21:59
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.

None yet

4 participants