Skip to content

Commit

Permalink
OM-329: add contribution point to render custom dashboard page
Browse files Browse the repository at this point in the history
  • Loading branch information
olewandowski1 committed Oct 30, 2024
1 parent 2aaaa09 commit 524a36d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ It is dedicated to be deployed as a module of [openimis-fe_js](https://github.co

## Available Contribution Points

- `home.HomePage.Container`: Use to override the container of the homepage completely (default: display `home.HomePage.Blocks`)
- `home.HomePage.Container`: Use to extend the container of the homepage completely (default: display `home.HomePage.Blocks`)
- `home.HomePage.Blocks`: Blocks displayed on the homepage. The current `user` is passed to each contribution. An example of block can be found on the [Claim management module](https://github.com/openimis/openimis-fe-claim_js)
- `home.HomePage.customDashboard`: A contribution key that enables rendering a custom dashboard as the homepage. To activate this, a component must be provided with the `home.HomePage.customDashboard` contribution key, and the __HomePage.enableCustomDashboard__ configuration must be set to __true__ in the database.

## Configurations Options

- `HomePageContainer.showHomeMessage`: a boolean configuration flag that determines whether or not a special message will be displayed on the home page. If set to true, the application will fetch and display HTML content based on the URL specified in **HomePageContainer.homeMessageURL**. By default, this is set to false. It means that no additional message will be displayed on the home page.
- `HomePageContainer.homeMessageURL`: a string configuration that specifies the URL from which to fetch the HTML payload for display on the home page. By default, this is set to an empty string (""), meaning no URL is specified. This URL is used only when **HomePageContainer.showHomeMessage** is set to true.
- `HomePageContainer.showHealthFacilityMessage`: boolean to show HF status information. It shows days to the end of the contract of a HF assigned to a current user. Default false.
- `HomePage.enableCustomDashboard`: a boolean configuration flag that exposes the `home.HomePage.customDashboard` contribution key. This key allows overriding the default homepage to render a custom dashboard. **NOTE**: The custom page will not be rendered unless a component is provided with the `home.HomePage.customDashboard` contribution key.
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ export const DEFAULT = {
SHOW_HOME_MESSAGE: false,
HOME_MESSAGE_URL: "",
SHOW_HEALTH_FACILITY_MESSAGE: false,
ENABLE_CUSTOM_DASHBOARD: false,
};

export const DAYS_HF_STATUS = {
DAYS_LONG_TIME_ACTIVE: 180,
DAYS_MEDIUM_TIME_ACTIVE: 30,
};

export const MODULE_NAME = "home";
15 changes: 14 additions & 1 deletion src/pages/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { Contributions } from "@openimis/fe-core";
import React from "react";

import { Contributions, useModulesManager } from "@openimis/fe-core";
import { DEFAULT } from "../constants";

const HomePage = (props) => {
const modulesManager = useModulesManager();
const enableCustomDashboard = modulesManager.getConf(
"fe-home",
"HomePage.enableCustomDashboard",
DEFAULT.ENABLE_CUSTOM_DASHBOARD
);

if (enableCustomDashboard) {
return <Contributions contributionKey="home.HomePage.customDashboard" />;
}

return <Contributions contributionKey="home.HomePage.Container" {...props} />;
};

Expand Down

0 comments on commit 524a36d

Please sign in to comment.