From d92a2d2d0ee865df6f05e165276722effcdc06a9 Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Wed, 28 Aug 2024 12:59:00 -0400 Subject: [PATCH 1/5] Use sourcemaps for SRC instead of a development build Requires SRC update --- src/main/webapp/Portal.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/Portal.html b/src/main/webapp/Portal.html index e50886e131..c672c0a307 100644 --- a/src/main/webapp/Portal.html +++ b/src/main/webapp/Portal.html @@ -134,17 +134,14 @@ ) loadCss('https://fonts.googleapis.com/icon?family=Material+Icons') - let reactPath, reactDomPath, srcPath + let reactPath, reactDomPath if (processEnvironment === 'production') { reactPath = cdnEndpoint + 'generated/react.production.min.js' reactDomPath = cdnEndpoint + 'generated/react-dom.production.min.js' - srcPath = - cdnEndpoint + 'generated/synapse-react-client.production.min.js' } else { reactPath = cdnEndpoint + 'generated/react.development.js' reactDomPath = cdnEndpoint + 'generated/react-dom.development.js' - srcPath = cdnEndpoint + 'generated/synapse-react-client.development.js' } // TODO: Workaround for SWC-6664 @@ -196,7 +193,7 @@ loadJs(cdnEndpoint + 'generated/react-router-dom.min.js') loadJs(cdnEndpoint + 'generated/universalCookie.min.js') loadJs(cdnEndpoint + 'generated/react-bootstrap.min.js') - loadJs(srcPath) // We don't load SRC's scss because we include it in our own compiled scss + loadJs(cdnEndpoint + 'generated/synapse-react-client.production.min.js') // We don't load SRC's scss because we include it in our own compiled scss loadJs(cdnEndpoint + 'generated/croppie.min.js') loadCss(cdnEndpoint + 'js/diff/diffview.css') loadCss(cdnEndpoint + 'generated/croppie.css') From 7ea619164f5f55ee0556de9b92efe1828bd17b07 Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Thu, 29 Aug 2024 16:34:27 -0400 Subject: [PATCH 2/5] SWC-7038 - Fix regression that causes a race condition when a component is rendered, destroyed, then rendered synchronously. --- .../web/client/widget/ReactComponent.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java b/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java index d125fbdca8..c16d671ca5 100644 --- a/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java +++ b/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java @@ -175,14 +175,17 @@ protected void onLoad() { @Override protected void onUnload() { super.onUnload(); - if (root != null) { - // Asynchronously schedule unmounting the root to allow React to finish the current render cycle. - // https://github.com/facebook/react/issues/25675 + ReactDOMRoot rootToUnmount = this.root; + // Immediately unbind this.root so synchronous attempts to re-render succeed + this.root = null; + + // Asynchronously schedule unmounting the old root to allow React to finish a render cycle that might be in progress. + // https://github.com/facebook/react/issues/25675 + if (rootToUnmount != null) { Timer t = new Timer() { @Override public void run() { - root.unmount(); - root = null; + rootToUnmount.unmount(); } }; t.schedule(0); From 74d0873a9323ff4a2176dd5bccc5bc4826cda2ce Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Thu, 29 Aug 2024 16:37:29 -0400 Subject: [PATCH 3/5] SWC-7038 - Upgrade synapse-react-client to v3.3.10 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ca21b2954d..0ad8054459 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "react-transition-group": "2.6.0", "sass": "^1.63.6", "spark-md5": "^3.0.2", - "synapse-react-client": "3.3.9", + "synapse-react-client": "3.3.10", "universal-cookie": "^4.0.4", "xss": "^1.0.15" }, diff --git a/yarn.lock b/yarn.lock index 8fb8753efb..cf53641ace 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5924,10 +5924,10 @@ svg-path-sdf@^1.1.3: parse-svg-path "^0.1.2" svg-path-bounds "^1.0.1" -synapse-react-client@3.3.9: - version "3.3.9" - resolved "https://registry.yarnpkg.com/synapse-react-client/-/synapse-react-client-3.3.9.tgz#ac59c8823d3d193bceffd674fb0b6da0b3564275" - integrity sha512-IbHV1a4DERpVe3QsNYtsgRFaGhn/CWVCJW+1e2/HIO7ZgKsu1lSsmV7yR//ZPKmR0PuRgI0IndJnFEl24mI12Q== +synapse-react-client@3.3.10: + version "3.3.10" + resolved "https://registry.yarnpkg.com/synapse-react-client/-/synapse-react-client-3.3.10.tgz#71c7fff7904d07d44d832ca78ed7c1ad9169fd6e" + integrity sha512-Wm+T4bBZBvXMfxh8+59EV76yAyp+2693XUwx3PNBMHK4x1wTMc2H6D8NVAWDQqyKvg3nk0BSQ+GrH9eQiNOkqQ== dependencies: "@apidevtools/json-schema-ref-parser" "^9.1.2" "@brainhubeu/react-carousel" "1.19.26" From d8211e6cfeaaf423d3149abac3a33b92542f73eb Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Thu, 29 Aug 2024 17:05:13 -0400 Subject: [PATCH 4/5] SWC-7038 - React component render should also be scheduled --- .../web/client/widget/ReactComponent.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java b/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java index c16d671ca5..32f37cc582 100644 --- a/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java +++ b/src/main/java/org/sagebionetworks/web/client/widget/ReactComponent.java @@ -143,15 +143,22 @@ private void injectChildWidgetsIntoComponent() { public void render(ReactElement reactElement) { this.reactElement = reactElement; - maybeCreateRoot(); injectChildWidgetsIntoComponent(); // This component may be a React child of another component. If so, we must rerender the ancestor component(s) so // that they use the new ReactElement created in this render step. ReactComponent componentToRender = getRootReactComponentWidget(); if (componentToRender == this) { - // Resynchronize with the DOM - root.render(this.reactElement); + // Asynchronously schedule creating a root in case React is still rendering and may unmount the current root + Timer t = new Timer() { + @Override + public void run() { + maybeCreateRoot(); + // Resynchronize with the DOM + root.render(reactElement); + } + }; + t.schedule(0); } else { // Walk up the tree to the parent and repeat rerendering componentToRender.rerender(); @@ -175,17 +182,14 @@ protected void onLoad() { @Override protected void onUnload() { super.onUnload(); - ReactDOMRoot rootToUnmount = this.root; - // Immediately unbind this.root so synchronous attempts to re-render succeed - this.root = null; - - // Asynchronously schedule unmounting the old root to allow React to finish a render cycle that might be in progress. - // https://github.com/facebook/react/issues/25675 - if (rootToUnmount != null) { + if (root != null) { + // Asynchronously schedule unmounting the root to allow React to finish the current render cycle. + // https://github.com/facebook/react/issues/25675 Timer t = new Timer() { @Override public void run() { - rootToUnmount.unmount(); + root.unmount(); + root = null; } }; t.schedule(0); From 698950f2a1856b57521d83c421e4554d7d8f4af9 Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Thu, 29 Aug 2024 17:05:27 -0400 Subject: [PATCH 5/5] SWC-7038 - Update e2e for error page --- e2e/files.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/files.spec.ts b/e2e/files.spec.ts index db737567dc..173808da90 100644 --- a/e2e/files.spec.ts +++ b/e2e/files.spec.ts @@ -52,12 +52,12 @@ const expectNoAccessPage = async ( expectTimeout: number = defaultExpectTimeout, ) => { await expect( - page.getByRole('heading', { - name: 'Sorry, no access to this page.', - }), + page.getByText('You don’t have permission to view this.'), ).toBeVisible({ timeout: expectTimeout }) await expect( - page.getByText('You are not authorized to access the page requested.'), + page.getByText( + 'This account has not been granted access to view this resource.', + ), ).toBeVisible({ timeout: expectTimeout }) }