This is an automated email from the ASF dual-hosted git repository.

porcelli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 3f54f35fa4e kie-issues#337: KIE Sandbox shows a blank page in Firefox 
(#2397)
3f54f35fa4e is described below

commit 3f54f35fa4e6621f81dad7e9ee96f3604923a9ee
Author: Thiago Lugli <[email protected]>
AuthorDate: Mon Jun 3 18:56:16 2024 -0300

    kie-issues#337: KIE Sandbox shows a blank page in Firefox (#2397)
---
 packages/online-editor/src/App.tsx                 |  2 ++
 packages/online-editor/src/index.tsx               |  9 ++-------
 .../startupBlockers/IncompatibleBrowser.tsx        |  4 ++--
 .../startupBlockers/StartupBlockerProvider.tsx}    | 23 ++++++++++------------
 4 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/packages/online-editor/src/App.tsx 
b/packages/online-editor/src/App.tsx
index 8593c808950..5074a4c74d0 100644
--- a/packages/online-editor/src/App.tsx
+++ b/packages/online-editor/src/App.tsx
@@ -40,6 +40,7 @@ import { AuthSessionsContextProvider } from 
"./authSessions/AuthSessionsContext"
 import { AccountsContextProvider } from "./accounts/AccountsContext";
 import { GlobalAlertsContextProvider } from "./alerts";
 import { WorkspacesContextProviderWithCustomCommitMessagesModal } from 
"./workspace/components/WorkspacesContextProviderWithCustomCommitMessagesModal";
+import { StartupBlockerProvider } from 
"./workspace/startupBlockers/StartupBlockerProvider";
 
 export function App() {
   return (
@@ -47,6 +48,7 @@ export function App() {
       {nest(
         [OnlineI18nContextProvider, {}],
         [EnvContextProvider, {}],
+        [StartupBlockerProvider, {}],
         [EditorEnvelopeLocatorContextProvider, {}],
         [SettingsContextProvider, {}],
         [ExtendedServicesContextProvider, {}],
diff --git a/packages/online-editor/src/index.tsx 
b/packages/online-editor/src/index.tsx
index 5a3d5d16a66..2dc1af6abf6 100644
--- a/packages/online-editor/src/index.tsx
+++ b/packages/online-editor/src/index.tsx
@@ -22,16 +22,11 @@ import * as React from "react";
 import * as ReactDOM from "react-dom";
 import { App } from "./App";
 import "../static/resources/style.css";
-import * as incompatibleBrowser from 
"./workspace/startupBlockers/IncompatibleBrowser";
 
 async function main() {
   const appContainer = document.getElementById("app")!;
-
-  if (await incompatibleBrowser.isTrue()) {
-    ReactDOM.render(<incompatibleBrowser.Component />, appContainer);
-  } else {
-    ReactDOM.render(<App />, appContainer);
-  }
+  // eslint-disable-next-line react/no-deprecated
+  ReactDOM.render(<App />, appContainer);
 }
 
 main();
diff --git 
a/packages/online-editor/src/workspace/startupBlockers/IncompatibleBrowser.tsx 
b/packages/online-editor/src/workspace/startupBlockers/IncompatibleBrowser.tsx
index 18c12b93f29..e2ea3fdcc98 100644
--- 
a/packages/online-editor/src/workspace/startupBlockers/IncompatibleBrowser.tsx
+++ 
b/packages/online-editor/src/workspace/startupBlockers/IncompatibleBrowser.tsx
@@ -40,7 +40,7 @@ const isCompatibleBrowser = 
Bowser.getParser(window.navigator.userAgent).satisfi
 });
 const browserInfo = Bowser.parse(window.navigator.userAgent);
 
-export async function isTrue() {
+export function isTrue() {
   return !hasNecessaryApis || !isCompatibleBrowser;
 }
 
@@ -52,7 +52,7 @@ export function Component() {
         <br />
         <TextContent>
           <Text component={TextVariants.h4}>
-            ${env.KIE_SANDBOX_APP_NAME} is not compatible with this browser.{" 
"}
+            {env.KIE_SANDBOX_APP_NAME} is not compatible with this browser.{" 
"}
             <small style={{ display: "inline" }}>
               ({browserInfo.browser.name} {browserInfo.browser.version})
             </small>
diff --git a/packages/online-editor/src/index.tsx 
b/packages/online-editor/src/workspace/startupBlockers/StartupBlockerProvider.tsx
similarity index 62%
copy from packages/online-editor/src/index.tsx
copy to 
packages/online-editor/src/workspace/startupBlockers/StartupBlockerProvider.tsx
index 5a3d5d16a66..1889664aa30 100644
--- a/packages/online-editor/src/index.tsx
+++ 
b/packages/online-editor/src/workspace/startupBlockers/StartupBlockerProvider.tsx
@@ -17,21 +17,18 @@
  * under the License.
  */
 
-import "@patternfly/react-core/dist/styles/base.css";
 import * as React from "react";
-import * as ReactDOM from "react-dom";
-import { App } from "./App";
-import "../static/resources/style.css";
-import * as incompatibleBrowser from 
"./workspace/startupBlockers/IncompatibleBrowser";
+import * as incompatibleBrowser from "./IncompatibleBrowser";
 
-async function main() {
-  const appContainer = document.getElementById("app")!;
+interface Props {
+  children: React.ReactNode;
+}
+
+const isIncompatibleBrowser = incompatibleBrowser.isTrue();
 
-  if (await incompatibleBrowser.isTrue()) {
-    ReactDOM.render(<incompatibleBrowser.Component />, appContainer);
-  } else {
-    ReactDOM.render(<App />, appContainer);
+export function StartupBlockerProvider(props: Props) {
+  if (isIncompatibleBrowser) {
+    return <incompatibleBrowser.Component />;
   }
+  return <>{props.children}</>;
 }
-
-main();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to