This React application contains code examples that cover how to use Mosaic services to achieve certain scenarios.
Each scenario is developed to be a concise example that showcases the use-case (i.e. the scenario) and what code is responsible to achieve it. This will act as developer documentation for frontend application developers who would be interested to develop against Mosaic services.
The scenarios are grouped into areas to be easily discoverable:
- user-authentication
- SignInWithExternalIdp
- ShowUserInfo
- user-profile-management
- CreateProfile
- SwitchActiveProfile
- catalog-consumption
- GetSingleItem
- video-playback
- PlayProtectedVideo
- etc.
The scenario-registry.ts found in the root of the project maintains an array
of all scenarios that will be loaded into the application, and this array is fed
into the ScenarioHostApp in the index.tsx file.
The ScenarioHost exposes several commonly used features that maybe required by each scenario.
Such as:
- activeProfile
- Through this object, the individual scenario can access different Endpoint
URLs of the Mosaic services, and different IDs (i.e.
tenant_id,environment_id) that are configured by the user.
- Through this object, the individual scenario can access different Endpoint
URLs of the Mosaic services, and different IDs (i.e.
- logger
- Through the logger each scenario can print some output to the Logger component that will provide meaningful feedback to the user.
- setVariable, getVariable
- These methods will allow scenarios to share variables between different
scenarios (i.e. user-access-token is set by scenario-A, and it is later
accessed by scenario-B). The
./src/common/types/well-known-variable-keys.tsfile will list all well-known variables that can be shared between scenarios.
- These methods will allow scenarios to share variables between different
scenarios (i.e. user-access-token is set by scenario-A, and it is later
accessed by scenario-B). The
The semantic-ui-react library is used as the UI Component library when
developing the scenarios. In real-world applications, the appropriate UI
libraries shall be used.
- Run
yarnto install dependencies - Copy
.env.templateinto.env, and change the values if needed - Run
yarn devto start running the project in watch mode - Run
yarn util:start-proxyto start alocalhostproxy to theMosaic User Serviceupstream- Ensure to set/update the URL for
User Auth Base URLin yourMosaic Frontend Samplesprofile to use the proxy endpoint for requests
- Ensure to set/update the URL for
- Run
yarn buildto generate thebuildfolder - Use the
Dockerfilein the root to build a docker imagedocker build -t mosaic-fe-samples .