Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"react": "17.0.2",
"react-children-utilities": "^2.8.0",
"react-dom": "17.0.2",
"react-error-boundary": "^4.0.10",
"react-redux": "7.2.6",
"react-remark": "^2.1.0",
"redux-mock-store": "^1.5.4",
Expand Down
69 changes: 51 additions & 18 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "antd/dist/antd.less";
import "antd/lib/style/themes/default.less";

import Layout, { Content, Header } from "antd/lib/layout/layout";
import { Alert, Button } from "antd";
import { Backdrop } from "./components/Backdrop";
import { pageType } from "../common/constants/constants";
import { StatusBar } from "./components/StatusBar";
Expand All @@ -22,6 +23,26 @@ import { BackendStatus } from "./types/mainSlice.types";
import { LocatorsPage } from "../features/locators/LocatorsPage";
import { PageObjectPage } from "../features/pageObjects/PageObjectPage";
import { OnboardingProvider } from "../features/onboarding/OnboardingProvider";
import { ErrorBoundary } from "react-error-boundary";
// import ErrorBoundary from "antd/lib/alert/ErrorBoundary";

// const { ErrorBoundary } = Alert;

const ThrowError: React.FC = () => {
const [error, setError] = useState<Error>();
const onClick = () => {
setError(new Error("An Uncaught Error"));
};

if (error) {
throw error;
}
return (
<Button danger onClick={onClick}>
Click me to throw a error
</Button>
);
};

const App = () => {
const [isInvalidSession, setIsInvalidSession] = useState(false);
Expand Down Expand Up @@ -55,25 +76,37 @@ const App = () => {

return (
<div>
<Backdrop />
<Layout className="jdn__app">
<Header className="jdn__header">
<StatusBar />
</Header>
<Content className="jdn__content">
{backendAvailable === BackendStatus.Accessed ? (
isInvalidSession ? (
<SeveralTabsWarning {...{ checkSession: () => checkSession(setIsInvalidSession) }} />
<ErrorBoundary
fallback={
<Alert
message="Error"
description="Something went wrong. Try to reload plugin or contact the developer."
type="error"
showIcon
/>
}
>
<ThrowError />
<Backdrop />
<Layout className="jdn__app">
<Header className="jdn__header">
<StatusBar />
</Header>
<Content className="jdn__content">
{backendAvailable === BackendStatus.Accessed ? (
isInvalidSession ? (
<SeveralTabsWarning {...{ checkSession: () => checkSession(setIsInvalidSession) }} />
) : (
renderPage()
)
) : backendAvailable === BackendStatus.TryToAccess ? (
BackendStatus.TryToAccess
) : (
renderPage()
)
) : backendAvailable === BackendStatus.TryToAccess ? (
BackendStatus.TryToAccess
) : (
<Guide />
)}
</Content>
</Layout>
<Guide />
)}
</Content>
</Layout>
</ErrorBoundary>
</div>
);
};
Expand Down