Skip to content

Feature/error boundary #1011

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

Merged
merged 7 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
error boundary part 1
  • Loading branch information
MenamAfzal committed Jul 4, 2024
commit 69b117f09ab456528eff001a91238fcdee483b20
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
321 changes: 238 additions & 83 deletions client/packages/lowcoder/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { SystemWarning } from "./components/SystemWarning";
import { getBrandingConfig } from "./redux/selectors/configSelectors";
import { buildMaterialPreviewURL } from "./util/materialUtils";
import GlobalInstances from 'components/GlobalInstances';
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';

const LazyUserAuthComp = React.lazy(() => import("pages/userAuth"));
const LazyInviteLanding = React.lazy(() => import("pages/common/inviteLanding"));
Expand Down Expand Up @@ -89,18 +90,34 @@ type AppIndexProps = {
};

class AppIndex extends React.Component<AppIndexProps, any> {
constructor(props: any) {
super(props);
this.state = {error: null};
}
componentDidMount() {
this.props.getCurrentUser();
}

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);
}
}

updateError = () => {
this.state.error('known');
};
fallbackRender = ({error, resetErrorBoundary}: FallbackProps) => {
return <div role="alert">
<h3>Error Boundary</h3>
<p>Something went wrong.</p>
<button onClick={resetErrorBoundary}>Reset</button>
</div>;
};
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 @@ -122,56 +139,157 @@ 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>

{/*
<ErrorBoundary
fallbackRender={this.fallbackRender}
onReset={(details) => {
this.state.error(null);
}}
>
<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 @@ -184,55 +302,92 @@ 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>
</ErrorBoundary>
</Wrapper>
);
}
Expand Down Expand Up @@ -267,7 +422,7 @@ export function bootstrap() {
const root = createRoot(container!);
root.render(
<Provider store={reduxStore}>
<AppIndexWithProps />
<AppIndexWithProps />
</Provider>
);
}
Loading