From 50641c714b1f091dc7cbbc4e34e3fcd837e6f08e Mon Sep 17 00:00:00 2001
From: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Date: Thu, 9 Jan 2025 15:13:50 +0530
Subject: [PATCH] FEATURE/HCMPRE-1852 :: Consolidated Common UI (#2120)
* added change for common
* Updated the readme content
* revert
* added build configs
* Update buildCommonConsole.yml
* Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---
.github/workflows/buildCommonConsole.yml | 93 +++++++++++++++++++
health/micro-ui/web/console/App.js | 72 ++++++++++++++
health/micro-ui/web/console/Dockerfile | 30 ++++++
health/micro-ui/web/console/install-deps.sh | 18 ++++
.../micro-ui/web/console/inter-package.json | 58 ++++++++++++
health/micro-ui/web/console/nginx.conf | 12 +++
health/micro-ui/web/console/package.json | 93 +++++++++++++++++++
health/micro-ui/web/console/webpack.config.js | 52 +++++++++++
.../micro-ui-internals/packages/css/README.md | 26 ++++--
.../modules/campaign-manager/README.md | 37 ++++----
10 files changed, 465 insertions(+), 26 deletions(-)
create mode 100644 .github/workflows/buildCommonConsole.yml
create mode 100644 health/micro-ui/web/console/App.js
create mode 100644 health/micro-ui/web/console/Dockerfile
create mode 100644 health/micro-ui/web/console/install-deps.sh
create mode 100644 health/micro-ui/web/console/inter-package.json
create mode 100644 health/micro-ui/web/console/nginx.conf
create mode 100644 health/micro-ui/web/console/package.json
create mode 100644 health/micro-ui/web/console/webpack.config.js
diff --git a/.github/workflows/buildCommonConsole.yml b/.github/workflows/buildCommonConsole.yml
new file mode 100644
index 00000000000..49124293938
--- /dev/null
+++ b/.github/workflows/buildCommonConsole.yml
@@ -0,0 +1,93 @@
+name: Blank Common Console Workflow
+on:
+ push:
+ branches: ['*'] # Trigger on any branch
+ paths:
+ - 'health/micro-ui/web/console/**'
+ workflow_dispatch: # Enable manual triggering with inputs
+ inputs:
+ folder_name:
+ description: 'Specify the folder for Docker build (default: console)'
+ required: false
+ default: 'console'
+
+jobs:
+ docker_image-build:
+ outputs:
+ run_job_digit_ui: ${{ steps.check_files.outputs.run_job_digit_ui }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 2
+
+ - name: Setup Docker
+ uses: docker/setup-buildx-action@v1
+
+ - name: Check modified files
+ id: check_files
+ run: |
+ echo "=============== List modified files ==============="
+ git diff --name-only HEAD^ HEAD
+
+ echo "========== Check paths of modified files =========="
+ git diff --name-only HEAD^ HEAD > files.txt
+ run_job_digit_ui=false
+ while IFS= read -r file
+ do
+ if [[ $file == health/micro-ui/* ]]; then
+ echo "This modified file is under the 'digit_ui' folder."
+ run_job_digit_ui=true
+ fi
+ done < files.txt
+
+ # Set the output based on whether the job should run
+ echo "::set-output name=run_job_digit_ui::$run_job_digit_ui"
+ echo "ACTION_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
+ echo "COMMIT_ID=${GITHUB_SHA: -8}" >> $GITHUB_ENV # Extract last 8 characters of SHA
+ echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
+
+ - name: Login to egovio Docker Container Registry
+ env:
+ DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
+ DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
+ run: |
+ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
+
+ - name: Build and Push Docker images for digit-ui
+ if: ${{ steps.check_files.outputs.run_job_digit_ui == 'true' }}
+ run: |
+ # Use input folder name or default
+ DOCKER_IMAGE_VARIANT=${{ github.event.inputs.folder_name || 'console' }}
+ echo "Original folder for Docker build: $DOCKER_IMAGE_VARIANT"
+
+ # Remove '-ui' if it exists in the folder name
+ SANITIZED_FOLDER=${ORIGINAL_FOLDER//-ui/}
+ echo "Sanitized folder for Docker build: $SANITIZED_FOLDER"
+
+ IMAGE_NAME_1=$DOCKER_IMAGE_VARIANT:${{ env.BRANCH_NAME }}-${{ env.COMMIT_ID }}-${{ env.ACTION_NUMBER }}
+ docker build -t $IMAGE_NAME_1 -f $SANITIZED_FOLDER/dockerfile . &
+
+ # Wait for the build to complete
+ wait
+
+ # Tag and push Docker image
+ docker tag $IMAGE_NAME_1 egovio/$IMAGE_NAME_1
+ docker push egovio/$IMAGE_NAME_1
+
+ # Set outputs for the summary
+ echo "IMAGE_NAME_1=egovio/$IMAGE_NAME_1" >> $GITHUB_ENV
+ working-directory: health/micro-ui
+
+ - name: Display Docker images in Actions tab
+ if: ${{ steps.check_files.outputs.run_job_digit_ui == 'true' }}
+ run: |
+ echo "First Docker image: ${{ env.IMAGE_NAME_1 }}"
+ echo "::set-output name=first_image::$IMAGE_NAME_1"
+
+ - name: Show Docker images in job summary
+ if: ${{ steps.check_files.outputs.run_job_digit_ui == 'true' }}
+ run: |
+ echo "## Docker images built and pushed:" >> $GITHUB_STEP_SUMMARY
+ echo "- ${{ env.IMAGE_NAME_1 }}" >> $GITHUB_STEP_SUMMARY
diff --git a/health/micro-ui/web/console/App.js b/health/micro-ui/web/console/App.js
new file mode 100644
index 00000000000..93b15440c5e
--- /dev/null
+++ b/health/micro-ui/web/console/App.js
@@ -0,0 +1,72 @@
+/**
+ * The above code initializes various Digit UI modules and components, sets up customizations, and
+ * renders the DigitUI component based on the enabled modules and state code.
+ * @returns The `App` component is being returned, which renders the `DigitUI` component with the
+ * specified props such as `stateCode`, `enabledModules`, `moduleReducers`, and `defaultLanding`. The
+ * `DigitUI` component is responsible for rendering the UI based on the provided configuration and
+ * modules.
+ */
+import React from "react";
+import { initLibraries } from "@egovernments/digit-ui-libraries";
+import { DigitUI } from "@egovernments/digit-ui-module-core";
+// import { initHRMSComponents } from "@egovernments/digit-ui-module-hrms";
+import { UICustomizations } from "./Customisations/UICustomizations";
+import { initWorkbenchComponents } from "@egovernments/digit-ui-module-workbench";
+import { initUtilitiesComponents } from "@egovernments/digit-ui-module-utilities";
+import { initWorkbenchHCMComponents } from "@egovernments/digit-ui-module-hcmworkbench";
+import { initCampaignComponents } from "@egovernments/digit-ui-module-campaign-manager"
+
+window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");
+
+const enabledModules = [
+ "DSS",
+ "NDSS",
+ "Utilities",
+ // "HRMS",
+ "Engagement",
+ "Workbench",
+ "HCMWORKBENCH",
+ "Campaign"
+];
+
+const moduleReducers = (initData) => ({
+ initData,
+});
+
+const initDigitUI = () => {
+ window.Digit.ComponentRegistryService.setupRegistry({});
+ window.Digit.Customizations = {
+ PGR: {},
+ commonUiConfig: UICustomizations,
+ };
+ // initHRMSComponents();
+ initUtilitiesComponents();
+ initWorkbenchComponents();
+ initWorkbenchHCMComponents();
+ initCampaignComponents();
+
+};
+
+initLibraries().then(() => {
+ initDigitUI();
+});
+
+function App() {
+ window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");
+ const stateCode =
+ window.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID") ||
+ process.env.REACT_APP_STATE_LEVEL_TENANT_ID;
+ if (!stateCode) {
+ return
stateCode is not defined
;
+ }
+ return (
+
+ );
+}
+
+export default App;
diff --git a/health/micro-ui/web/console/Dockerfile b/health/micro-ui/web/console/Dockerfile
new file mode 100644
index 00000000000..66882ccfc6a
--- /dev/null
+++ b/health/micro-ui/web/console/Dockerfile
@@ -0,0 +1,30 @@
+FROM egovio/alpine-node-builder-14:yarn AS build
+#FROM ghcr.io/egovernments/alpine-node-builder-14:yarn AS build
+RUN apk update && apk upgrade
+RUN apk add --no-cache git>2.30.0
+ARG WORK_DIR
+WORKDIR /app
+ENV NODE_OPTIONS "--max-old-space-size=4792"
+
+COPY ${WORK_DIR} .
+RUN ls -lah
+
+#RUN node web/envs.js
+RUN cd web/ \
+ && node -e 'console.log(v8.getHeapStatistics().heap_size_limit/(1024*1024))' \
+ && node -e 'console.log("health-console only")' \
+ && cd console/ \
+ && chmod +x ./install-deps.sh \
+ && ./install-deps.sh \
+ && cd ../ \
+ && yarn install \
+ && yarn build:webpack
+
+FROM nginx:mainline-alpine
+#FROM ghcr.io/egovernments/nginx:mainline-alpine
+ENV WORK_DIR=/var/web/console
+
+RUN mkdir -p ${WORK_DIR}
+
+COPY --from=build /app/web/build ${WORK_DIR}/
+COPY --from=build /app/web/console/nginx.conf /etc/nginx/conf.d/default.conf
diff --git a/health/micro-ui/web/console/install-deps.sh b/health/micro-ui/web/console/install-deps.sh
new file mode 100644
index 00000000000..ef0b29ed8f3
--- /dev/null
+++ b/health/micro-ui/web/console/install-deps.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+BRANCH="$(git branch --show-current)"
+
+echo "Main Branch: $BRANCH"
+
+INTERNALS="micro-ui-internals"
+cd ..
+
+cp console/App.js src
+cp console/package.json package.json
+cp console/webpack.config.js webpack.config.js
+cp console/inter-package.json $INTERNALS/package.json
+
+cp $INTERNALS/example/src/UICustomizations.js src/Customisations
+
+echo "UI :: console " && echo "Branch: $(git branch --show-current)" && echo "$(git log -1 --pretty=%B)" && echo "installing packages"
+
diff --git a/health/micro-ui/web/console/inter-package.json b/health/micro-ui/web/console/inter-package.json
new file mode 100644
index 00000000000..c08ae51ada8
--- /dev/null
+++ b/health/micro-ui/web/console/inter-package.json
@@ -0,0 +1,58 @@
+{
+ "name": "egovernments",
+ "version": "1.0.0",
+ "main": "index.js",
+ "workspaces": [
+ "packages/modules/campaign-manager"
+ ],
+ "author": "JaganKumar ",
+ "license": "MIT",
+ "private": true,
+ "engines": {
+ "node": ">=14"
+ },
+ "scripts": {
+ "start": "SKIP_PREFLIGHT_CHECK=true run-s build start:dev",
+ "sprint": "SKIP_PREFLIGHT_CHECK=true run-s start:script",
+ "start:dev": "run-p dev:**",
+ "start:script": "./scripts/create.sh",
+ "dev:css": "cd packages/css && yarn start",
+ "publish:css": "cd packages/css && yarn publish --access public",
+ "dev:example": "cd example && yarn start",
+ "dev:campaign": "cd packages/modules/campaign-manager && yarn start",
+ "build": "run-p build:**",
+ "build:campaign": "cd packages/modules/campaign-manager && yarn build",
+ "deploy:jenkins": "./scripts/jenkins.sh",
+ "clean": "rm -rf node_modules"
+ },
+ "resolutions": {
+ "**/@babel/runtime": "7.20.1",
+ "**/@babel/traverse":"7.25.9",
+ "**/babel-preset-react-app": "10.0.0",
+ "**/@jridgewell/gen-mapping": "0.3.5",
+ "**/ajv": "8.11.2",
+ "fast-uri":"2.1.0"
+ },
+ "devDependencies": {
+ "husky": "7.0.4",
+ "lint-staged": "12.3.7",
+ "npm-run-all": "4.1.5",
+ "prettier": "2.1.2"
+ },
+ "husky": {},
+ "lint-staged": {
+ "*.{js,css,md}": "prettier --write"
+ },
+ "dependencies": {
+ "lodash": "4.17.21",
+ "microbundle-crl": "0.13.11",
+ "@egovernments/digit-ui-react-components": "1.8.2-beta.18",
+ "@egovernments/digit-ui-components": "0.0.2-beta.1",
+ "react": "17.0.2",
+ "react-dom": "17.0.2",
+ "react-hook-form": "6.15.8",
+ "react-i18next": "11.16.2",
+ "react-query": "3.6.1",
+ "react-router-dom": "5.3.0"
+ }
+}
diff --git a/health/micro-ui/web/console/nginx.conf b/health/micro-ui/web/console/nginx.conf
new file mode 100644
index 00000000000..41e78a4c09b
--- /dev/null
+++ b/health/micro-ui/web/console/nginx.conf
@@ -0,0 +1,12 @@
+server
+{
+ listen 80;
+ underscores_in_headers on;
+
+ location /console
+ {
+ root /var/web;
+ index index.html index.htm;
+ try_files $uri $uri/ /console/index.html;
+ }
+}
\ No newline at end of file
diff --git a/health/micro-ui/web/console/package.json b/health/micro-ui/web/console/package.json
new file mode 100644
index 00000000000..d18039f5a47
--- /dev/null
+++ b/health/micro-ui/web/console/package.json
@@ -0,0 +1,93 @@
+{
+ "name": "micro-ui",
+ "version": "1.0.0",
+ "author": "Jagankumar ",
+ "license": "MIT",
+ "private": true,
+ "engines": {
+ "node": ">=14"
+ },
+ "workspaces": [
+ "micro-ui-internals/packages/modules/campaign-manager"
+ ],
+ "homepage": "/console",
+ "dependencies": {
+ "@egovernments/digit-ui-libraries": "1.8.6",
+ "@egovernments/digit-ui-module-workbench": "1.0.11",
+ "@egovernments/digit-ui-module-core": "1.8.14",
+ "@egovernments/digit-ui-module-utilities": "1.0.10",
+ "@egovernments/digit-ui-components": "0.0.2-beta.58",
+ "@egovernments/digit-ui-react-components": "1.8.12",
+ "@egovernments/digit-ui-module-hcmworkbench":"0.1.0",
+ "@egovernments/digit-ui-module-campaign-manager": "0.3.0",
+ "react": "17.0.2",
+ "react-dom": "17.0.2",
+ "jsonpath": "^1.1.1",
+ "react-router-dom": "5.3.0",
+ "react-scripts": "4.0.1",
+ "web-vitals": "1.1.2",
+ "terser-brunch": "^4.1.0",
+ "react-hook-form": "6.15.8",
+ "react-i18next": "11.16.2",
+ "react-query": "3.6.1"
+ },
+ "devDependencies": {
+ "@babel/plugin-proposal-private-property-in-object": "7.21.0",
+ "http-proxy-middleware": "1.3.1",
+ "lodash": "4.17.21",
+ "microbundle-crl": "0.13.11",
+ "react": "17.0.2",
+ "react-dom": "17.0.2",
+ "react-hook-form": "6.15.8",
+ "react-i18next": "11.16.2",
+ "react-query": "3.6.1",
+ "react-router-dom": "5.3.0",
+ "husky": "7.0.4",
+ "lint-staged": "12.3.7",
+ "npm-run-all": "4.1.5",
+ "prettier": "2.1.2",
+ "file-loader": "6.2.0",
+ "css-loader": "5.2.6",
+ "style-loader": "2.0.0",
+ "babel-loader": "8.1.0",
+ "webpack-cli": "4.10.0",
+ "clean-webpack-plugin": "4.0.0"
+ },
+ "resolutions": {
+ "**/babel-loader": "8.2.2",
+ "**/@babel/core": "7.14.0",
+ "**/@babel/traverse": "7.25.9",
+ "**/@babel/preset-env": "7.14.0",
+ "**/styled-components": "5.0.0",
+ "**/@babel/plugin-transform-modules-commonjs": "7.14.0",
+ "**/@jridgewell/gen-mapping": "0.3.5",
+ "**/polished": "4.2.2",
+ "fast-uri": "2.1.0"
+ },
+ "scripts": {
+ "start": "react-scripts start",
+ "build": "GENERATE_SOURCEMAP=false SKIP_PREFLIGHT_CHECK=true react-scripts build",
+ "build:prepare": "./build.sh",
+ "build:libraries": "cd micro-ui-internals && yarn build",
+ "build:prod": "webpack --mode production",
+ "build:webpack": "yarn build:libraries &&cd .. && ls && cd ./web && ls && yarn build:prod",
+ "clean": "rm -rf node_modules"
+ },
+ "eslintConfig": {
+ "extends": [
+ "react-app"
+ ]
+ },
+ "browserslist": {
+ "production": [
+ ">0.2%",
+ "not dead",
+ "not op_mini all"
+ ],
+ "development": [
+ "last 1 chrome version",
+ "last 1 firefox version",
+ "last 1 safari version"
+ ]
+ }
+}
diff --git a/health/micro-ui/web/console/webpack.config.js b/health/micro-ui/web/console/webpack.config.js
new file mode 100644
index 00000000000..836d8cb1074
--- /dev/null
+++ b/health/micro-ui/web/console/webpack.config.js
@@ -0,0 +1,52 @@
+const path = require("path");
+const HtmlWebpackPlugin = require("html-webpack-plugin");
+const { CleanWebpackPlugin } = require("clean-webpack-plugin");
+// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
+
+module.exports = {
+ // mode: 'development',
+ entry: "./src/index.js",
+ devtool: "none",
+ module: {
+ rules: [
+ {
+ test: /\.(js)$/,
+ exclude: /node_modules/,
+ use: ["babel-loader"],
+ },
+ {
+ test: /\.css$/i,
+ use: ["style-loader", "css-loader"],
+ },
+ {
+ test: /\.(png|jpe?g|gif)$/i,
+ use: [
+ {
+ loader: 'file-loader',
+ },
+ ],
+ },
+ ],
+ },
+ output: {
+ filename: "[name].bundle.js",
+ path: path.resolve(__dirname, "build"),
+ publicPath: "/console/",
+ },
+ optimization: {
+ splitChunks: {
+ chunks: 'all',
+ minSize:20000,
+ maxSize:50000,
+ enforceSizeThreshold:50000,
+ minChunks:1,
+ maxAsyncRequests:30,
+ maxInitialRequests:30
+ },
+ },
+ plugins: [
+ new CleanWebpackPlugin(),
+ // new BundleAnalyzerPlugin(),
+ new HtmlWebpackPlugin({ inject: true, template: "public/index.html" }),
+ ],
+};
\ No newline at end of file
diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/README.md b/health/micro-ui/web/micro-ui-internals/packages/css/README.md
index cc15f43eea8..553d7173980 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/css/README.md
+++ b/health/micro-ui/web/micro-ui-internals/packages/css/README.md
@@ -34,22 +34,28 @@ frontend/micro-ui/web/public/index.html
```jsx
/** add this import **/
-
+
```
-### Changelog
-```bash
-## 0.3.0 - 2024-12-03
-#### Base Admin console & microplan web
-## 0.1.0
-#### Base version
+## List of features available in this package were as follows
-```
-## Contributors
+1. Campaign Management
+2. Checklist Management
+3. Boundary Management
+4. Microplanning
+5. Campaign Settings
+
+
+### Contributors
-[jagankumar-egov] [nipunarora-eGov] [nabeelmd-eGov] [Bhavya-eGov]
+- [jagankumar-egov](https://github.com/jagankumar-egov)
+- [nabeelmd-egov](https://github.com/nabeelmd-egov)
+- [Bhavya-egov](https://github.com/Bhavya-egov)
+- [nipunarora-eGov](https://github.com/nipunarora-eGov)
+- [Swathi-egov](https://github.com/Swathi-egov)
+- [suryansh-egov](https://github.com/suryansh-egov)
### Published from DIGIT Frontend
DIGIT Frontend Repo (https://github.com/egovernments/Digit-Frontend/tree/console)
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/README.md b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/README.md
index 2610a0cf20d..8a6d31bce90 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/README.md
+++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/README.md
@@ -1,4 +1,4 @@
-# digit-ui-module-workbench
+# digit-ui-module-campaign-manager
## Install
@@ -21,7 +21,7 @@ frontend/micro-ui/web/package.json
```
```json
-"@egovernments/digit-ui-module-campaign-manager" :"0.2.0",
+"@egovernments/digit-ui-module-campaign-manager" :"0.3.0",
```
then navigate to App.js
@@ -46,33 +46,37 @@ const initDigitUI = () => {
};
```
-## List of features available in this versions were as follows
-1 . Update Date change
- > -Provides a screen to change the campaign and cycle start date and end date.
- > -Date can be change within boundary level or project level based on the MDMS config
+## List of features available in this package were as follows
+1. Helps in creating the Campaign and configure delivery rules
+ Supported Campaigns Bednet, SMC, IRS & Codelivery
-2 . View Timeline
+2. Create Data: Validates and creates resource details of type facility,user and boundary.
+
+3. Update Date
+ > -Provides a screen to change the campaign and cycle start and end dates.
+ > -Dates can be changed within boundary level or project level based on the MDMS config
+
+
+4. View Timeline
> -Provides a feature to show the campaign current status in summary screen
> -Provides a Dropdown if it has any referenced master
-3 . Action column.
- > - Added Action column in my campaign screen to perform actions
+5. Updating the campaign details
+6. Configure Checklist
+
+7. Manage Boundaries
-### Changelog
-```bash
-0.2.0 Feature added for Campaign Date change, View timeline
-0.0.1 base version
-```
### Contributors
- [jagankumar-egov](https://github.com/jagankumar-egov)
- [nabeelmd-egov](https://github.com/nabeelmd-egov)
-
+- [Bhavya-egov](https://github.com/Bhavya-egov)
+- [suryansh-egov](https://github.com/suryansh-egov)
## License
@@ -81,7 +85,8 @@ const initDigitUI = () => {
## Documentation
Documentation Site (https://core.digit.org/guides/developer-guide/ui-developer-guide/digit-ui)
-Workbench Documentation(https://workbench.digit.org/platform/functional-specifications/workbench-ui)
+
+[Campaign Module Documentation](https://docs.digit.org/health/0.3/setup/configuration)
## Maintainer