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 feat flag for courses dropdown & webinars #2666

Merged
merged 6 commits into from
Jun 2, 2023

Conversation

asadali145
Copy link
Contributor

@asadali145 asadali145 commented Jun 2, 2023

Pre-Flight checklist

  • Screenshots and design review for any changes that affect layout or styling
    • Desktop screenshots
    • Mobile width screenshots
  • Testing
    • Code is tested
    • Changes have been manually tested
  • Settings
    • New settings are documented and present in app.json
    • New settings have reasonable development defaults, if applicable

What are the relevant tickets?

None but this discussion.

What's this PR do?

Adds a feature flag for the course topics dropdown.

How should this be manually tested?

  • Set ENABLE_COURSE_DROPDOWN to True and the header course topics dropdown should be enabled.
  • Set ENABLE_COURSE_DROPDOWN to False and the header course topics dropdown should be disabled.

Screenshots (if appropriate)

Screen Shot 2023-06-02 at 2 23 41 PM Screen Shot 2023-06-02 at 2 24 02 PM

@odlbot odlbot temporarily deployed to xpro-ci-pr-2666 June 2, 2023 09:24 Inactive
@asadali145 asadali145 marked this pull request as ready for review June 2, 2023 09:27
@odlbot odlbot temporarily deployed to xpro-ci-pr-2666 June 2, 2023 09:51 Inactive
@odlbot odlbot temporarily deployed to xpro-ci-pr-2666 June 2, 2023 10:27 Inactive
@odlbot odlbot temporarily deployed to xpro-ci-pr-2666 June 2, 2023 10:40 Inactive
@asadali145 asadali145 changed the title feat: add feat flag for courses dropdown feat: add feat flag for courses dropdown & webinars Jun 2, 2023
Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

Code review, Just a couple of minor changes.

@@ -1432,4 +1432,10 @@
description="Comma separated string of course/program runs/Ids that support digital credentials",
)

ENABLE_COURSE_DROPDOWN = get_bool(
Copy link
Contributor

Choose a reason for hiding this comment

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

The standard name format to define feature flags is FEATURE_*. Which in this case could be FEATURE_COURSE_DROPDOWN.

The reason for this is that the manipulation of the setting from the environment file automatically handles the features and adds them in setting.FEATURES dict which we can then use anywhere. An example of adding that can be seen in 0ade363

mitxpro/utils.py Outdated
@@ -594,4 +594,5 @@ def get_js_settings(request: HttpRequest):
},
"digital_credentials": settings.FEATURES.get("DIGITAL_CREDENTIALS", False),
"digital_credentials_supported_runs": settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS,
"enable_course_dropdown": settings.ENABLE_COURSE_DROPDOWN,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be changed accordingly as per the last comment.

Comment on lines 87 to 95
it("does not have a CatalogMenu component when feature flag is disabled", () => {
SETTINGS.enable_course_dropdown = false
assert.isNotOk(
shallow(<TopAppBar currentUser={user} location={null} errorPageHeader={null} courseTopics={courseTopics} />)
.find("CatalogMenu")
.exists()
)
})

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can merge this test and the one below with a parameterized test that validates the UI when the flag is on and off.

Comment on lines 139 to 142
const courseTopicsQuery = SETTINGS.enable_course_dropdown ? catalog.courseTopicsQuery() : []

const mapPropsToConfig = () => [users.currentUserQuery(), courseTopicsQuery]

Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be simplified like:

const mapPropsToConfig = () => SETTINGS.enable_course_dropdown ? [users.currentUserQuery(), courseTopicsQuery]: [users.currentUserQuery()]

const mapPropsToConfig = () => errorPageHeader ? [] : [users.currentUserQuery(), catalog.courseTopicsQuery()]
const courseTopicsQuery = SETTINGS.enable_course_dropdown ? catalog.courseTopicsQuery() : []

const mapPropsToConfig = () => errorPageHeader ? [] : [users.currentUserQuery(), courseTopicsQuery]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above to simplify, If possible

@odlbot odlbot temporarily deployed to xpro-ci-pr-2666 June 2, 2023 11:26 Inactive
Copy link
Contributor

@arslanashraf7 arslanashraf7 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 👍

@asadali145 asadali145 merged commit 456c344 into master Jun 2, 2023
@odlbot odlbot mentioned this pull request Jun 2, 2023
11 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.

3 participants