Add error boundary to segments/segments.jsx
[MAILPOET-4706]
This commit is contained in:
@ -10,7 +10,7 @@ import {
|
|||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import { noop } from 'lodash';
|
import { noop } from 'lodash';
|
||||||
|
|
||||||
import { Tabs, Props as TabProps } from './tabs';
|
import { Props as TabProps, Tabs } from './tabs';
|
||||||
|
|
||||||
function RouterAwareTabs(
|
function RouterAwareTabs(
|
||||||
props: TabProps & {
|
props: TabProps & {
|
||||||
@ -105,4 +105,6 @@ function RoutedTabs({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RoutedTabs.displayName = 'RoutedTabs';
|
||||||
|
|
||||||
export { RoutedTabs };
|
export { RoutedTabs };
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
useState,
|
ReactNode,
|
||||||
useRef,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
ReactNode,
|
useRef,
|
||||||
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { MailPoet } from 'mailpoet';
|
import { MailPoet } from 'mailpoet';
|
||||||
|
import { withBoundary } from 'common';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
type: 'success' | 'info' | 'warning' | 'error';
|
type: 'success' | 'info' | 'warning' | 'error';
|
||||||
@ -86,6 +87,7 @@ function Notice({
|
|||||||
document.getElementById('mailpoet_notices'),
|
document.getElementById('mailpoet_notices'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notice.defaultProps = {
|
Notice.defaultProps = {
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
scroll: false,
|
scroll: false,
|
||||||
@ -94,5 +96,6 @@ Notice.defaultProps = {
|
|||||||
onDisplay: undefined,
|
onDisplay: undefined,
|
||||||
onClose: undefined,
|
onClose: undefined,
|
||||||
};
|
};
|
||||||
|
Notice.displayName = 'Notice';
|
||||||
export { Notice };
|
const NoticeWithBoundary = withBoundary(Notice);
|
||||||
|
export { NoticeWithBoundary as Notice };
|
||||||
|
@ -40,3 +40,4 @@ export function Editor(): JSX.Element {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Editor.displayName = 'SegmentEditor';
|
||||||
|
@ -225,4 +225,6 @@ DynamicSegmentListComponent.propTypes = {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DynamicSegmentListComponent.displayName = 'DynamicSegmentList';
|
||||||
|
|
||||||
export const DynamicSegmentList = withRouter(DynamicSegmentListComponent);
|
export const DynamicSegmentList = withRouter(DynamicSegmentListComponent);
|
||||||
|
@ -78,4 +78,6 @@ SegmentForm.propTypes = {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SegmentForm.displayName = 'SegmentForm';
|
||||||
|
|
||||||
export { SegmentForm };
|
export { SegmentForm };
|
||||||
|
@ -374,4 +374,6 @@ SegmentListComponent.propTypes = {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SegmentListComponent.displayName = 'SegmentList';
|
||||||
|
|
||||||
export const SegmentList = withRouter(SegmentListComponent);
|
export const SegmentList = withRouter(SegmentListComponent);
|
||||||
|
@ -8,6 +8,7 @@ import { SegmentList } from 'segments/list.jsx';
|
|||||||
import { SegmentForm } from 'segments/form.jsx';
|
import { SegmentForm } from 'segments/form.jsx';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
import { Notices } from 'notices/notices.jsx';
|
import { Notices } from 'notices/notices.jsx';
|
||||||
|
import { withBoundary } from 'common';
|
||||||
import { Editor } from './dynamic/editor';
|
import { Editor } from './dynamic/editor';
|
||||||
import { DynamicSegmentList } from './dynamic/list.jsx';
|
import { DynamicSegmentList } from './dynamic/list.jsx';
|
||||||
import { ListHeading } from './heading';
|
import { ListHeading } from './heading';
|
||||||
@ -39,6 +40,8 @@ function Tabs() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tabs.displayName = 'SegmentTabs';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
@ -46,12 +49,12 @@ function App() {
|
|||||||
<Notices />
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" render={() => <Redirect to="/lists" />} />
|
<Route exact path="/" render={() => <Redirect to="/lists" />} />
|
||||||
<Route path="/new" component={SegmentForm} />
|
<Route path="/new" render={withBoundary(SegmentForm)} />
|
||||||
<Route path="/edit/:id" component={SegmentForm} />
|
<Route path="/edit/:id" render={withBoundary(SegmentForm)} />
|
||||||
<Route path="/new-segment" component={Editor} />
|
<Route path="/new-segment" render={withBoundary(Editor)} />
|
||||||
<Route path="/edit-segment/:id" component={Editor} />
|
<Route path="/edit-segment/:id" render={withBoundary(Editor)} />
|
||||||
<Route path="/segments/(.*)?" component={Tabs} />
|
<Route path="/segments/(.*)?" render={withBoundary(Tabs)} />
|
||||||
<Route path="/lists/(.*)?" component={Tabs} />
|
<Route path="/lists/(.*)?" render={withBoundary(Tabs)} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</GlobalContext.Provider>
|
</GlobalContext.Provider>
|
||||||
|
Reference in New Issue
Block a user