From a58c091f6ecfd7a8c83d331697931178a8c30736 Mon Sep 17 00:00:00 2001 From: alexd-bes <129009580+alexd-bes@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:11:34 +1200 Subject: [PATCH 01/26] tweak(adminPanel): Allow multiple file imports for data tables (#5699) --- packages/admin-panel/src/routes/visualisations/dataTables.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/admin-panel/src/routes/visualisations/dataTables.js b/packages/admin-panel/src/routes/visualisations/dataTables.js index 3824bfab57..9428dc929b 100644 --- a/packages/admin-panel/src/routes/visualisations/dataTables.js +++ b/packages/admin-panel/src/routes/visualisations/dataTables.js @@ -94,6 +94,7 @@ const IMPORT_CONFIG = { title: `Import ${RESOURCE_NAME.singular}`, actionConfig: { importEndpoint: 'dataTables', + multiple: true, }, }; const EDITOR_CONFIG = { displayUsedBy: true }; From e330de65b847016e0205f0b17e0ba99c62137bf9 Mon Sep 17 00:00:00 2001 From: Jasper Lai <33956381+jaskfla@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:39:24 +1200 Subject: [PATCH 02/26] deps: update browserslist (#5694) ran `yarn dlx update-browserslist-db@latest` --- yarn.lock | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/yarn.lock b/yarn.lock index ea67dbea03..acd16f7bb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17999,24 +17999,10 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.30001043, caniuse-lite@npm:^1.0.30001109, caniuse-lite@npm:^1.0.30001125, caniuse-lite@npm:^1.0.30001254, caniuse-lite@npm:^1.0.30001261, caniuse-lite@npm:^1.0.30001370, caniuse-lite@npm:^1.0.30001503": - version: 1.0.30001525 - resolution: "caniuse-lite@npm:1.0.30001525" - checksum: a0d190c185b8e1220dbc72e42f310633059aa175ca3396eb781b249ac3da6c62b30cb8efc5fa24d632cb938f58d90b0c7772d1c9942b6643cf418c27c2cb8632 - languageName: node - linkType: hard - -"caniuse-lite@npm:^1.0.30001541": - version: 1.0.30001558 - resolution: "caniuse-lite@npm:1.0.30001558" - checksum: 1bd6ef855a0de6ff052234912910d699e58edabcf2f34848b7df1f97ee40b059bbdf1901ac919d19360a0603e32e2ac30ae89670ceca8f118e750be3280ef5b1 - languageName: node - linkType: hard - -"caniuse-lite@npm:^1.0.30001565": - version: 1.0.30001578 - resolution: "caniuse-lite@npm:1.0.30001578" - checksum: b0cd4fed07ae1224f564baaed5e096c9c479b3063d023fc629df52caa14e59b7436b33498729161e253a5b8974d644374ff1ce47ccf1885ef3d1541f4067705f +"caniuse-lite@npm:^1.0.30001043, caniuse-lite@npm:^1.0.30001109, caniuse-lite@npm:^1.0.30001125, caniuse-lite@npm:^1.0.30001254, caniuse-lite@npm:^1.0.30001261, caniuse-lite@npm:^1.0.30001370, caniuse-lite@npm:^1.0.30001503, caniuse-lite@npm:^1.0.30001541, caniuse-lite@npm:^1.0.30001565": + version: 1.0.30001625 + resolution: "caniuse-lite@npm:1.0.30001625" + checksum: e7f8b9e10c35a5d9a1d1db76be398cb1c592ee1bc905fabe6bd90313537099d29a65c49c85e6350132fa30ca20e8c0317ecfaa66d997f7fac21ff37ddaece2a9 languageName: node linkType: hard From 6e61c34223d7a4011385ad26e124262d3e8e38bb Mon Sep 17 00:00:00 2001 From: Jasper Lai <33956381+jaskfla@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:29:42 +1200 Subject: [PATCH 03/26] feat(datatrakWeb): RN-1219: open DataTrak links in MediTrak iOS app (#5313) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * associate domains * iOS smart app banner * use newer AASA format * update `Podfile.lock` via `pod install` Not actually 100% sure what this means 😬 * restore previous bundle ID * fix bundle ID in AASA file * temporary: dev mode on all associated domains * temporary: provisioning profile * don‘t open account settings in MediTrak * experiment: file in root of `public` folder * experiment: add AASA to Vite `assetsInclude` * fix implicit any * fix mixed-up comments * stricter `assetsInclude` * test `public` files with extensions * test explicit reference to AASA * teset `assetsInclude` with extensions * Revert "test explicit reference to AASA" This reverts commit 384608659c20cf55d2bd96887a4c3b3601887a53. * try nginx `location` for AASA * try nginx `location` in correct server * ⚗️ add `index` to nginx `location` for AASA * try commenting out Vite `assetsInclude` * remove redundant Vite `assetsInclude` * delete experimental static files * remove me-specific `project.pbxproj` entries * format AASA as JSON * update podfile * remove test domain and developer mode * amend which links open in app * fix: prevent account-settings and report * retry allowing all but a few * support login autofill --- packages/datatrak-web/.prettierrc | 8 ++++++ packages/datatrak-web/index.html | 4 +++ .../.well-known/apple-app-site-association | 22 ++++++++++++++++ .../src/components/ErrorDisplay.tsx | 2 +- .../nginx-template/servers.template.conf | 8 +++++- .../app/authentication/LoginPage.jsx | 2 ++ packages/meditrak-app/ios/Podfile.lock | 14 +++++----- .../TupaiaMediTrak.xcodeproj/project.pbxproj | 26 +++++++++++++++++-- .../TupaiaMediTrak.entitlements | 12 +++++++++ vite.config.js | 3 +-- 10 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 packages/datatrak-web/.prettierrc create mode 100644 packages/datatrak-web/public/.well-known/apple-app-site-association create mode 100644 packages/meditrak-app/ios/TupaiaMediTrak/TupaiaMediTrak.entitlements diff --git a/packages/datatrak-web/.prettierrc b/packages/datatrak-web/.prettierrc new file mode 100644 index 0000000000..0c14b02ab6 --- /dev/null +++ b/packages/datatrak-web/.prettierrc @@ -0,0 +1,8 @@ +{ + "overrides": [ + { + "files": ["apple-app-site-association"], + "options": { "parser": "json" } + } + ] +} diff --git a/packages/datatrak-web/index.html b/packages/datatrak-web/index.html index a4fabd2eef..edb640c977 100644 --- a/packages/datatrak-web/index.html +++ b/packages/datatrak-web/index.html @@ -19,6 +19,10 @@ property="og:description" content="Data collection and visualisation for the most remote settings in the world" /> + + + + <% if (process.env.REACT_APP_DEPLOYMENT_NAME === 'master' || process.env.REACT_APP_DEPLOYMENT_NAME === 'main' || process.env.REACT_APP_DEPLOYMENT_NAME === 'production') { %> diff --git a/packages/datatrak-web/public/.well-known/apple-app-site-association b/packages/datatrak-web/public/.well-known/apple-app-site-association new file mode 100644 index 0000000000..2893a058af --- /dev/null +++ b/packages/datatrak-web/public/.well-known/apple-app-site-association @@ -0,0 +1,22 @@ +{ + "applinks": { + "apps": [], + "details": [ + { + "appIDs": ["352QMCKRKJ.com.tupaia.meditrak"], + "components": [ + { "/": "/account-settings/*", "exclude": true }, + { "/": "/forgot-password/*", "exclude": true }, + { "/": "/reports/*", "exclude": true }, + { "/": "/reset-password/*", "exclude": true }, + { "/": "/verify-email/*", "exclude": true }, + { "/": "/verify-email-resend/*", "exclude": true }, + { "/": "/*" } + ] + } + ] + }, + "webcredentials": { + "apps": ["352QMCKRKJ.com.tupaia.meditrak"] + } +} diff --git a/packages/datatrak-web/src/components/ErrorDisplay.tsx b/packages/datatrak-web/src/components/ErrorDisplay.tsx index ff8d813b06..6541405894 100644 --- a/packages/datatrak-web/src/components/ErrorDisplay.tsx +++ b/packages/datatrak-web/src/components/ErrorDisplay.tsx @@ -39,7 +39,7 @@ export const ErrorDisplay = ({ }: { error?: Error | null; children?: ReactNode; - title; + title: ReactNode; }) => { return ( diff --git a/packages/devops/configs/nginx-template/servers.template.conf b/packages/devops/configs/nginx-template/servers.template.conf index d1345630b8..84a47d68fd 100644 --- a/packages/devops/configs/nginx-template/servers.template.conf +++ b/packages/devops/configs/nginx-template/servers.template.conf @@ -112,8 +112,14 @@ server { expires 0; } + # For Universal Links and Shared Web Credentials on Apple platforms + # See https://developer.apple.com/documentation/xcode/supporting-associated-domains + location /.well-known/apple-app-site-association { + index apple-app-site-association; + default_type application/json; + } + # Redirect error pages - # error_page 404 500 502 503 504 /error_page.html; location = /error_page.html { root /home/ubuntu/tupaia; diff --git a/packages/meditrak-app/app/authentication/LoginPage.jsx b/packages/meditrak-app/app/authentication/LoginPage.jsx index d6e92b916a..46e9b524f4 100644 --- a/packages/meditrak-app/app/authentication/LoginPage.jsx +++ b/packages/meditrak-app/app/authentication/LoginPage.jsx @@ -78,6 +78,7 @@ export class LoginPage extends React.Component { {errorMessage !== '' && renderErrorMessage(errorMessage)} { this.passwordInputRef = reference; }} diff --git a/packages/meditrak-app/ios/Podfile.lock b/packages/meditrak-app/ios/Podfile.lock index c0135b9f2e..7814b492dc 100644 --- a/packages/meditrak-app/ios/Podfile.lock +++ b/packages/meditrak-app/ios/Podfile.lock @@ -397,7 +397,7 @@ PODS: - react-native-config/App (= 1.5.1) - react-native-config/App (1.5.1): - React-Core - - react-native-document-picker (9.0.1): + - react-native-document-picker (9.1.1): - React-Core - react-native-geolocation (3.1.0): - React-Core @@ -519,7 +519,7 @@ PODS: - React-jsi (= 0.72.5) - React-logger (= 0.72.5) - React-perflogger (= 0.72.5) - - RealmJS (12.2.1): + - RealmJS (12.3.1): - React - RNCAsyncStorage (1.19.3): - React-Core @@ -789,7 +789,7 @@ SPEC CHECKSUMS: appcenter-analytics: fbeef54afe6fa91d3803dfd31499817baa81fec0 appcenter-core: e192ea8b373bebd3e44998882b43311078bd7dda AppCenterReactNativeShared: 01df23849b1c3c6eb8c4049f54322635650e98f0 - boost: 57d2868c099736d80fcd648bf211b4431e51a558 + boost: 64032b9e9b938fda23325e68a3771f0fabf414dc BugsnagReactNative: c681c456736c24344553f48013da8253eb00ee92 BVLinearGradient: 880f91a7854faff2df62518f0281afb1c60d49a3 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 @@ -805,7 +805,7 @@ SPEC CHECKSUMS: Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 - glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b + glog: a1239c5c5b1018806c4f93e15aa57e6e39461a62 hermes-engine: f6cf92a471053245614d9d8097736f6337d5b86c libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c @@ -826,7 +826,7 @@ SPEC CHECKSUMS: React-logger: 2e4aee3e11b3ec4fa6cfd8004610bbb3b8d6cca4 react-native-cameraroll: 121cab3d7fe2972d9a26ef40558d78d4053356a8 react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8 - react-native-document-picker: 2b8f18667caee73a96708a82b284a4f40b30a156 + react-native-document-picker: 3599b238843369026201d2ef466df53f77ae0452 react-native-geolocation: ef66fb798d96284c6043f0b16c15d9d1d4955db4 react-native-image-picker: 2e2e82aba9b6a91a7c78f7d9afde341a2659c7b8 react-native-netinfo: fefd4e98d75cbdd6e85fc530f7111a8afdf2b0c5 @@ -849,7 +849,7 @@ SPEC CHECKSUMS: React-runtimescheduler: cc32add98c45c5df18436a6a52a7e1f6edec102c React-utils: 7a9918a1ffdd39aba67835d42386f592ea3f8e76 ReactCommon: 91ece8350ebb3dd2be9cef662abd78b6948233c0 - RealmJS: b36dae5c0def204602827884512252a320332c69 + RealmJS: 578e16cf7c0b32c13a23b2df667b021bb3c36f1c RNCAsyncStorage: c913ede1fa163a71cea118ed4670bbaaa4b511bb RNDateTimePicker: 8fb39263b721223e095248acaf6f406d5b7f6713 RNDeviceInfo: bf8a32acbcb875f568217285d1793b0e8588c974 @@ -866,4 +866,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 9d0921d206ad5368ab2b22815114d4a166126a49 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/packages/meditrak-app/ios/TupaiaMediTrak.xcodeproj/project.pbxproj b/packages/meditrak-app/ios/TupaiaMediTrak.xcodeproj/project.pbxproj index 09574ef2fe..e86c40069a 100644 --- a/packages/meditrak-app/ios/TupaiaMediTrak.xcodeproj/project.pbxproj +++ b/packages/meditrak-app/ios/TupaiaMediTrak.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 5DCACB8F33CDC322A6C60F78 /* libPods-TupaiaMediTrak.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TupaiaMediTrak.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = TupaiaMediTrak/LaunchScreen.storyboard; sourceTree = ""; }; 89C6BE57DB24E9ADA2F236DE /* Pods-TupaiaMediTrak-TupaiaMediTrakTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TupaiaMediTrak-TupaiaMediTrakTests.release.xcconfig"; path = "Target Support Files/Pods-TupaiaMediTrak-TupaiaMediTrakTests/Pods-TupaiaMediTrak-TupaiaMediTrakTests.release.xcconfig"; sourceTree = ""; }; + A4FBBCAE2B4BA3A600ADA573 /* TupaiaMediTrak.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = TupaiaMediTrak.entitlements; path = TupaiaMediTrak/TupaiaMediTrak.entitlements; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -88,6 +89,7 @@ 13B07FAE1A68108700A75B9A /* TupaiaMediTrak */ = { isa = PBXGroup; children = ( + A4FBBCAE2B4BA3A600ADA573 /* TupaiaMediTrak.entitlements */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 13B07FB51A68108700A75B9A /* Images.xcassets */, @@ -489,8 +491,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = TupaiaMediTrak/TupaiaMediTrak.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 141; DEVELOPMENT_TEAM = 352QMCKRKJ; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 352QMCKRKJ; ENABLE_BITCODE = NO; INFOPLIST_FILE = TupaiaMediTrak/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -503,7 +510,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = com.tupaia.meditrak; PRODUCT_NAME = TupaiaMediTrak; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -517,8 +524,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = TupaiaMediTrak/TupaiaMediTrak.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 141; DEVELOPMENT_TEAM = 352QMCKRKJ; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 352QMCKRKJ; INFOPLIST_FILE = TupaiaMediTrak/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -530,7 +542,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = com.tupaia.meditrak; PRODUCT_NAME = TupaiaMediTrak; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -614,6 +626,11 @@ "-ld_classic", "-Wl", "-ld_classic", + "-Wl", + "-ld_classic", + "-Wl", + "-ld_classic", + "-Wl -ld_classic ", ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; @@ -692,6 +709,11 @@ "-ld_classic", "-Wl", "-ld_classic", + "-Wl", + "-ld_classic", + "-Wl", + "-ld_classic", + "-Wl -ld_classic ", ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; diff --git a/packages/meditrak-app/ios/TupaiaMediTrak/TupaiaMediTrak.entitlements b/packages/meditrak-app/ios/TupaiaMediTrak/TupaiaMediTrak.entitlements new file mode 100644 index 0000000000..7bf19e40a2 --- /dev/null +++ b/packages/meditrak-app/ios/TupaiaMediTrak/TupaiaMediTrak.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.developer.associated-domains + + applinks:datatrak.tupaia.org + webcredentials:datatrak.tupaia.org + webcredentials:tupaia.org + + + diff --git a/vite.config.js b/vite.config.js index 3c577a7b89..3729ec23bf 100644 --- a/vite.config.js +++ b/vite.config.js @@ -38,9 +38,8 @@ export default defineConfig(({ command, mode }) => { }, }, - // ViteEjsPlugin is used to allow the use of EJS templates in the index.html file, for analytics scripts etc plugins: [ - ViteEjsPlugin(), + ViteEjsPlugin(), // Enables use of EJS templates in the index.html file, for analytics scripts etc viteCompression(), react({ jsxRuntime: 'classic', From fbc924940b0fc14af7759473a367e5454c88674b Mon Sep 17 00:00:00 2001 From: Jasper Lai <33956381+jaskfla@users.noreply.github.com> Date: Thu, 6 Jun 2024 13:28:43 +1200 Subject: [PATCH 04/26] feat(meditrak): RN-1219: `tupaiameditrak://` URL scheme (#5702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * associate domains * iOS smart app banner * use newer AASA format * update `Podfile.lock` via `pod install` Not actually 100% sure what this means 😬 * restore previous bundle ID * fix bundle ID in AASA file * temporary: dev mode on all associated domains * temporary: provisioning profile * don‘t open account settings in MediTrak * experiment: file in root of `public` folder * experiment: add AASA to Vite `assetsInclude` * fix implicit any * fix mixed-up comments * stricter `assetsInclude` * test `public` files with extensions * test explicit reference to AASA * teset `assetsInclude` with extensions * Revert "test explicit reference to AASA" This reverts commit 384608659c20cf55d2bd96887a4c3b3601887a53. * try nginx `location` for AASA * try nginx `location` in correct server * ⚗️ add `index` to nginx `location` for AASA * try commenting out Vite `assetsInclude` * remove redundant Vite `assetsInclude` * delete experimental static files * remove me-specific `project.pbxproj` entries * format AASA as JSON * update podfile * remove test domain and developer mode * amend which links open in app * fix: prevent account-settings and report * retry allowing all but a few * support login autofill * add `tupaiameditrak://` URL scheme --- packages/meditrak-app/ios/TupaiaMediTrak/Info.plist | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/meditrak-app/ios/TupaiaMediTrak/Info.plist b/packages/meditrak-app/ios/TupaiaMediTrak/Info.plist index a83b4dd84d..faf6da1da4 100644 --- a/packages/meditrak-app/ios/TupaiaMediTrak/Info.plist +++ b/packages/meditrak-app/ios/TupaiaMediTrak/Info.plist @@ -22,6 +22,17 @@ ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) + CFBundleURLTypes + + + CFBundleURLName + + CFBundleURLSchemes + + tupaiameditrak + + + ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS From 197c1ab0cb3bbbe0633af13f576116c18fc660c1 Mon Sep 17 00:00:00 2001 From: Jasper Lai <33956381+jaskfla@users.noreply.github.com> Date: Thu, 6 Jun 2024 13:29:04 +1200 Subject: [PATCH 05/26] =?UTF-8?q?tweak(scripts):=20hide=20`setupNewDatabas?= =?UTF-8?q?e.sh`=E2=80=99s=20executed=20commands=20(#5703)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hide executed commands in `setupNewDatabase` --- packages/database/scripts/setupNewDatabase.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/database/scripts/setupNewDatabase.sh b/packages/database/scripts/setupNewDatabase.sh index aa1e4791d0..642fb303b2 100755 --- a/packages/database/scripts/setupNewDatabase.sh +++ b/packages/database/scripts/setupNewDatabase.sh @@ -17,8 +17,6 @@ source "$DIR/../../scripts/bash/mergeEnvForDB.sh" # Set default port in case it wasn't in .env : "${DB_PORT:=5432}" -set -x - IS_RDS=$(PGPASSWORD="$DB_PG_PASSWORD" psql -qtAX -h "$DB_URL" -p "$DB_PORT" -U "$DB_PG_USER" -c "SELECT 1 FROM pg_roles WHERE rolname='rds_superuser'") PGPASSWORD="$DB_PG_PASSWORD" psql -h "$DB_URL" -p "$DB_PORT" -U "$DB_PG_USER" -c "CREATE ROLE $DB_USER LOGIN PASSWORD '$DB_PASSWORD'" || echo "Role $DB_USER already exists?" From 6cf82d8c8b8ae6af6eca95ef60c72d5e6bd6a74e Mon Sep 17 00:00:00 2001 From: alexd-bes <129009580+alexd-bes@users.noreply.github.com> Date: Fri, 7 Jun 2024 08:11:54 +1200 Subject: [PATCH 06/26] fix(tupaiaWeb): RN-1237: Fix styling for nested columns (#5706) * Fix styling for nested columns * Fix span type --- packages/tupaia-web/src/theme/theme.ts | 5 +---- .../ui-components/src/components/Matrix/Cell.tsx | 3 +++ .../src/components/Matrix/Matrix.tsx | 1 + .../src/components/Matrix/MatrixHeader.tsx | 16 ++++++++++++---- .../src/components/Matrix/MatrixRow.tsx | 4 +++- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/tupaia-web/src/theme/theme.ts b/packages/tupaia-web/src/theme/theme.ts index c3144eb38e..e7d00566bc 100644 --- a/packages/tupaia-web/src/theme/theme.ts +++ b/packages/tupaia-web/src/theme/theme.ts @@ -124,13 +124,10 @@ theme.overrides = { lineHeight: '1.4', borderBottom: 'none', // remove the bottom border from all cells, and it will be applied to the header cells below ['&.MuiTableCell-row-head']: { - borderRight: `1px solid ${theme.palette.divider}`, // border right for the row header cells fontWeight: theme.typography.fontWeightMedium, }, }, - head: { - borderBottom: `1px solid ${theme.palette.divider}`, // header cells have a bottom border - }, + stickyHeader: { backgroundColor: 'inherit', // make the sticky header cells have the row's background color }, diff --git a/packages/ui-components/src/components/Matrix/Cell.tsx b/packages/ui-components/src/components/Matrix/Cell.tsx index 663e5be2b7..29c9ef93d9 100644 --- a/packages/ui-components/src/components/Matrix/Cell.tsx +++ b/packages/ui-components/src/components/Matrix/Cell.tsx @@ -16,4 +16,7 @@ export const Cell = styled(TableCell)<{ max-width: 30ch; // don't let the text take up too much space; word-break: ${({ $characterLength = 0 }) => ($characterLength > 30 ? 'break-word' : 'normal')}; white-space: pre-line; + &.MuiTableCell-row-head { + box-shadow: inset -1px 0 0 0 ${({ theme }) => theme.palette.divider}; // add a border to the right of the first cell, but use a box shadow so that it doesn't get hidden on scroll + } `; diff --git a/packages/ui-components/src/components/Matrix/Matrix.tsx b/packages/ui-components/src/components/Matrix/Matrix.tsx index 7340dbf1bc..bc39355feb 100644 --- a/packages/ui-components/src/components/Matrix/Matrix.tsx +++ b/packages/ui-components/src/components/Matrix/Matrix.tsx @@ -16,6 +16,7 @@ import { MatrixLegend } from './MatrixLegend'; const MatrixTable = styled.table` color: ${({ theme }) => theme.palette.text.primary}; height: 1px; // this is to make the cell content (eg. buttons) take full height of the cell, and does not actually get applied + border-collapse: collapse; // necessary to enable borders between column groups `; // wraps the table in a container so that we can set a max-height on it and make it scrollable inside it diff --git a/packages/ui-components/src/components/Matrix/MatrixHeader.tsx b/packages/ui-components/src/components/Matrix/MatrixHeader.tsx index 72a510d627..2c978cf0d0 100644 --- a/packages/ui-components/src/components/Matrix/MatrixHeader.tsx +++ b/packages/ui-components/src/components/Matrix/MatrixHeader.tsx @@ -8,18 +8,23 @@ import styled from 'styled-components'; import { MatrixColumnType } from '../../types'; import { MatrixContext } from './MatrixContext'; import { Cell } from './Cell'; +import { getFlattenedColumns } from './utils'; const HeaderCell = styled(Cell)` line-height: 1.4; z-index: 3; // set the z-index of the first cell to be above the rest of the column header cells so that it doesn't get covered on horizontal scroll - &:first-child { + box-shadow: inset 0 -1px 0 0 ${({ theme }) => theme.palette.divider}; // add a border to the bottom but ise a box shadow so that it doesn't get hidden on scroll + &.MuiTableCell-row-head { z-index: 4; // set the z-index of the first cell to be above the rest of the column header cells so that it doesn't get covered on horizontal scroll max-width: 12rem; // set the max-width of the first cell so that on larger screens the row header column doesn't take up too much space + box-shadow: inset -1px -1px 0 0 ${({ theme }) => theme.palette.divider}; // add a border to the right of the first cell, but use a box shadow so that it doesn't get hidden on scroll } `; const ColGroup = styled.colgroup` - border: 2px solid ${({ theme }) => darken(theme.palette.text.primary, 0.4)}; + &:not(:first-of-type) { + border-right: 1px solid ${({ theme }) => darken(theme.palette.text.primary, 0.4)}; + } `; /** @@ -41,12 +46,15 @@ export const MatrixHeader = () => { {rowHeaderColumnTitle} ); + + const flattenedColumns = getFlattenedColumns(columns); + return ( /** * If there are no parents, then there are only column groups to style for the row header column and the rest of the table. Otherwise, there are column groups for each displayed column group, plus one for the row header column. * */ <> - + {hasParents ? ( <> {columnGroups.map(({ title, children = [] }) => ( @@ -70,7 +78,7 @@ export const MatrixHeader = () => { {/** If hasParents is true, then this row header column cell will have already been rendered. */} {!hasParents && RowHeaderColumn} - {columns.map(({ title, key }) => ( + {flattenedColumns.map(({ title, key }) => ( { const { children, title, onClick } = row; const { columns, expandedRows, disableExpand = false } = useContext(MatrixContext); + const flattenedColumns = getFlattenedColumns(columns); const isExpanded = expandedRows.includes(title); const depth = parents.length; @@ -306,7 +308,7 @@ export const MatrixRow = ({ row, parents = [], index }: MatrixRowProps) => { > {title} - {columns.map(({ key, title: cellTitle }) => ( + {flattenedColumns.map(({ key, title: cellTitle }) => ( Date: Fri, 7 Jun 2024 13:46:53 +1200 Subject: [PATCH 07/26] fix(datatrakWeb): Fix prettier overrides (#5710) fic(datatrakWeb): Fix prettier overrides --- .prettierrc => .prettierrc.js | 2 +- packages/datatrak-web/.prettierrc | 8 -------- packages/datatrak-web/.prettierrc.js | 11 +++++++++++ 3 files changed, 12 insertions(+), 9 deletions(-) rename .prettierrc => .prettierrc.js (83%) delete mode 100644 packages/datatrak-web/.prettierrc create mode 100644 packages/datatrak-web/.prettierrc.js diff --git a/.prettierrc b/.prettierrc.js similarity index 83% rename from .prettierrc rename to .prettierrc.js index 4d03a9151a..4434eb1ee2 100644 --- a/.prettierrc +++ b/.prettierrc.js @@ -1,4 +1,4 @@ -{ +module.exports = { "arrowParens": "avoid", "printWidth": 100, "singleQuote": true, diff --git a/packages/datatrak-web/.prettierrc b/packages/datatrak-web/.prettierrc deleted file mode 100644 index 0c14b02ab6..0000000000 --- a/packages/datatrak-web/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "overrides": [ - { - "files": ["apple-app-site-association"], - "options": { "parser": "json" } - } - ] -} diff --git a/packages/datatrak-web/.prettierrc.js b/packages/datatrak-web/.prettierrc.js new file mode 100644 index 0000000000..9eb26c9f15 --- /dev/null +++ b/packages/datatrak-web/.prettierrc.js @@ -0,0 +1,11 @@ +const baseConfig = require('./../../.prettierrc.js'); + +module.exports = { + ...baseConfig, + overrides: [ + { + files: ['apple-app-site-association'], + options: { parser: 'json' }, + }, + ], +}; From 7e402a5a8478fce2522498a1ee7dfeb80b2d2eab Mon Sep 17 00:00:00 2001 From: alexd-bes <129009580+alexd-bes@users.noreply.github.com> Date: Mon, 10 Jun 2024 07:46:34 +1200 Subject: [PATCH 08/26] tweak(adminPanel): RN-1295: Update auth screens on admin panel (#5666) * WIP * Change password page * Handle 401 errors the same way as other errors * Handle redirecting login * Forgot password views * Reset password view * Primary blue colour * Use constants for auth routes * WIP LESMIS * LESMIS * Tidy ups * Update broken build type * Update getSurveyResponsePageConfig.js * use user endpoint * remove viz builder useUser * Fix session handling * Revert "Fix session handling" This reverts commit 302c8290f33c4114887156cd63a36272e2ccf56f. * PR fixes * tweak(serverBoilerplate): RN-1295: Bypass session handling for request reset password route (#5668) * tweak(serverBoilerplate): RN-1295: Bypass session handling for request reset password route * Make all frontends use the same requestResetPassword * Remove requestResetPassword from web-config-server * Merge fixes * Build fixes * Update top navbar * Fix styling on LESMIS * Styling * Fix redirect * Colours * LESMIS * Display error if caught * Disable links on auth pages * Fix crashing pages --------- Co-authored-by: Andrew --- packages/admin-panel/src/App.jsx | 46 +++---- .../admin-panel/src/VizBuilderApp/App.jsx | 18 +-- .../src/VizBuilderApp/api/constants.js | 2 +- .../src/VizBuilderApp/api/queries/index.js | 1 - .../src/VizBuilderApp/api/queries/useUser.js | 18 --- .../src/VizBuilderApp/components/index.js | 1 - packages/admin-panel/src/api/TupaiaApi.js | 27 ---- .../admin-panel/src/api/mutations/index.js | 11 ++ .../admin-panel/src/api/mutations/useLogin.js | 41 +++++++ .../src/api/mutations/useLogout.js | 17 +++ .../src/api/mutations/useOneTimeLogin.js | 25 ++++ .../api/mutations/useRequestResetPassword.js | 18 +++ .../src/api/mutations/useResetPassword.js | 38 ++++++ .../src/api/mutations/useUpdateProfile.js | 24 ++++ packages/admin-panel/src/api/queries/index.js | 6 + .../admin-panel/src/api/queries/useUser.js | 21 ++++ .../src/authentication/LoginForm.jsx | 110 ----------------- .../src/authentication/PrivateRoute.jsx | 29 ++--- .../src/authentication/ProfileButton.jsx | 26 ---- .../src/authentication/RegisterLink.jsx | 25 ++++ .../admin-panel/src/authentication/actions.js | 87 +------------ .../src/authentication/constants.js | 9 +- .../admin-panel/src/authentication/index.js | 6 +- .../admin-panel/src/authentication/reducer.js | 69 ----------- .../src/authentication/selectors.js | 28 ----- .../admin-panel/src/layout/AppPageLayout.jsx | 12 +- .../admin-panel/src/layout/AuthLayout.jsx | 60 +++++++++ packages/admin-panel/src/layout/Page.jsx | 8 ++ .../src/layout/SimplePageLayout.jsx | 49 ++++++++ packages/admin-panel/src/layout/index.js | 4 +- .../src/layout/navigation/HomeLink.jsx | 6 +- .../src/layout/navigation/NavPanel.jsx | 17 ++- .../src/layout/navigation/SecondaryNavbar.jsx | 8 +- .../navigation/TopNavbar.jsx} | 26 ++-- .../{UserLink.jsx => UserButton.jsx} | 14 ++- .../src/layout/navigation/UserProfileInfo.jsx | 28 +++-- .../src/layout/navigation/index.js | 3 +- packages/admin-panel/src/library.js | 15 ++- .../src/pages/ChangePasswordPage.jsx | 79 ++++-------- .../src/pages/ForgotPasswordPage.jsx | 26 ++++ packages/admin-panel/src/pages/LoginPage.jsx | 115 ++++-------------- packages/admin-panel/src/pages/LogoutPage.jsx | 42 ------- .../admin-panel/src/pages/ProfilePage.jsx | 94 ++++---------- .../src/pages/ResetPasswordPage.jsx | 79 ++++++++++++ packages/admin-panel/src/pages/index.js | 3 +- .../src/pages/resources/ResourcePage.jsx | 13 +- .../src/pages/resources/resourceName.js | 8 +- packages/admin-panel/src/profileRoutes.jsx | 4 +- packages/admin-panel/src/rootReducer.js | 7 +- .../src/routes/entities/entityHierarchies.js | 2 +- packages/admin-panel/src/routes/index.js | 2 +- .../admin-panel/src/routes/projects/strive.js | 2 +- packages/admin-panel/src/routes/routes.jsx | 6 + .../routes/users/permissionGroupsViewer.js | 2 +- .../DataFetchingTable/DataFetchingTable.jsx | 2 +- packages/admin-panel/src/theme/colors.js | 9 +- packages/admin-panel/src/theme/theme.js | 9 +- packages/admin-panel/src/usedBy/UsedBy.jsx | 2 +- .../src/utilities/StoreProvider.jsx | 39 ++---- .../src/utilities/getHasBESAdminAccess.js | 7 ++ .../admin-panel/src/widgets/PageHeader.jsx | 1 - .../api/mutations/useRequestResetPassword.ts | 2 +- packages/lesmis/src/routes/AdminPanelApp.jsx | 87 +++++-------- .../lesmis/src/routes/LesmisAdminRedirect.jsx | 8 +- .../views/AdminPanel/AdminPanelLoginPage.jsx | 14 +-- .../AdminPanel/AdminPanelProfileButton.jsx | 27 ---- .../AdminPanel/authentication/actions.js | 90 ++++++++------ .../src/views/AdminPanel/pages/LoginPage.jsx | 105 +++------------- .../src/orchestrator/api/ApiBuilder.ts | 8 +- .../src/orchestrator/auth/AuthConnection.ts | 9 +- .../routes/RequestResetPasswordRoute.ts | 30 +++++ .../src/orchestrator/routes/index.ts | 4 + .../src/orchestrator/types.ts | 5 + .../tupaia-web-server/src/app/createApp.ts | 1 - .../api/mutations/useRequestResetPassword.ts | 2 +- packages/ui-components/src/constants.js | 8 ++ .../src/features/Auth/AuthLink.tsx | 1 + .../src/features/Auth/ForgotPasswordForm.tsx | 9 +- .../src/features/Auth/LoginForm.tsx | 49 ++++++-- .../Auth/ResetPasswordForm/PasswordForm.tsx | 2 +- .../ui-components/src/features/Auth/index.ts | 1 + packages/web-config-server/src/apiV1/index.js | 9 +- .../handlers/requestResetPassword.js | 9 -- .../web-config-server/src/appServer/index.js | 8 +- .../web-config-server/src/appServer/routes.js | 6 - 85 files changed, 911 insertions(+), 1089 deletions(-) delete mode 100644 packages/admin-panel/src/VizBuilderApp/api/queries/useUser.js create mode 100644 packages/admin-panel/src/api/mutations/index.js create mode 100644 packages/admin-panel/src/api/mutations/useLogin.js create mode 100644 packages/admin-panel/src/api/mutations/useLogout.js create mode 100644 packages/admin-panel/src/api/mutations/useOneTimeLogin.js create mode 100644 packages/admin-panel/src/api/mutations/useRequestResetPassword.js create mode 100644 packages/admin-panel/src/api/mutations/useResetPassword.js create mode 100644 packages/admin-panel/src/api/mutations/useUpdateProfile.js create mode 100644 packages/admin-panel/src/api/queries/index.js create mode 100644 packages/admin-panel/src/api/queries/useUser.js delete mode 100644 packages/admin-panel/src/authentication/LoginForm.jsx delete mode 100644 packages/admin-panel/src/authentication/ProfileButton.jsx create mode 100644 packages/admin-panel/src/authentication/RegisterLink.jsx delete mode 100644 packages/admin-panel/src/authentication/reducer.js delete mode 100644 packages/admin-panel/src/authentication/selectors.js create mode 100644 packages/admin-panel/src/layout/AuthLayout.jsx create mode 100644 packages/admin-panel/src/layout/SimplePageLayout.jsx rename packages/admin-panel/src/{VizBuilderApp/components/NavPanel.jsx => layout/navigation/TopNavbar.jsx} (51%) rename packages/admin-panel/src/layout/navigation/{UserLink.jsx => UserButton.jsx} (54%) create mode 100644 packages/admin-panel/src/pages/ForgotPasswordPage.jsx delete mode 100644 packages/admin-panel/src/pages/LogoutPage.jsx create mode 100644 packages/admin-panel/src/pages/ResetPasswordPage.jsx create mode 100644 packages/admin-panel/src/utilities/getHasBESAdminAccess.js delete mode 100644 packages/lesmis/src/views/AdminPanel/AdminPanelProfileButton.jsx create mode 100644 packages/server-boilerplate/src/orchestrator/routes/RequestResetPasswordRoute.ts delete mode 100644 packages/web-config-server/src/appServer/handlers/requestResetPassword.js diff --git a/packages/admin-panel/src/App.jsx b/packages/admin-panel/src/App.jsx index ea66ae5974..7663270a4a 100644 --- a/packages/admin-panel/src/App.jsx +++ b/packages/admin-panel/src/App.jsx @@ -3,17 +3,17 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import React from 'react'; -import PropTypes from 'prop-types'; import { Navigate, Route, Routes } from 'react-router-dom'; -import { connect } from 'react-redux'; -import { AppPageLayout, Footer } from './layout'; -import { ROUTES } from './routes'; +import { AppPageLayout, AuthLayout, Footer } from './layout'; +import { AUTH_ROUTES, ROUTES } from './routes'; import { PROFILE_ROUTES } from './profileRoutes'; -import { getHasBESAdminAccess, getUser, PrivateRoute } from './authentication'; +import { PrivateRoute } from './authentication'; import { LoginPage } from './pages/LoginPage'; -import { LogoutPage } from './pages/LogoutPage'; import { ResourcePage } from './pages/resources/ResourcePage'; import { TabPageLayout } from './layout/TabPageLayout'; +import { useUser } from './api/queries'; +import { getHasBESAdminAccess } from './utilities/getHasBESAdminAccess'; +import { ForgotPasswordPage, ResetPasswordPage } from './pages'; export const getFlattenedChildViews = (route, basePath = '') => { return route.childViews.reduce((acc, childView) => { @@ -45,7 +45,9 @@ export const getFlattenedChildViews = (route, basePath = '') => { }, []); }; -export const App = ({ user, hasBESAdminAccess }) => { +const App = () => { + const { data: user } = useUser(); + const hasBESAdminAccess = getHasBESAdminAccess(user); const userHasAccessToTab = tab => { if (tab.isBESAdminOnly) { return !!hasBESAdminAccess; @@ -69,13 +71,15 @@ export const App = ({ user, hasBESAdminAccess }) => { const accessibleRoutes = getAccessibleRoutes(); return ( - } /> - } /> + }> + } /> + } /> + } /> + }> @@ -117,24 +121,4 @@ export const App = ({ user, hasBESAdminAccess }) => { ); }; -App.defaultProps = { - hasBESAdminAccess: false, -}; - -App.propTypes = { - user: PropTypes.shape({ - name: PropTypes.string.isRequired, - email: PropTypes.string.isRequired, - firstName: PropTypes.string, - profileImage: PropTypes.string, - }).isRequired, - hasBESAdminAccess: PropTypes.bool, -}; - -export default connect( - state => ({ - user: getUser(state), - hasBESAdminAccess: getHasBESAdminAccess(state), - }), - null, -)(App); +export default App; diff --git a/packages/admin-panel/src/VizBuilderApp/App.jsx b/packages/admin-panel/src/VizBuilderApp/App.jsx index 5030c74932..25ae9c595b 100644 --- a/packages/admin-panel/src/VizBuilderApp/App.jsx +++ b/packages/admin-panel/src/VizBuilderApp/App.jsx @@ -10,18 +10,10 @@ import { matchRoutes } from 'react-router-dom'; import { FullPageLoader } from '@tupaia/ui-components'; import { Main } from './views/Main'; import { CreateNew } from './views/CreateNew'; -import { useUser } from './api/queries'; import { VizConfigProvider as StateProvider } from './context'; import { useVizBuilderBasePath } from './utils'; -import { NavPanel } from './components'; - -const Wrapper = styled.main` - display: flex; - flex-direction: column; - background: ${props => props.theme.palette.background.default}; - height: 100vh; - overflow: hidden; -`; +import { SimplePageLayout } from '../layout'; +import { useUser } from '../api/queries'; const Container = styled.div` flex: 1; @@ -62,15 +54,13 @@ export const App = ({ Footer, homeLink, logo }) => { return ( - - - + {/** Workaround for handling issues with this nested app */} {renderMatches(matches)} {Footer &&