portal-config
Portal Configuration Module
Introduction
This document serves as the documentation for the portal configuration module. The module provides functionality for configuring portal settings, managing clients, retrieving portal data, and handling errors related to portal and app loading.
....
Portal Configuration Setup
To configure the portal using the enablePortalConfig
function, follow the steps outlined below:
import { enablePortalConfig } from '@portal/core';
// Configure the portal
enablePortalConfig(config, (builder) => {
// Set the base configuration
builder.setConfig({
portalId: portalConfig.portalId,
portalEnv: portalConfig.fusionLegacyEnvIdentifier,
});
// Define portal routes
builder.setRoutes({
root: {
pageKey: 'project-portal',
},
routes: [
{
path: 'project/*',
pageKey: 'project',
messages: {
errorMessage: 'Fail to load project page',
},
children: [
{
path: ':contextId',
pageKey: 'project',
messages: {
errorMessage: 'Fail to load project page',
},
},
],
},
{
path: 'facility/*',
pageKey: 'facility',
messages: {
errorMessage: 'Fail to load facility page',
},
children: [
{
path: ':contextId',
pageKey: 'facility',
messages: {
errorMessage: 'Fail to load facility page',
},
},
],
},
],
});
});
Configuration Explanation
Set Base Configuration:
- Use
builder.setConfig
to set the base configuration for the portal. - Provide the
portalId
andportalEnv
obtained fromportalConfig
.
- Use
Define Portal Routes:
- Use
builder.setRoutes
to define the portal routes. - Specify the root route with its corresponding
pageKey
. - Define individual routes with
path
,pageKey
, and optionalmessages
for error handling. - Optionally, define child routes for nested navigation.
- Use
Error Handling
The module provides error handling for various scenarios, including portal loading errors (PortalLoadError
) and app loading errors (AppsLoadError
). Ensure to handle errors appropriately in your application.
Conclusion
The portal configuration module provides a robust solution for managing portal settings and retrieving portal data asynchronously. By following the usage guidelines and leveraging the provided classes and interfaces, developers can seamlessly integrate portal configuration functionalities into their applications.