Skip to content

Commit 04bcb3e

Browse files
authored
Decouple fhir envs (#1183)
* Enable fhir modules without needing corresponding old module envs * Update docker documentation * Team assignment mdoule env is not composite * Update tests * Move composite envs to settings.
1 parent 8e4cbfa commit 04bcb3e

File tree

9 files changed

+545
-193
lines changed

9 files changed

+545
-193
lines changed

app/src/configs/__mocks__/settings.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const COMPOSITE_ENABLE_USER_MANAGEMENT = true;
2+
export const COMPOSITE_ENABLE_TEAM_MANAGEMENT = true;
3+
export const COMPOSITE_ENABLE_LOCATIONS_MANAGEMENT = true;

app/src/configs/settings.ts

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import {
88
OPENSRP_OAUTH_STATE,
99
OPENSRP_USER_URL,
1010
OPENSRP_OAUTH_SCOPES,
11+
ENABLE_USER_MANAGEMENT,
12+
ENABLE_FHIR_USER_MANAGEMENT,
13+
ENABLE_TEAMS,
14+
ENABLE_FHIR_TEAMS,
15+
ENABLE_FHIR_LOCATIONS,
16+
ENABLE_LOCATIONS,
1117
} from './env';
1218

1319
/** Authentication Configs */
@@ -25,3 +31,8 @@ if (ENABLE_OPENSRP_OAUTH) {
2531
}
2632

2733
export { providers };
34+
35+
export const COMPOSITE_ENABLE_USER_MANAGEMENT =
36+
ENABLE_USER_MANAGEMENT || ENABLE_FHIR_USER_MANAGEMENT;
37+
export const COMPOSITE_ENABLE_TEAM_MANAGEMENT = ENABLE_TEAMS || ENABLE_FHIR_TEAMS;
38+
export const COMPOSITE_ENABLE_LOCATIONS_MANAGEMENT = ENABLE_LOCATIONS || ENABLE_FHIR_LOCATIONS;

app/src/containers/ConnectedSidebar/tests/index.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { act } from 'react-dom/test-utils';
99
import { getActiveKey } from '../../../components/page/Sidebar/utils';
1010
import toJson from 'enzyme-to-json';
1111
import { Route } from '../../../routes';
12+
1213
jest.mock('../../../configs/env');
14+
jest.mock('../../../configs/settings');
1315

1416
describe('components/ConnectedSidebar', () => {
1517
it('renders the ConnectedSidebar component', () => {

app/src/containers/pages/Home/Home.tsx

+10-24
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
import * as React from 'react';
21
import { Helmet } from 'react-helmet';
32
import { Col, Row, Button } from 'antd';
43
import { Link } from 'react-router-dom';
54
import './Home.css';
65
import { useTranslation } from '../../../mls';
6+
import { URL_USER, URL_LOCATION_UNIT, URL_TEAM_ASSIGNMENT, URL_TEAMS } from '../../../constants';
7+
import { ENABLE_TEAMS_ASSIGNMENT_MODULE } from '../../../configs/env';
8+
import React from 'react';
79
import {
8-
URL_USER,
9-
URL_LOCATION_UNIT,
10-
URL_LOCATION_UNIT_GROUP,
11-
URL_TEAM_ASSIGNMENT,
12-
URL_TEAMS,
13-
} from '../../../constants';
14-
import {
15-
ENABLE_LOCATIONS,
16-
ENABLE_TEAMS,
17-
ENABLE_TEAMS_ASSIGNMENT_MODULE,
18-
ENABLE_USER_MANAGEMENT,
19-
} from '../../../configs/env';
10+
COMPOSITE_ENABLE_LOCATIONS_MANAGEMENT,
11+
COMPOSITE_ENABLE_TEAM_MANAGEMENT,
12+
COMPOSITE_ENABLE_USER_MANAGEMENT,
13+
} from '../../../configs/settings';
2014

2115
export const Home = () => {
2216
const { t } = useTranslation();
@@ -32,7 +26,7 @@ export const Home = () => {
3226
</Col>
3327
</Row>
3428
<Row gutter={16} className="links-box">
35-
{ENABLE_USER_MANAGEMENT && (
29+
{COMPOSITE_ENABLE_USER_MANAGEMENT && (
3630
<Col className="gutter-row" span={12}>
3731
<Link to={URL_USER} className="admin-link">
3832
<Button color="outline" className="btn-links">
@@ -41,7 +35,7 @@ export const Home = () => {
4135
</Link>
4236
</Col>
4337
)}
44-
{ENABLE_TEAMS && (
38+
{COMPOSITE_ENABLE_TEAM_MANAGEMENT && (
4539
<Col className="gutter-row" span={12}>
4640
<Link to={URL_TEAMS} className="admin-link">
4741
<Button color="outline" className="btn-links">
@@ -52,7 +46,7 @@ export const Home = () => {
5246
)}
5347
</Row>
5448
<Row gutter={16} className="links-box">
55-
{ENABLE_LOCATIONS && (
49+
{COMPOSITE_ENABLE_LOCATIONS_MANAGEMENT && (
5650
<>
5751
<Col className="gutter-row" span={12}>
5852
<Link to={URL_LOCATION_UNIT} className="admin-link">
@@ -61,14 +55,6 @@ export const Home = () => {
6155
</Button>
6256
</Link>
6357
</Col>
64-
65-
<Col className="gutter-row" span={12}>
66-
<Link to={URL_LOCATION_UNIT_GROUP} className="admin-link">
67-
<Button color="outline" className="btn-links">
68-
{t('Location Unit Group')}
69-
</Button>
70-
</Link>
71-
</Col>
7258
</>
7359
)}
7460
</Row>

app/src/containers/pages/Home/tests/Home.test.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mount, shallow } from 'enzyme';
1+
import { mount } from 'enzyme';
22
import toJson from 'enzyme-to-json';
33
import { history } from '@onaio/connected-reducer-registry';
44
import React from 'react';
@@ -15,12 +15,9 @@ import {
1515
} from '../../../../constants';
1616

1717
jest.mock('../../../../configs/env');
18+
jest.mock('../../../../configs/settings');
1819

1920
describe('containers/pages/Home', () => {
20-
it('renders without crashing', () => {
21-
shallow(<Home />);
22-
});
23-
2421
it('renders Home correctly & changes Title of page', () => {
2522
const wrapper = mount(
2623
<Router history={history}>
@@ -30,7 +27,9 @@ describe('containers/pages/Home', () => {
3027

3128
const helmet = Helmet.peek();
3229
expect(helmet.title).toEqual('OpenSRP Web');
33-
expect(toJson(wrapper.find('Home'))).toMatchSnapshot('Home page rendered');
30+
wrapper.find('.admin-link').forEach((adminLink) => {
31+
expect(toJson(adminLink)).toMatchSnapshot('links on home page');
32+
});
3433
wrapper.unmount();
3534
});
3635

@@ -62,7 +61,7 @@ describe('containers/pages/Home', () => {
6261
);
6362

6463
expect(wrapper.find(`Link[to="${URL_LOCATION_UNIT}"]`)).toHaveLength(1);
65-
expect(wrapper.find(`Link[to="${URL_LOCATION_UNIT_GROUP}"]`)).toHaveLength(1);
64+
expect(wrapper.find(`Link[to="${URL_LOCATION_UNIT_GROUP}"]`)).toHaveLength(0);
6665
});
6766

6867
it('displays links for teams module', () => {

0 commit comments

Comments
 (0)