-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: load modules based on remoteConfig
Remote Config is a seperate product within the firebase platform which allows users to store state remotely which can be edited outside of deployments. Link: https://firebase.google.com/docs/remote-config Using remote configuration we are then able to defer module configuration out to the target environment. This commit adds a check against remote config when: 1. Building the desktop menu 2. Registering routes 3. Example of checking module support within a Profile page Questions which still require further investigation: * Loading state when fetching remote configuration * Use mobx as a wrapper for this Firebase product Request for comment: * A new src/modules/ directory to serve as the primary entry point for interacting with the Module concept.
- Loading branch information
1 parent
887ff58
commit c006e25
Showing
8 changed files
with
160 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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,2 +1,3 @@ | ||
FAST_REFRESH=false | ||
SITE_NAME=Project Kamp | ||
REACT_APP_SITE_VARIANT=dev_site |
This file contains 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 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,27 @@ | ||
import { remoteConfig } from 'src/utils/firebase' | ||
|
||
export async function getSupportedModules(): Promise<string[]> { | ||
await remoteConfig.fetchAndActivate() | ||
return JSON.parse(remoteConfig.getValue('enabledModules').asString()) | ||
} | ||
|
||
export enum MODULE { | ||
HOWTO = 'howto', | ||
MAP = 'map', | ||
EVENTS = 'events', | ||
RESEARCH = 'research', | ||
ACADEMY = 'academy', | ||
} | ||
|
||
/** | ||
* The default configuration which will be used | ||
* if no configuration options for `enabledModules` is | ||
* found on the remote configuration associated with the | ||
* current firebase project. | ||
*/ | ||
remoteConfig.defaultConfig.enabledModules = JSON.stringify([ | ||
MODULE.MAP, | ||
MODULE.HOWTO, | ||
MODULE.EVENTS, | ||
MODULE.ACADEMY, | ||
]) |
This file contains 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 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 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
Oops, something went wrong.