Skip to content

Commit

Permalink
added hrms module
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunarora-eGov committed Mar 6, 2024
1 parent 7feb75f commit 4220810
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 29 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/mfe-hrms-ui-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: hrms ui service docker Image CI

on:
push:
branches: [ "mf-build-docker", "mf-stable" ]
branches: [ "mf-build-docker","mf-stable-common-module" ]
pull_request:
branches: [ "mf-build" ]

Expand All @@ -14,19 +14,36 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for tags and branches

- name: Set up environment variables
id: env
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "ACTION_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
echo "COMMIT_ID=${GITHUB_SHA: -8}" >> $GITHUB_ENV # Extract last 8 characters of SHA
- name: Build the Docker image
id: docker_build
working-directory: ./micro-ui/web/packages/hrms
run: docker build . --file docker/Dockerfile --tag egovio/hrms-ui:latest
run: |
IMAGE_TAG=egovio/hrms-ui:${{ env.BRANCH_NAME }}-${{ env.COMMIT_ID }}-${{ env.ACTION_NUMBER }}
docker build . \
--file docker/Dockerfile \
--tag $IMAGE_TAG
echo "::set-output name=image_name::$IMAGE_TAG"
- name: Login to Docker Hub and Push Docker Image
working-directory: ./micro-ui/web/packages/hrms
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME: ${{ steps.docker_build.outputs.image_name }}
run: |
# Authenticate with Docker Hub
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Push the image to Docker Hub
docker push egovio/hrms-ui:latest
docker push $IMAGE_NAME
echo "Docker image pushed: $IMAGE_NAME"
3 changes: 2 additions & 1 deletion micro-ui/web/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"packages/app1",
"packages/common",
"packages/pgr",
"packages/dss"
"packages/dss",
"packages/hrms"
],
"command": {
"run": {
Expand Down
3 changes: 2 additions & 1 deletion micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"packages/app1",
"packages/common",
"packages/pgr",
"packages/dss"
"packages/dss",
"packages/hrms"
],
"scripts": {
"build": "yarn lerna run build",
Expand Down
11 changes: 11 additions & 0 deletions micro-ui/web/packages/core/src/modules/registerRemotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export default (queryClient) => {
},
});

registerApplication({
name: "HRMS",
app: () => import("hrms/HRMSModule"),
activeWhen: `/${window.contextPath ? window.contextPath : "core-digit-ui"}/employee/hrms`,
customProps: {
title: "HRMS is running on host",
queryClient,
userType
},
});

start();
}

2 changes: 1 addition & 1 deletion micro-ui/web/packages/core/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = () => {
// auth: "auth@http://localhost:8082/remoteEntry.js",
// header: "header@http://localhost:8083/remoteEntry.js",
// dashboard: "dashboard@http://localhost:8084/remoteEntry.js",
// hrms: "hrms@https://localhost:8085/remoteEntry.js",
hrms: "hrms@https://localhost:8085/remoteEntry.js",
workbench: "workbench@https://localhost:8086/remoteEntry.js",
common:"common@https://localhost:8090/remoteEntry.js",
pgr:"pgr@https://localhost:8087/remoteEntry.js",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/packages/core/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = () => {
// auth: `auth@${domain}/auth/remoteEntry.js`,
// header: `header@${domain}/header/remoteEntry.js`,
// dashboard: `dashboard@${domain}/dashboard/remoteEntry.js`,
// hrms: `hrms@${domain}/hrms/remoteEntry.js`,
hrms: `hrms@${domain}/hrms-ui/remoteEntry.js`,
common: `common@${domain}/common-ui/remoteEntry.js`,
pgr: `pgr@${domain}/pgr-ui/remoteEntry.js`,
workbench : `workbench@${domain}/workbench-mfe/remoteEntry.js`,
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/packages/hrms/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ server
{
root /var/web;
index index.html index.htm;
try_files $uri $uri/ /core/index.html;
try_files $uri $uri/ /hrms-ui/index.html;
}
}
5 changes: 3 additions & 2 deletions micro-ui/web/packages/hrms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
"@babel/preset-env":"7.23.9"
},
"dependencies": {
"single-spa-react": "^4.6.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-router-dom": "5.2.0",
"rxjs": "6.6.3",
"@digit-ui/digit-ui-libraries-mfe": "1.0.7",
"@egovernments/digit-ui-react-components":"1.4.107",
"@digit-ui/digit-ui-libraries-mfe": "1.0.6",
"@egovernments/digit-ui-react-components":"1.4.106",
"@digit-ui/digit-ui-module-core-base":"1.0.8",
"react-hook-form": "6.15.8",
"react-i18next": "11.16.2",
Expand Down
1 change: 0 additions & 1 deletion micro-ui/web/packages/hrms/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>Hrms Page</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<script src="https://s3.ap-south-1.amazonaws.com/egov-dev-assets/globalConfigsWorkbench.js"></script>

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link
Expand Down
19 changes: 19 additions & 0 deletions micro-ui/web/packages/hrms/src/HRMSWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { QueryClientProvider } from 'react-query';
import { Switch, useLocation, BrowserRouter as Router } from 'react-router-dom';
import { initHRMSComponents } from './Module';
import EmployeeApp from './pages';

const App = ({ queryClient, title }) => {
initHRMSComponents();

return (
<QueryClientProvider client={queryClient}>
<Router>
<EmployeeApp path={`/${window.contextPath ? window.contextPath : "core-digit-ui"}/employee/hrms/`} />
</Router>
</QueryClientProvider>
);
};

export default App;
25 changes: 25 additions & 0 deletions micro-ui/web/packages/hrms/src/SingleSpaEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import ReactDOM from "react-dom";
import singleSpaReact from "single-spa-react";
import App from "./HRMSWrapper";
const appLifeCycles = singleSpaReact({
React,
ReactDOM,
rootComponent: App,
errorBoundary() {
// https://reactjs.org/docs/error-boundaries.html
return <div>This renders when a catastrophic error occurs</div>;
},
});

export function bootstrap(props) {
return appLifeCycles.bootstrap(props);
}

export function mount(props) {
return appLifeCycles.mount(props);
}

export function unmount(props) {
return appLifeCycles.unmount(props);
}
6 changes: 3 additions & 3 deletions micro-ui/web/packages/hrms/src/components/InboxFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Filter = ({ searchParams, onFilterChange, onSearch, removeParam, ...props
)[0];
});
const { isLoading, isError, errors, data: data, ...rest } = Digit.Hooks.hrms.useHrmsMDMS(
tenantId ? tenantId.code : searchParams?.tenantId,
tenantId ? tenantId?.code : searchParams?.tenantId,
"egov-hrms",
"HRMSRolesandDesignation"
);
Expand All @@ -54,8 +54,8 @@ const Filter = ({ searchParams, onFilterChange, onSearch, removeParam, ...props
});

useEffect(() => {
if (tenantId.code) {
setSearchParams({ ..._searchParams, tenantId: tenantId.code });
if (tenantId?.code) {
setSearchParams({ ..._searchParams, tenantId: tenantId?.code });
}
}, [tenantId]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
const [focusIndex, setFocusIndex] = useState(-1);

function gethierarchylistdata() {
return data?.MdmsRes?.["egov-location"]["TenantBoundary"].map((ele) => ele.hierarchyType);
return data?.MdmsRes?.["egov-location"]["TenantBoundary"]?.map((ele) => ele.hierarchyType);
}

function getboundarydata() {
Expand Down Expand Up @@ -173,8 +173,7 @@ function Jurisdiction({
const [Boundary, selectboundary] = useState([]);
useEffect(() => {
selectBoundaryType(
data?.MdmsRes?.["egov-location"]["TenantBoundary"]
.filter((ele) => {
data?.MdmsRes?.["egov-location"]["TenantBoundary"]?.filter((ele) => {
return ele?.hierarchyType?.code == jurisdiction?.hierarchy?.code;
})
.map((item) => { return { ...item.boundary, i18text: Digit.Utils.locale.convertToLocale(item.boundary.label, 'EGOV_LOCATION_BOUNDARYTYPE') } })
Expand Down
8 changes: 4 additions & 4 deletions micro-ui/web/packages/hrms/src/pages/Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Response = (props) => {
const [mutationHappened, setMutationHappened, clear] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_HAPPENED", false);
const [successData, setsuccessData, clearSuccessData] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_SUCCESS_DATA", false);
const [errorInfo, setErrorInfo, clearError] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_ERROR_DATA", false);
const mutation = state.key === "UPDATE" ? Digit.Hooks.hrms.useHRMSUpdate(tenantId) : Digit.Hooks.hrms.useHRMSCreate(tenantId);
const mutation = state?.key === "UPDATE" ? Digit.Hooks.hrms.useHRMSUpdate(tenantId) : Digit.Hooks.hrms.useHRMSCreate(tenantId);

const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {});
const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession;
Expand All @@ -63,7 +63,7 @@ const Response = (props) => {
setMutationHappened(true);
};
if (!mutationHappened ) {
if (state.key === "UPDATE") {
if (state?.key === "UPDATE") {
mutation.mutate(
{
Employees: state.Employees,
Expand Down Expand Up @@ -97,12 +97,12 @@ const Response = (props) => {
<BannerPicker
t={t}
data={mutation?.data|| successData}
action={state.action}
action={state?.action}
isSuccess={!successData ? mutation?.isSuccess : true}
isLoading={(mutation.isIdle && !mutationHappened) || mutation?.isLoading}
isEmployee={props.parentRoute.includes("employee")}
/>
<CardText>{t(DisplayText(state.action, mutation.isSuccess || !!successData, props.parentRoute.includes("employee"), t), t)}</CardText>
<CardText>{t(DisplayText(state?.action, mutation.isSuccess || !!successData, props.parentRoute.includes("employee"), t), t)}</CardText>

<ActionBar>
<Link to={`${props.parentRoute.includes("employee") ? `/${window?.contextPath}/employee` : `/${window?.contextPath}/citizen`}`}>
Expand Down
8 changes: 5 additions & 3 deletions micro-ui/web/packages/hrms/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PrivateRoute } from "@egovernments/digit-ui-react-components";
import React,{ useEffect } from "react";
import { useTranslation } from "react-i18next";
import { Link, Switch, useLocation } from "react-router-dom";
import { Link, Switch, useLocation, BrowserRouter as Router } from "react-router-dom";
import { SVG } from "@egovernments/digit-ui-react-components";

const {SixFtApart,Rotate360}=SVG;
Expand Down Expand Up @@ -33,8 +33,9 @@ const EmployeeApp = ({ path, url, userType }) => {
},[location]);

return (
<Switch>
<React.Fragment>
<Router>
<Switch>
<div className="ground-container">
<p className="breadcrumb" style={{ marginLeft: mobileView ? "1vw" : "0px" }}>
<Link to= {`/${window?.contextPath}/employee`} style={{ cursor: "pointer", color: "#666" }}>
Expand All @@ -53,8 +54,9 @@ const EmployeeApp = ({ path, url, userType }) => {
<PrivateRoute path={`${path}/details/:tenantId/:id`} component={() => <HRMSDetails />} />
<PrivateRoute path={`${path}/edit/:tenantId/:id`} component={() => <EditEmpolyee />} />
</div>
</Switch>
</Router>
</React.Fragment>
</Switch>
);
};

Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/packages/hrms/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = () => {
name: "hrms",
filename: "remoteEntry.js",
exposes: {
"./HrmsModule": "./src/bootstrap",
"./HRMSModule": "./src/SingleSpaEntry",
},
shared: packageJson.dependencies,
}),
Expand Down
6 changes: 3 additions & 3 deletions micro-ui/web/packages/hrms/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ module.exports = () => {
},
plugins: [
new ModuleFederationPlugin({
name: "hrms-ui",
name: "hrms",
filename: "remoteEntry.js",
exposes: {
"./HrmsModule": "./src/bootstrap",
"./HRMSModule": "./src/SingleSpaEntry",
},
shared: packageJson.dependencies, //removed the shared logic for now will be enabled later for optimization
// shared: packageJson.dependencies, //removed the shared logic for now will be enabled later for optimization
}),
],
};
Expand Down

0 comments on commit 4220810

Please sign in to comment.