Skip to content

Commit

Permalink
Merge branch 'master' into BAH-3843
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathy00 committed Jun 12, 2024
2 parents a23c4be + 937b03a commit 0b31ea3
Show file tree
Hide file tree
Showing 180 changed files with 7,377 additions and 1,241 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Use Ruby 2.5
- name: Use Ruby 3.1
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.5
ruby-version: 3.1
- run: npm install -g bower
- run: npm install -g grunt-cli
- run: gem install compass
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Validate PR

on:
pull_request:
pull_request:
branches: [ master ]

jobs:
Expand All @@ -13,10 +13,10 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Use Ruby 2.5
- name: Use Ruby 3.1
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.5
ruby-version: 3.1
- run: npm install -g bower
- run: npm install -g grunt-cli
- run: gem install compass
Expand Down
9 changes: 9 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ resource_name = IPD App
replace_edited_strings = false
keep_translations = false

[o:openmrs:p:bahmni:r:micro-frontend-app]
file_filter = micro-frontends/public/i18n/locale_<lang>.json
source_file = micro-frontends/public/i18n/locale_en.json
type = KEYVALUEJSON
minimum_perc = 0
resource_name = Micro Frontend App
replace_edited_strings = false
keep_translations = false

[o:openmrs:p:bahmni:r:orders-app]
file_filter = ui/app/i18n/orders/locale_<lang>.json
source_file = ui/app/i18n/orders/locale_en.json
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ These steps need to performed ONLY the FIRST TIME you set up this code.
4. Install Compass:
- Compass compiles SASS/SCSS into CSS.
- Requires ruby (It's recommended to install ruby also using rvm. See install [rvm with ruby](https://stackify.com/rvm-how-to-get-started-and-manage-your-ruby-installations/)).
- Ruby version: 2.6.6
- Ruby version: 3.1
- Once ruby is installed, you can install compass using: `gem install compass`

### Build commands
Expand Down
9 changes: 5 additions & 4 deletions micro-frontends/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
"@babel/core": "^7.15.5",
"@babel/plugin-transform-runtime": "^7.22.4",
"@babel/preset-env": "^7.22.4",
"bahmni-form-controls": "^0.93.12",
"@babel/preset-react": "^7.22.3",
"@testing-library/react": "12.1.5",
"axios": "1.4.0",
"babel-jest": "^29.5.0",
"babel-loader": "^9.1.2",
"bahmni-form-controls": "^0.93.12",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "5.2.6",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
Expand All @@ -29,13 +30,12 @@
"sass": "^1.63.4",
"sass-loader": "10.1.0",
"webpack": "^5.86.0",
"webpack-cli": "^5.1.4",
"copy-webpack-plugin": "^11.0.0"
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@carbon/icons-react": "^10.18.0",
"angular-component": "^0.1.3",
"bahmni-carbon-ui": "0.1.3",
"bahmni-carbon-ui": "0.1.6",
"carbon-components": "^10.19.0",
"carbon-components-react": "^7.25.0",
"classnames": "2.3.1",
Expand All @@ -52,6 +52,7 @@
},
"scripts": {
"build": "webpack --mode production",
"build:dev": "webpack --mode development",
"test": "jest",
"test:ci": "yarn test --ci --coverage",
"lint": "eslint src/**/*.{js,jsx}"
Expand Down
20 changes: 19 additions & 1 deletion micro-frontends/public/i18n/locale_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,23 @@
"SEARCH_REACTION": "Search Reaction",
"COMMON_REACTIONS": "Common Reactions",
"ALLERGEN": "Allergen",
"EDIT_FORM_ERROR_MESSAGE": "Please enter a value in the mandatory fields or correct the value in the highlighted fields to proceed"
"EDIT_FORM_ERROR_MESSAGE": "Please enter a value in the mandatory fields or correct the value in the highlighted fields to proceed",
"EMPTY_NOTES_ERROR": "Note cannot be empty",
"OT_NOTES": "Notes",
"FROM": "From",
"TO": "To",
"FROM_DATE_BEFORE_TO_DATE_ERROR": "From date should be before To date",
"DATE_OUT_OF_RANGE_ERROR": "Please select date within the valid range",
"DELETE_NOTE_TITLE": "Delete Note",
"YES_KEY": "Yes",
"NO_KEY": "No",
"DELETE_NOTE_MESSAGE": "Are you sure you want to delete this note?",
"NOTES_PLACEHOLDER": "Enter a maximum of 150 characters",
"UPDATE_NOTE_TITLE": "Update Note",
"ADD_NOTE_TITLE": "Add Note",
"LOADING": "Loading...",
"UPDATE": "Update",
"AKNOWLEDGE_BUTTON": "Acknowledge",
"AKNOWLEDGEMENT_REQUIRED_TEXT": "Acknowledgement required",
"NO_DRUGS_TO_BE_AKNOWLEDGED_TEXT": "You have no new drugs to be acknowledged"
}
25 changes: 25 additions & 0 deletions micro-frontends/src/ipd/CareViewDashboard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import PropTypes from "prop-types";
import React, { Suspense, lazy } from "react";
import Loader from "../next-ui/Components/Loader/Loader";

export function CareViewDashboard(props) {
const LazyApp = lazy(() => import("@openmrs-mf/ipd/CareViewDashboard"));

return (
<>
<Suspense fallback={<Loader />}>
<LazyApp hostData={props.hostData} hostApi={props.hostApi} />
</Suspense>
</>
);
}

// Without propTypes, react2angular won't render the component
CareViewDashboard.propTypes = {
hostData: PropTypes.shape({
patientId: PropTypes.string,
}).isRequired,
hostApi: PropTypes.shape({
onHome: PropTypes.func,
}).isRequired,
};
28 changes: 28 additions & 0 deletions micro-frontends/src/ipd/IpdDashboard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import PropTypes from "prop-types";
import React, { Suspense, lazy } from "react";
import Loader from "../next-ui/Components/Loader/Loader";

export function IpdDashboard(props) {
const LazyApp = lazy(() => import("@openmrs-mf/ipd/IpdDashboard"));

return (
<>
<Suspense fallback={<Loader />}>
<LazyApp
hostData={props.hostData}
hostApi={props.hostApi}
/>
</Suspense>
</>
);
}

// Without propTypes, react2angular won't render the component
IpdDashboard.propTypes = {
hostData: PropTypes.object.isRequired,
hostApi: PropTypes.shape({
navigation: PropTypes.shape({
visitSummary: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
};
34 changes: 34 additions & 0 deletions micro-frontends/src/ipd/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Adapt all IPD components to use within angular
"use strict";

import { react2angular } from "react2angular";
import { IpdDashboard } from "./IpdDashboard";
import { CareViewDashboard } from "./CareViewDashboard";

angular.module("bahmni.mfe.ipd", [
"ui.router",
"bahmni.common.config",
"bahmni.common.uiHelper",
"bahmni.common.i18n",
"bahmni.common.domain",
]);

/** MFE component 1: IpdDashboard
*================================================= */

angular
.module("bahmni.mfe.ipd")
.component("mfeIpdDashboard", react2angular(IpdDashboard), {
template:
'<mfe-ipd-dashboard host-data="hostData" host-api="hostApi"></mfe-ipd-dashboard>'
});

/** MFE component 2: CareViewDashboard
*================================================= */

angular
.module("bahmni.mfe.ipd")
.component("mfeIpdCareViewDashboard", react2angular(CareViewDashboard), {
template:
'<mfe-ipd-care-view-dashboard host-data="hostData" host-api="hostApi"></mfe-ipd-care-view-dashboard>'
});
35 changes: 35 additions & 0 deletions micro-frontends/src/next-ui/Components/Loader/Loader.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { FormattedMessage } from "react-intl";
import './Loader.scss';

const Loader = () => {
const loadingMessage = (
<FormattedMessage
id={"LOADING_MESSAGE"}
defaultMessage={"Loading... Please Wait"}
/>
);
return (
<div className="loader-container">
<div className="loader-content">
<div className="lds-spinner">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<p className="loader-text">{loadingMessage}</p>
</div>
</div>
);
};

export default Loader;
109 changes: 109 additions & 0 deletions micro-frontends/src/next-ui/Components/Loader/Loader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
.lds-spinner,
.lds-spinner div,
.lds-spinner div:after {
box-sizing: border-box;
}
.lds-spinner {
color: #719898;
display: inline-block;
position: relative;
width: 80px;
height: 80px;

div {
transform-origin: 40px 40px;
animation: lds-spinner 1.2s linear infinite;

&:after {
content: " ";
display: block;
position: absolute;
top: 3.2px;
left: 36.8px;
width: 6.4px;
height: 17.6px;
border-radius: 20%;
background: #719898;
}

&:nth-child(1) {
transform: rotate(0deg);
animation-delay: -1.1s;
}
&:nth-child(2) {
transform: rotate(30deg);
animation-delay: -1s;
}
&:nth-child(3) {
transform: rotate(60deg);
animation-delay: -0.9s;
}
&:nth-child(4) {
transform: rotate(90deg);
animation-delay: -0.8s;
}
&:nth-child(5) {
transform: rotate(120deg);
animation-delay: -0.7s;
}
&:nth-child(6) {
transform: rotate(150deg);
animation-delay: -0.6s;
}
&:nth-child(7) {
transform: rotate(180deg);
animation-delay: -0.5s;
}
&:nth-child(8) {
transform: rotate(210deg);
animation-delay: -0.4s;
}
&:nth-child(9) {
transform: rotate(240deg);
animation-delay: -0.3s;
}
&:nth-child(10) {
transform: rotate(270deg);
animation-delay: -0.2s;
}
&:nth-child(11) {
transform: rotate(300deg);
animation-delay: -0.1s;
}
&:nth-child(12) {
transform: rotate(330deg);
animation-delay: 0s;
}
}
}

@keyframes lds-spinner {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}

.loader-container {
font-family: "Arial";
display: flex;
align-items: center;
justify-content: center;
height: 80vh;
width: 100vw;
background-color: #fafafa;
}

.loader-content {
display: flex;
flex-direction: column;
align-items: center;
}

.loader-text {
font-size: 16px;
color: #333;
margin: 15px 0 0;
}
30 changes: 30 additions & 0 deletions micro-frontends/src/next-ui/Components/Loader/Loader.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { render } from '@testing-library/react';
import { IntlProvider } from 'react-intl';
import renderer from 'react-test-renderer';
import Loader from './Loader';

const messages = {
LOADING_MESSAGE: 'Loading... Please Wait'
};

describe('Loader Component', () => {
it('renders loader correctly', () => {
const { getAllByText } = render(
<IntlProvider locale="en" messages={messages}>
<Loader />
</IntlProvider>
);

expect(getAllByText("Loading... Please Wait").length).toEqual(1);
});

it('matches snapshot', () => {
const tree = renderer.create(
<IntlProvider locale="en" messages={messages}>
<Loader />
</IntlProvider>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
Loading

0 comments on commit 0b31ea3

Please sign in to comment.