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

Feature/error boundary #1011

Merged
merged 7 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions client/packages/lowcoder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"react-documents": "^1.2.1",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.4",
"react-error-boundary": "^4.0.13",
"react-grid-layout": "^1.3.0",
"react-helmet": "^6.1.0",
"react-joyride": "^2.4.0",
Expand Down
299 changes: 216 additions & 83 deletions client/packages/lowcoder/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ class AppIndex extends React.Component<AppIndexProps, any> {
}

componentDidUpdate(prevProps: AppIndexProps) {
if(prevProps.currentOrgId !== this.props.currentOrgId && this.props.currentOrgId !== '') {
if (
prevProps.currentOrgId !== this.props.currentOrgId &&
this.props.currentOrgId !== ''
) {
this.props.fetchConfig(this.props.currentOrgId);
}
}

render() {
const isTemplate = hasQueryParam("template");
const isTemplate = hasQueryParam('template');
const pathname = history.location.pathname;

// we check if we are on the public cloud
Expand All @@ -126,56 +128,151 @@ class AppIndex extends React.Component<AppIndexProps, any> {
<Helmet>
{<title>{this.props.brandName}</title>}
{<link rel="icon" href={this.props.favicon} />}
<meta name="description" content={trans("productDesc")} />
<meta name="keywords" content="Lowcoder, Applications, App Builder, Internal Applications, Websites, Dashboards, Data Visualization, Customer Applications, CRM, ERP, eCommerce, VideoMeeting, Rapid Development" />
<meta name="description" content={trans('productDesc')} />
<meta
name="keywords"
content="Lowcoder, Applications, App Builder, Internal Applications, Websites, Dashboards, Data Visualization, Customer Applications, CRM, ERP, eCommerce, VideoMeeting, Rapid Development"
/>
<meta name="author" content="Lowcoder Software LTD" />
<meta name="robots" content="index, follow" />


<meta key="og:title" property="og:title" content={this.props.brandName} />
<meta key="og:description" property="og:description" content={trans("productDesc")} />
<meta key="og:image" property="og:image" content="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/App%20Editor%20%7C%20Main%20Screeen%20clean%20v2.4.0.png" />
<meta
key="og:title"
property="og:title"
content={this.props.brandName}
/>
<meta
key="og:description"
property="og:description"
content={trans('productDesc')}
/>
<meta
key="og:image"
property="og:image"
content="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/App%20Editor%20%7C%20Main%20Screeen%20clean%20v2.4.0.png"
/>
<meta key="og:url" property="og:url" content={window.location.href} />
<meta key="og:type" property="og:type" content="website" />

<meta key="twitter:card" name="twitter:card" content="summary_large_image" />
<meta key="twitter:title" name="twitter:title" content={this.props.brandName} />
<meta key="twitter:description" name="twitter:description" content={trans("productDesc")} />
<meta key="twitter:image" name="twitter:image" content="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/App%20Editor%20%7C%20Main%20Screeen%20clean%20v2.4.0.png" />
<meta
key="twitter:card"
name="twitter:card"
content="summary_large_image"
/>
<meta
key="twitter:title"
name="twitter:title"
content={this.props.brandName}
/>
<meta
key="twitter:description"
name="twitter:description"
content={trans('productDesc')}
/>
<meta
key="twitter:image"
name="twitter:image"
content="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/App%20Editor%20%7C%20Main%20Screeen%20clean%20v2.4.0.png"
/>

<meta key="viewport" name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta key="mobile-web-app-capable" name="mobile-web-app-capable" content="yes" />
<meta
key="viewport"
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta
key="mobile-web-app-capable"
name="mobile-web-app-capable"
content="yes"
/>
<meta key="theme-color" name="theme-color" content="#b480de" />

<meta key="apple-mobile-web-app-capable" name="apple-mobile-web-app-capable" content="yes" />
<meta key="apple-mobile-web-app-status-bar-style" name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta key="apple-mobile-web-app-title" name="apple-mobile-web-app-title" content={this.props.brandName} />
<link key="apple-touch-icon" rel="apple-touch-icon" href="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/Lowcoder%20Logo%20512.png" />
<link key="apple-touch-startup-image" rel="apple-touch-startup-image" href="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/Lowcoder%20Logo%20512.png" />
<meta
key="apple-mobile-web-app-capable"
name="apple-mobile-web-app-capable"
content="yes"
/>
<meta
key="apple-mobile-web-app-status-bar-style"
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
<meta
key="apple-mobile-web-app-title"
name="apple-mobile-web-app-title"
content={this.props.brandName}
/>
<link
key="apple-touch-icon"
rel="apple-touch-icon"
href="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/Lowcoder%20Logo%20512.png"
/>
<link
key="apple-touch-startup-image"
rel="apple-touch-startup-image"
href="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/Lowcoder%20Logo%20512.png"
/>

<meta key="application-name" name="application-name" content={this.props.brandName} />
<meta key="msapplication-TileColor" name="msapplication-TileColor" content="#b480de" />
<meta key="msapplication-TileImage" name="msapplication-TileImage" content="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/Lowcoder%20Logo%20150.png" />
<meta
key="application-name"
name="application-name"
content={this.props.brandName}
/>
<meta
key="msapplication-TileColor"
name="msapplication-TileColor"
content="#b480de"
/>
<meta
key="msapplication-TileImage"
name="msapplication-TileImage"
content="https://raw.githubusercontent.com/lowcoder-org/lowcoder-media-assets/main/images/Lowcoder%20Logo%20150.png"
/>
{/* }<meta key="msapplication-config" name="msapplication-config" content="https://www.yourdomain.com/path/to/browserconfig.xml" />, */}

<link rel="canonical" href={window.location.href} />
{isLowCoderDomain && [
// Adding Support for iframely to be able to embedd the component explorer in the docu
<meta key="iframely:title" property="iframely:title" content={this.props.brandName} />,
<meta key="iframely:description" property="iframely:description" content={trans("productDesc")} />,
<meta
key="iframely:title"
property="iframely:title"
content={this.props.brandName}
/>,
<meta
key="iframely:description"
property="iframely:description"
content={trans('productDesc')}
/>,

<link key="preconnect-googleapis" rel="preconnect" href="https://fonts.googleapis.com" />,
<link key="preconnect-gstatic" rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />,
<link key="font-ubuntu" href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet" />,
<link
key="preconnect-googleapis"
rel="preconnect"
href="https://fonts.googleapis.com"
/>,
<link
key="preconnect-gstatic"
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="anonymous"
/>,
<link
key="font-ubuntu"
href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,700;1,400&display=swap"
rel="stylesheet"
/>,
// adding Clearbit Support for Analytics
<script key="clearbit-script" src="https://tag.clearbitscripts.com/v1/pk_dfbc0aeefb28dc63475b67134facf127/tags.js" referrerPolicy="strict-origin-when-cross-origin" type="text/javascript"></script>
<script
key="clearbit-script"
src="https://tag.clearbitscripts.com/v1/pk_dfbc0aeefb28dc63475b67134facf127/tags.js"
referrerPolicy="strict-origin-when-cross-origin"
type="text/javascript"
></script>,
]}
</Helmet>
<SystemWarning />
<Router history={history}>
<Switch>

{/*
<Router history={history}>
<Switch>
{/*
// we decided to show the org homepage in a own navigation page
{!this.props.orgDev && !!this.props.defaultHomePage ? (
<Redirect exact from={BASE_URL} to={APPLICATION_VIEW_URL(this.props.defaultHomePage, "view")}
Expand All @@ -188,55 +285,91 @@ class AppIndex extends React.Component<AppIndexProps, any> {
/>
)} */}

{!this.props.orgDev ? (
<Redirect exact from={BASE_URL} to={ORG_HOME_URL} />
) : (
<Redirect exact from={BASE_URL} to={ALL_APPLICATIONS_URL} />
)}

<LazyRoute exact path={IMPORT_APP_FROM_TEMPLATE_URL} component={LazyAppFromTemplate} />
<LazyRoute fallback="layout" path={APP_EDITOR_URL} component={LazyAppEditor} />
<LazyRoute
fallback="layout"
path={[
USER_PROFILE_URL,
NEWS_URL,
ORG_HOME_URL,
ALL_APPLICATIONS_URL,
DATASOURCE_CREATE_URL,
DATASOURCE_EDIT_URL,
DATASOURCE_URL,
QUERY_LIBRARY_URL,
FOLDERS_URL,
FOLDER_URL,
TRASH_URL,
SETTING,
MARKETPLACE_URL,
ADMIN_APP_URL,
API_DOCS_URL,
]}
// component={ApplicationListPage}
component={LazyApplicationHome}
/>
<LazyRoute path={USER_AUTH_URL} component={LazyUserAuthComp} />
<LazyRoute path={ORG_AUTH_LOGIN_URL} component={LazyUserAuthComp} />
<LazyRoute path={ORG_AUTH_REGISTER_URL} component={LazyUserAuthComp} />
<LazyRoute path={ORG_AUTH_FORGOT_PASSWORD_URL} component={LazyUserAuthComp} />
<LazyRoute path={ORG_AUTH_RESET_PASSWORD_URL} component={LazyUserAuthComp} />
<LazyRoute path={INVITE_LANDING_URL} component={LazyInviteLanding} />
<LazyRoute path={`${COMPONENT_DOC_URL}/:name`} component={LazyComponentDoc} />
<LazyRoute path={`/playground/:name/:dsl`} component={LazyComponentPlayground} />
<Redirect to={`${COMPONENT_DOC_URL}/input`} path="/components" />
{developEnv() && (
<>
<LazyRoute path="/debug_comp/:name" component={LazyDebugComp} />
<LazyRoute exact path="/debug_comp" component={LazyDebugComp} />
<LazyRoute path="/debug_editor" component={LazyAppEditor} />
<LazyRoute path="/debug_new" component={LazyDebugNewComp} />
</>
)}
</Switch>
</Router>
{!this.props.orgDev ? (
<Redirect exact from={BASE_URL} to={ORG_HOME_URL} />
) : (
<Redirect exact from={BASE_URL} to={ALL_APPLICATIONS_URL} />
)}

<LazyRoute
exact
path={IMPORT_APP_FROM_TEMPLATE_URL}
component={LazyAppFromTemplate}
/>
<LazyRoute
fallback="layout"
path={APP_EDITOR_URL}
component={LazyAppEditor}
/>
<LazyRoute
fallback="layout"
path={[
USER_PROFILE_URL,
NEWS_URL,
ORG_HOME_URL,
ALL_APPLICATIONS_URL,
DATASOURCE_CREATE_URL,
DATASOURCE_EDIT_URL,
DATASOURCE_URL,
QUERY_LIBRARY_URL,
FOLDERS_URL,
FOLDER_URL,
TRASH_URL,
SETTING,
MARKETPLACE_URL,
ADMIN_APP_URL,
API_DOCS_URL,
]}
// component={ApplicationListPage}
component={LazyApplicationHome}
/>
<LazyRoute path={USER_AUTH_URL} component={LazyUserAuthComp} />
<LazyRoute
path={ORG_AUTH_LOGIN_URL}
component={LazyUserAuthComp}
/>
<LazyRoute
path={ORG_AUTH_REGISTER_URL}
component={LazyUserAuthComp}
/>
<LazyRoute
path={ORG_AUTH_FORGOT_PASSWORD_URL}
component={LazyUserAuthComp}
/>
<LazyRoute
path={ORG_AUTH_RESET_PASSWORD_URL}
component={LazyUserAuthComp}
/>
<LazyRoute
path={INVITE_LANDING_URL}
component={LazyInviteLanding}
/>
<LazyRoute
path={`${COMPONENT_DOC_URL}/:name`}
component={LazyComponentDoc}
/>
<LazyRoute
path={`/playground/:name/:dsl`}
component={LazyComponentPlayground}
/>
<Redirect to={`${COMPONENT_DOC_URL}/input`} path="/components" />
{developEnv() && (
<>
<LazyRoute
path="/debug_comp/:name"
component={LazyDebugComp}
/>
<LazyRoute
exact
path="/debug_comp"
component={LazyDebugComp}
/>
<LazyRoute path="/debug_editor" component={LazyAppEditor} />
<LazyRoute path="/debug_new" component={LazyDebugNewComp} />
</>
)}
</Switch>
</Router>
</Wrapper>
);
}
Expand Down Expand Up @@ -271,7 +404,7 @@ export function bootstrap() {
const root = createRoot(container!);
root.render(
<Provider store={reduxStore}>
<AppIndexWithProps />
<AppIndexWithProps />
</Provider>
);
}
13 changes: 10 additions & 3 deletions client/packages/lowcoder/src/pages/editor/AppEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import { fetchFolderElements } from "redux/reduxActions/folderActions";
import { registryDataSourcePlugin } from "constants/queryConstants";
import { DatasourceApi } from "api/datasourceApi";
import { useRootCompInstance } from "./useRootCompInstance";
import ErrorBoundary from "antd/es/alert/ErrorBoundary";
import EditorSkeletonView from "./editorSkeletonView";
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL";
import history from "util/history";

const AppSnapshot = lazy(() => {
return import("pages/editor/appSnapshot")
Expand Down Expand Up @@ -133,9 +135,14 @@ export default function AppEditor() {
})
);
}, [viewMode, applicationId, dispatch]);

const fallbackUI = (
<div style={{display:'flex', height:'100%', width:'100%', alignItems:'center',justifyContent:'center', gap:'8px',marginTop:'10px'}}>
<p style={{margin:0}}>Something went wrong while displaying this webpage</p>
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Go to Apps</button>
</div>
);
return (
<ErrorBoundary>
<ErrorBoundary fallback={fallbackUI}>
{showAppSnapshot ? (
<Suspense fallback={<EditorSkeletonView />}>
<AppSnapshot
Expand Down
Loading
Loading