Skip to content

Feature flag support#3129

Merged
rtibbles merged 10 commits intolearningequality:unstablefrom
bjester:feature-flags
May 3, 2021
Merged

Feature flag support#3129
rtibbles merged 10 commits intolearningequality:unstablefrom
bjester:feature-flags

Conversation

@bjester
Copy link
Member

@bjester bjester commented Apr 29, 2021

Summary

Allows for customization of Studio behavior on per-user basis through features defined in a static JSON file and granted through the admin interface.

Description of the change(s) you made

  • Adds feature_flags JSONB column to the User model
  • Adds jsonschema dependency and resolves cross-dependency versioning conflicts
  • Adds JSON file in form of a JSON schema to itemize available feature flags and validate feature flag data prior to saving
  • Adds static alias to Webpack for loading JSON schema on frontend
  • Exposes table of feature flags using the JSON schema in the Studio admin UI for toggling the features
  • Refactors older user details API view into the AdminUserViewSet
  • Fixes/refactors permissions for editing user record
  • Adds function to garbage collect that cleans up lingering feature flags in the database

Manual verification steps performed

  1. Log into Studio admin
  2. Click "Users" tab
  3. View a user's details
  4. Enable the dev feature
  5. Verify the feature's state for the user in the database
  6. Disable the dev feature
  7. Verify the feature's state for the user in the database
  8. Manually add non-existent feature flag to the user record in the database
  9. Run python manage.py garbage_collect
  10. Verify the user in the database no longer has the feature flag manually added

Screenshots (if applicable)

Screenshot from 2021-05-03 11-33-39

Enabling Disabling
Screenshot from 2021-05-03 11-31-15 Screenshot from 2021-05-03 11-30-55

References

Resolves #3120

Comments

In the above issue it has the following deliverable:

Add under setting disk space section, to allow reuse of Save Changes button already present

I did not follow the above deliverable because the save button is contained in a standalone component which would either require additional refactoring or would otherwise not be nominally understandable. Instead I added it below and used a KSwitch which is expected to apply the change immediately (without the need for a save button).


Contributor's Checklist

PR process:

  • If this includes an internal dependency change, a link to the diff is provided
  • If any Python requirements have changed, the updated requirements.txt files also included in this PR
  • Migrations are safe for a large db

Studio-specifc:

  • All user-facing strings are translated properly
  • The notranslate class been added to elements that shouldn't be translated by Google Chrome's automatic translation feature (e.g. icons, user-generated text)
  • All UI components are LTR and RTL compliant
  • If there new ways this uses user data that needs to be factored into our Privacy Policy, it has been noted.

Testing:

  • Code is clean and well-commented
  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

Reviewer's Checklist

This section is for reviewers to fill out.

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@bjester bjester marked this pull request as ready for review May 3, 2021 19:45
annotations["editable_channels__ids"] = NotNullArrayAgg("editable_channels__id")
annotations["view_only_channels__ids"] = NotNullArrayAgg(
"view_only_channels__id"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

These fields weren't used anywhere

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Works precisely as I would expect!

from django.conf.urls import include
from django.conf.urls import url
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
Copy link
Member

Choose a reason for hiding this comment

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

Hah, my linter also just picked this up.

@rtibbles rtibbles merged commit 9dde3fd into learningequality:unstable May 3, 2021
@bjester bjester mentioned this pull request Jan 26, 2024
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Basic user scoped feature flags

2 participants