-
Notifications
You must be signed in to change notification settings - Fork 2
Feature Flags Basic Implementation #289
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
Open
mlaws21
wants to merge
20
commits into
master
Choose a base branch
from
feature-flags
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e28ed5d
ui page and working on about feature flag
mlaws21 4635ca3
adding basic feature flags, and impl for about, FAQ, wiki
mlaws21 0cd0cd7
Rename featureFlags.tsx to FeatureFlags.tsx
mlaws21 4586d99
trying to fix naming errors
mlaws21 163de5a
Refactored Feature flags to use redux
mlaws21 cc6ca5d
removed uneccesary code
mlaws21 d3e7634
Merge branch 'master' into feature-flags
mlaws21 9d1f4e2
adding admin authentication
mlaws21 a66883d
added annotation need help to fix
mlaws21 5c01276
Changed defautls to true, added appSelectors
mlaws21 6355b31
added app selectors
mlaws21 3f6354f
added admin perms
mlaws21 41a26d6
linting
mlaws21 97f58a7
removed toggle and added enum functionality
mlaws21 ec6eb4a
Reafactored to only enabled/disabled
mlaws21 78522ff
updating perms
mlaws21 eddf7f9
refactored naming and fixxed typing
mlaws21 bde4275
fixed stylistic concerns
mlaws21 fd6c354
fixed issues and added styling to dashboard
mlaws21 306f51e
removing comments
mlaws21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .nav_feature_div { | ||
| display: inline-block; | ||
| } | ||
|
|
||
| .nav_feature_div:not(:empty) { | ||
| padding-right: 2em; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // React imports | ||
| import React from "react"; | ||
| import { | ||
| FFState, | ||
| updateFeatureFlag, | ||
| FeatureFlag, | ||
| } from "../../../lib/featureFlagSlice"; | ||
| import { RootState } from "../../../lib/store"; | ||
| import { useAppDispatch, useAppSelector } from "../../../lib/store"; | ||
|
|
||
| const Dashboard = () => { | ||
| const dispatch = useAppDispatch(); | ||
| const featureFlagState = useAppSelector( | ||
| (state: RootState) => state.featureFlagState | ||
| ); | ||
|
|
||
| const setFeatureFlag = (myflag: keyof FeatureFlag, newState: FFState) => { | ||
| dispatch(updateFeatureFlag({ flag: myflag, value: newState })); | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <p>Dashboard</p> | ||
| {Object.entries(featureFlagState).map(([key, value]) => ( | ||
| <div key={key}> | ||
| {Object.entries(FFState).map(([stateKey, stateValue]) => ( | ||
| <button | ||
| key={key + stateKey} | ||
| onClick={() => | ||
| setFeatureFlag(key as keyof FeatureFlag, stateKey as FFState) | ||
| } | ||
| > | ||
| {"Set " + key.slice(6, key.length) + " to " + stateKey} | ||
| </button> | ||
| ))} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Dashboard; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
|
|
||
| // const API_ADDRESS = "http://localhost:8080"; | ||
|
|
||
| export enum FFState { | ||
| Enabled = "Enabled", | ||
| Disabled = "Disabled", | ||
| } | ||
|
|
||
| export interface FeatureFlag { | ||
| enableAbout: FFState; | ||
| enableWiki: FFState; | ||
| enableFAQ: FFState; | ||
|
|
||
| // Add more feature flags as needed | ||
| } | ||
|
|
||
| export const initialState: FeatureFlag = { | ||
| enableAbout: FFState.Enabled, | ||
| enableWiki: FFState.Enabled, | ||
| enableFAQ: FFState.Enabled, | ||
| }; | ||
|
|
||
| const featureFlagSlice = createSlice({ | ||
| name: "featureFlags", | ||
| initialState, | ||
| reducers: { | ||
| updateFeatureFlag: ( | ||
| state, | ||
| action: PayloadAction<{ flag: keyof FeatureFlag; value: FFState }> | ||
| ) => { | ||
| const { flag, value } = action.payload; | ||
| if (flag in state) { | ||
| state[flag] = value; | ||
| } | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const { updateFeatureFlag } = featureFlagSlice.actions; | ||
|
|
||
| // export const getFeatureFlag = (state: FeatureFlagsState, flag: keyof FeatureFlagsState) => featureFlagsState[flag]; | ||
mlaws21 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| export default featureFlagSlice.reducer; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,23 @@ | ||
| import courseReducer from "./course"; | ||
| import schedulerUtilReducer from "./schedulerUtils"; | ||
| import authReducer from "../lib/authSlice"; | ||
| import featureFlagReducer from "../lib/featureFlagSlice"; | ||
|
|
||
| import goodrichReducer from "./goodrich"; | ||
|
|
||
| const rootReducer = { | ||
| courseState: courseReducer, | ||
| schedulerUtilState: schedulerUtilReducer, | ||
| authState: authReducer, | ||
| goodrichState: goodrichReducer, | ||
| featureFlagState: featureFlagReducer, | ||
| }; | ||
|
|
||
| export default rootReducer; | ||
| export { courseReducer, schedulerUtilReducer, authReducer, goodrichReducer }; | ||
| export { | ||
| courseReducer, | ||
| schedulerUtilReducer, | ||
| authReducer, | ||
| goodrichReducer, | ||
| featureFlagReducer, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.