Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Moving to Vite and react 18. #1321

Draft
wants to merge 66 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f95e4a2
Add antd pro-design
peterMuriuki Oct 25, 2023
e2aa734
Registering a checkmark
peterMuriuki Oct 26, 2023
a5966df
Add url to new user view details
peterMuriuki Oct 27, 2023
f4c1f66
silence table stripping for a more crisp clean look
peterMuriuki Oct 27, 2023
3a8e05f
Second iteration ideating data flow
peterMuriuki Oct 27, 2023
afffdb7
Export fhirDataType components
peterMuriuki Nov 7, 2023
30ab320
Update user management constantts
peterMuriuki Nov 7, 2023
082adf7
Add second iteration of user detail views
peterMuriuki Nov 7, 2023
43e7e50
Move userDeleteWith popup confirm button to own component
peterMuriuki Nov 8, 2023
1ddc671
Add react import to user delete btn component file
peterMuriuki Nov 8, 2023
6067714
Change leave text on group detail view to red
peterMuriuki Nov 8, 2023
7e9085e
Test edit btn works
peterMuriuki Nov 8, 2023
b153716
Fix roleDetail view and add tests
peterMuriuki Nov 8, 2023
bdc246c
Temporarily remove location details view
peterMuriuki Nov 8, 2023
20a52a6
Make description list responsive
peterMuriuki Nov 8, 2023
2ad8aff
Replace previous view details components
peterMuriuki Nov 8, 2023
c0c8ca5
Wrap microcopy in translator function
peterMuriuki Nov 9, 2023
d9a7bbe
Recognize practitionerDetail fhir resource in rbac
peterMuriuki Nov 9, 2023
124d618
Integrate rbac into user detail view
peterMuriuki Nov 9, 2023
393247b
Fix import
peterMuriuki Nov 9, 2023
9667dab
Fix permission string
peterMuriuki Nov 9, 2023
bbea0b2
Update tests
peterMuriuki Nov 9, 2023
a24b3fb
Fix practitionerDetails endpoint
peterMuriuki Jan 15, 2024
19a71e4
Fix url collision to user details
peterMuriuki Jan 16, 2024
e29bf27
Bump react version to v18
peterMuriuki Jan 17, 2024
05a230e
Remove yarn rc file with v1.18 specification
peterMuriuki Jan 17, 2024
d1beb34
Attempting to build with vite
peterMuriuki Jan 17, 2024
e312f4c
Remove changelog file
peterMuriuki Jan 17, 2024
8543cbf
temp refactor the index.html file
peterMuriuki Jan 17, 2024
0995175
Trying something different- rebuilding app from vite template
peterMuriuki Jan 17, 2024
dc229f0
Update devDependencies
peterMuriuki Jan 17, 2024
fd1c9bd
Install admin as a workspace
peterMuriuki Jan 17, 2024
1406b9d
Change preview port to 3000
peterMuriuki Jan 17, 2024
68e5a5e
Move severla folders limited routes
peterMuriuki Jan 17, 2024
f4a8ce8
Rename packages entry point to .ts
peterMuriuki Jan 23, 2024
05b1cd2
Refactor/Update dependency versions in packages
peterMuriuki Jan 23, 2024
f15f178
Replace connected-private-route with react utils implementation
peterMuriuki Jan 23, 2024
fa2f6fe
Refactor code to use vite env and react 18 render method
peterMuriuki Jan 23, 2024
8ffd288
Experimenting with using typescript for transpilation
peterMuriuki Jan 23, 2024
689f31f
Update a few dependencies
peterMuriuki Jan 23, 2024
b49e85e
Add placebo application
peterMuriuki Jan 23, 2024
7a4b06c
Fix rebase error in package.json app
peterMuriuki Jan 23, 2024
99bab3e
Fix recurring dependency issues
peterMuriuki Jan 23, 2024
3fabe85
First working version for both build and dev
peterMuriuki Jan 24, 2024
3b93ea8
Purge admin experimental app
peterMuriuki Jan 24, 2024
44530b1
Update yarn.lock
peterMuriuki Jan 24, 2024
52d42c0
Add package identity-obj-proxy to mock es6 css imports
peterMuriuki Jan 25, 2024
2c5297d
Fix test regression in fhir user management
peterMuriuki Jan 25, 2024
af80592
Refactor tests in fhir-care-team to use rtl
peterMuriuki Jan 26, 2024
bd7bc45
Install test enzyme adapter to allow gradual porting to rtl
peterMuriuki Jan 26, 2024
264857f
Add util function to fill out select fields
peterMuriuki Jan 26, 2024
c2222b1
Migrate test utilities to own package
peterMuriuki Jan 26, 2024
1be1265
Fix regressions in fhir-care-team
peterMuriuki Jan 26, 2024
1f405e8
Fix test import regression in fhir-group-management
peterMuriuki Jan 26, 2024
57c278a
Fix import regression in fhir-user-management
peterMuriuki Jan 26, 2024
d52c3b4
Fix import regression in fhir-location-management
peterMuriuki Jan 26, 2024
c79b505
Fix import regression in fhir-team-management
peterMuriuki Jan 26, 2024
d974606
Fix import regression in fhir-views
peterMuriuki Jan 26, 2024
e06ff9f
Fix import regression in react-utils
peterMuriuki Jan 26, 2024
f738ca7
Deprecate opensrp-1 location management package
peterMuriuki Jan 26, 2024
6d60c83
Fix imports for test utils in user-management
peterMuriuki Jan 26, 2024
dc8e110
Fix test regressions in user-management userForm
peterMuriuki Jan 29, 2024
c385088
Fix regression in user management tests
peterMuriuki Jan 29, 2024
fa48126
Fix test regression userroles list
peterMuriuki Jan 29, 2024
40ef727
fix regression in user create edit user group
peterMuriuki Jan 29, 2024
9f16e81
Skip some tests that need fixing in user management
peterMuriuki Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .yarnrc

This file was deleted.

40 changes: 0 additions & 40 deletions app/CHANGELOG.md

This file was deleted.

13 changes: 13 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
63 changes: 33 additions & 30 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@
"name": "@opensrp/web",
"version": "0.1.10",
"private": true,
"type": "module",
"dependencies": {
"@2fd/ant-design-icons": "^2.6.0",
"@ant-design/icons": "^4.7.0",
"@onaio/connected-private-route": "^0.0.11",
"@ant-design/pro-components": "^2.6.32",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@onaio/connected-reducer-registry": "^0.0.3",
"@onaio/gatekeeper": "1.0.0",
"@onaio/redux-reducer-registry": "^0.0.9",
"@onaio/session-reducer": "^0.0.12",
"@onaio/session-reducer": "^0.0.13",
"@onaio/utils": "^0.0.1",
"@opensrp/error-boundary-fallback": "^0.0.7",
"@opensrp/fhir-care-team": "^0.0.1",
"@opensrp/fhir-client": "^0.0.1",
"@opensrp/fhir-group-management": "^0.0.5",
"@opensrp/fhir-healthcare-service": "^0.0.1",
"@opensrp/fhir-location-management": "^0.0.1",
"@opensrp/fhir-quest-form": "^0.0.0",
"@opensrp/fhir-quest-form": "workspace:^",
"@opensrp/fhir-team-management": "^0.0.5",
"@opensrp/fhir-user-management": "^0.0.1",
"@opensrp/fhir-user-management": "workspace:^",
"@opensrp/fhir-views": "^0.0.0",
"@opensrp/i18n": "^0.0.1",
"@opensrp/keycloak-service": "^0.0.17",
Expand All @@ -31,48 +34,48 @@
"@opensrp/server-logout": "^0.0.2",
"@opensrp/server-service": "^0.0.17",
"@opensrp/store": "^0.0.10",
"@rollup/plugin-commonjs": "^25.0.7",
"@sentry/react": "^5.27.4",
"antd": "^5.5.2",
"bootstrap": "^4.5.2",
"client-oauth2": "^4.3.3",
"connected-react-router": "^6.8.0",
"jsdom-global": "^3.0.2",
"lodash": "^4.17.20",
"querystring": "^0.2.1",
"querystring-es3": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-query": "^3.15.1",
"react-scripts": "4.0.3",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"seamless-immutable": "^7.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "cd ../ && yarn test app --verbose --collectCoverage=true && cd app",
"test:watch": "cd ../ && yarn test app --verbose --watch && cd app",
"lint": "eslint ./**/*.{ts,tsx} --max-warnings 0",
"lint-snap": "eslint ./**/*.snap",
"eject": "react-scripts eject",
"coveralls": "set CI=true && yarn test --runInBand --verbose --coverage=true --forceExit --detectOpenHandles && cat ./coverage/lcov.info | coveralls"
},
"eslintConfig": {
"extends": "react-app"
"devDependencies": {
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react-swc": "^3.5.0",
"assert": "^2.1.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"https-browserify": "^1.0.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"typescript": "^5.2.2",
"url": "^0.11.3",
"util": "^0.12.5",
"vite": "^5.0.8",
"vite-plugin-node-polyfills": "^0.19.0"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"peerDependencies": {
"react": "17.0.0",
"react-dom": "17.0.0",
"react-helmet": "^6.1.0",
"react-redux": "^7.2.1",
"react-router": "^5.2.1",
Expand Down
17 changes: 0 additions & 17 deletions app/public/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/App/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import 'antd/dist/reset.css';
@import '~bootstrap/dist/css/bootstrap.min.css';
/* @import 'antd/dist/reset.css';
@import '~bootstrap/dist/css/bootstrap.min.css'; */

h2.page-title {
font-weight: 200;
Expand Down
22 changes: 16 additions & 6 deletions app/src/App/fhir-apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useOAuthLogin,
OauthCallbackProps,
} from '@onaio/gatekeeper';
import ConnectedPrivateRoute from '@onaio/connected-private-route';

import { Switch, Route, Redirect, RouteComponentProps } from 'react-router';
import { Spin } from 'antd';
import { CustomLogout } from '../components/Logout';
Expand Down Expand Up @@ -63,6 +63,8 @@ import {
import {
CreateEditUser as FHIRConnectedCreateEditUser,
UserList as FhirUserList,
USER_DETAILS_URL,
UserDetailsV2,
} from '@opensrp/fhir-user-management';
import { Home } from '../containers/pages/Home/Home';
import {
Expand Down Expand Up @@ -100,7 +102,7 @@ import {
qrListRouteKey,
QUEST_FORM_VIEW_URL,
} from '@opensrp/fhir-views';
import { QuestRForm, resourceTypeParam, resourceIdParam } from '@opensrp/fhir-quest-form';
// import { QuestRForm, resourceTypeParam, resourceIdParam } from '@opensrp/fhir-quest-form';
import {
CommodityList,
ADD_EDIT_COMMODITY_URL,
Expand Down Expand Up @@ -153,20 +155,20 @@ const FHIRApps = () => {
<Switch>
{/* tslint:disable jsx-no-lambda */}
{/* Home Page view */}
<ConnectedPrivateRoute
<PrivateComponent
redirectPath={APP_CALLBACK_URL}
disableLoginProtection={DISABLE_LOGIN_PROTECTION}
exact
path={URL_HOME}
component={Home}
/>
<PrivateComponent
{/* <PrivateComponent
redirectPath={APP_CALLBACK_URL}
disableLoginProtection={DISABLE_LOGIN_PROTECTION}
path={`${QUEST_FORM_VIEW_URL}/:${resourceIdParam}/:${resourceTypeParam}`}
permissions={['Questionnaire.read']}
component={QuestRForm}
/>
/> */}
<PrivateComponent
redirectPath={APP_CALLBACK_URL}
disableLoginProtection={DISABLE_LOGIN_PROTECTION}
Expand Down Expand Up @@ -224,6 +226,14 @@ const FHIRApps = () => {
permissions={['iam_user.read']}
component={FhirUserList}
/>
<PrivateComponent
redirectPath={APP_CALLBACK_URL}
disableLoginProtection={DISABLE_LOGIN_PROTECTION}
exact
path={USER_DETAILS_URL}
permissions={['iam_user.read']}
component={UserDetailsV2}
/>
<PrivateComponent
redirectPath={APP_CALLBACK_URL}
disableLoginProtection={DISABLE_LOGIN_PROTECTION}
Expand Down Expand Up @@ -464,7 +474,7 @@ const FHIRApps = () => {
/>
<PublicComponent exact path={APP_CALLBACK_PATH} component={CallbackComponent} />
{/* tslint:enable jsx-no-lambda */}
<ConnectedPrivateRoute
<PrivateComponent
redirectPath={APP_CALLBACK_URL}
disableLoginProtection={DISABLE_LOGIN_PROTECTION}
exact
Expand Down
2 changes: 1 addition & 1 deletion app/src/configs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param defaultValue - The default value to return the value is not defined in process.env and window._env_.
*/
export const setEnv = (name: string, defaultValue: any) => {
const { [name]: envValue } = process.env;
const { [name]: envValue } = import.meta.env;
const value = typeof envValue === 'undefined' ? defaultValue : envValue;

if (typeof (window as any)._env_ === 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion app/src/containers/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const Home = () => {
<Helmet>
<title>{t('OpenSRP Web')}</title>
</Helmet>
<Row justify="center" className="weclome-box">
<Row justify="center" className="welcome-box">
<Col span={6}>
<h3>{t('Welcome to OpenSRP')}</h3>
</Col>
Expand Down
9 changes: 4 additions & 5 deletions app/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './configs/dispatchConfig'; // this needs to be imported before anything else
import React, { Suspense } from 'react';
import ReactDOM from 'react-dom';
import { history } from '@onaio/connected-reducer-registry';
import { ConnectedRouter } from 'connected-react-router';
import { Provider } from 'react-redux';
Expand All @@ -16,14 +15,15 @@ import { QueryClient, QueryClientProvider } from 'react-query';
import { OpensrpWebI18nProvider } from '@opensrp/i18n';
import '@opensrp/react-utils/dist/components/CommonStyles/index.css';
import { RbacProvider } from '@opensrp/rbac';
import ReactDOM from 'react-dom/client'

// tslint:disable-next-line: ordered-imports
import './styles/css/index.css';
import { Spin } from 'antd';
// tslint:disable-next-line: ordered-imports
const queryClient = new QueryClient();

if (process.env.NODE_ENV === 'production') {
if (import.meta.env.DEV) {
const { tags, ...sentryConfigs } = SENTRY_CONFIGS;
Sentry.init(sentryConfigs);
if (tags) {
Expand All @@ -35,7 +35,7 @@ if (process.env.NODE_ENV === 'production') {
}
}

ReactDOM.render(
ReactDOM.createRoot(document.getElementById('root')!).render(
<Suspense fallback={() => <Spin className="custom-spinner" />}>
<Sentry.ErrorBoundary fallback={() => <ErrorBoundaryFallback homeUrl={URL_HOME} />}>
<Provider store={store}>
Expand All @@ -50,8 +50,7 @@ ReactDOM.render(
</ConnectedRouter>
</Provider>
</Sentry.ErrorBoundary>
</Suspense>,
document.getElementById('opensrp-root')
</Suspense>
);

// If you want your app to work offline and load faster, you can change
Expand Down
31 changes: 15 additions & 16 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"compilerOptions": {
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions app/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
Loading
Loading