Show global notices in all pages
[MAILPOET-2390]
This commit is contained in:
committed by
Jack Kitterhing
parent
3660271fad
commit
3fc48006c2
@@ -5,10 +5,12 @@ import { HashRouter, Switch, Route } from 'react-router-dom';
|
|||||||
import DynamicSegmentList from 'dynamic_segments/list.jsx';
|
import DynamicSegmentList from 'dynamic_segments/list.jsx';
|
||||||
import DynamicSegmentForm from 'dynamic_segments/form.jsx';
|
import DynamicSegmentForm from 'dynamic_segments/form.jsx';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/new" component={DynamicSegmentForm} />
|
<Route path="/new" component={DynamicSegmentForm} />
|
||||||
<Route path="/edit/:id" component={DynamicSegmentForm} />
|
<Route path="/edit/:id" component={DynamicSegmentForm} />
|
||||||
|
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const ExperimentalFeatures = () => {
|
const ExperimentalFeatures = () => {
|
||||||
const [flags, setFlags] = useState(null);
|
const [flags, setFlags] = useState(null);
|
||||||
@@ -61,24 +62,27 @@ const ExperimentalFeatures = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<GlobalContext.Provider value={contextValue}>
|
<GlobalContext.Provider value={contextValue}>
|
||||||
{ Object.values(flags).map((flag) => {
|
<>
|
||||||
const id = `experimental-feature-${flag.name}`;
|
<Notices />
|
||||||
return (
|
{ Object.values(flags).map((flag) => {
|
||||||
<div key={flag.name}>
|
const id = `experimental-feature-${flag.name}`;
|
||||||
<label htmlFor={id}>
|
return (
|
||||||
<input
|
<div key={flag.name}>
|
||||||
id={id}
|
<label htmlFor={id}>
|
||||||
type="checkbox"
|
<input
|
||||||
name={flag.name}
|
id={id}
|
||||||
defaultChecked={flag.value}
|
type="checkbox"
|
||||||
onChange={handleChange}
|
name={flag.name}
|
||||||
/>
|
defaultChecked={flag.value}
|
||||||
{' '}
|
onChange={handleChange}
|
||||||
{flag.name}
|
/>
|
||||||
</label>
|
{' '}
|
||||||
</div>
|
{flag.name}
|
||||||
);
|
</label>
|
||||||
})}
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
</GlobalContext.Provider>
|
</GlobalContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -1,13 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
import Editor from './components/editor.jsx';
|
import Editor from './components/editor.jsx';
|
||||||
import initStore from './store/store.jsx';
|
import initStore from './store/store.jsx';
|
||||||
import initBlocks from './blocks/blocks.jsx';
|
import initBlocks from './blocks/blocks.jsx';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<Editor />
|
<>
|
||||||
|
<Notices />
|
||||||
|
<Editor />
|
||||||
|
</>
|
||||||
</GlobalContext.Provider>
|
</GlobalContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Route, HashRouter } from 'react-router-dom';
|
import { Route, HashRouter } from 'react-router-dom';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
import FormList from './list.jsx';
|
import FormList from './list.jsx';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Route path="*" component={FormList} />
|
<Route path="*" component={FormList} />
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</GlobalContext.Provider>
|
</GlobalContext.Provider>
|
||||||
|
@@ -9,10 +9,12 @@ import SystemInfo from 'help/system_info.jsx';
|
|||||||
import SystemStatus from 'help/system_status.jsx';
|
import SystemStatus from 'help/system_status.jsx';
|
||||||
import YourPrivacy from 'help/your_privacy.jsx';
|
import YourPrivacy from 'help/your_privacy.jsx';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" render={() => <Redirect to="/knowledgeBase" />} />
|
<Route exact path="/" render={() => <Redirect to="/knowledgeBase" />} />
|
||||||
<Route path="/knowledgeBase" component={KnowledgeBase} />
|
<Route path="/knowledgeBase" component={KnowledgeBase} />
|
||||||
|
@@ -16,6 +16,7 @@ import {
|
|||||||
checkMailerStatus,
|
checkMailerStatus,
|
||||||
} from 'newsletters/listings/utils.jsx';
|
} from 'newsletters/listings/utils.jsx';
|
||||||
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
import SubscribersLimitNotice from 'notices/subscribers_limit_notice.jsx';
|
||||||
|
import { GlobalContext } from 'context/index.jsx';
|
||||||
|
|
||||||
const mailpoetTrackingEnabled = (!!(window.mailpoet_tracking_enabled));
|
const mailpoetTrackingEnabled = (!!(window.mailpoet_tracking_enabled));
|
||||||
|
|
||||||
@@ -173,6 +174,8 @@ newsletterActions = addStatsCTAAction(newsletterActions);
|
|||||||
class NewsletterListStandard extends React.Component {
|
class NewsletterListStandard extends React.Component {
|
||||||
static displayName = 'NewsletterListStandard';
|
static displayName = 'NewsletterListStandard';
|
||||||
|
|
||||||
|
static contextType = GlobalContext;
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
location: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
location: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
match: PropTypes.shape({
|
match: PropTypes.shape({
|
||||||
|
@@ -21,6 +21,7 @@ import NewsletterListNotificationHistory from 'newsletters/listings/notification
|
|||||||
import NewsletterSendingStatus from 'newsletters/sending_status.jsx';
|
import NewsletterSendingStatus from 'newsletters/sending_status.jsx';
|
||||||
import CampaignStatsPage from 'newsletters/campaign_stats/page.jsx';
|
import CampaignStatsPage from 'newsletters/campaign_stats/page.jsx';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const getAutomaticEmailsRoutes = () => {
|
const getAutomaticEmailsRoutes = () => {
|
||||||
if (!window.mailpoet_automatic_emails) return [];
|
if (!window.mailpoet_automatic_emails) return [];
|
||||||
@@ -101,6 +102,7 @@ const routes = Hooks.applyFilters('mailpoet_newsletters_before_router', [
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" render={() => <Redirect to="/standard" />} />
|
<Route exact path="/" render={() => <Redirect to="/standard" />} />
|
||||||
{routes.map((route) => (
|
{routes.map((route) => (
|
||||||
|
8
assets/js/src/notices/notices.jsx
Normal file
8
assets/js/src/notices/notices.jsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { GlobalContext } from 'context/index.jsx';
|
||||||
|
import Notice from './notice.jsx';
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
const { notices } = React.useContext(GlobalContext);
|
||||||
|
return notices.items.map(({ id, ...props }) => <Notice key={id} {...props} />);
|
||||||
|
};
|
@@ -5,12 +5,14 @@ import { HashRouter, Switch, Route } from 'react-router-dom';
|
|||||||
import SegmentList from 'segments/list.jsx';
|
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';
|
||||||
|
|
||||||
const container = document.getElementById('segments_container');
|
const container = document.getElementById('segments_container');
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/new" component={SegmentForm} />
|
<Route path="/new" component={SegmentForm} />
|
||||||
<Route path="/edit/:id" component={SegmentForm} />
|
<Route path="/edit/:id" component={SegmentForm} />
|
||||||
|
@@ -2,9 +2,11 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import DefaultSender from 'settings/default_sender.jsx';
|
import DefaultSender from 'settings/default_sender.jsx';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
|
<Notices />
|
||||||
<DefaultSender
|
<DefaultSender
|
||||||
senderAddress={window.mailpoet_settings_sender_adddress}
|
senderAddress={window.mailpoet_settings_sender_adddress}
|
||||||
senderName={window.mailpoet_settings_sender_name}
|
senderName={window.mailpoet_settings_sender_name}
|
||||||
|
@@ -6,6 +6,7 @@ import {
|
|||||||
import ScrollToTop from 'common/scroll_to_top.jsx';
|
import ScrollToTop from 'common/scroll_to_top.jsx';
|
||||||
|
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
import StepMethodSelection from './import/step_method_selection.jsx';
|
import StepMethodSelection from './import/step_method_selection.jsx';
|
||||||
import StepInputValidation from './import/step_input_validation.jsx';
|
import StepInputValidation from './import/step_input_validation.jsx';
|
||||||
import StepDataManipulation from './import/step_data_manipulation.jsx';
|
import StepDataManipulation from './import/step_data_manipulation.jsx';
|
||||||
@@ -22,6 +23,7 @@ const ImportSubscribers = () => {
|
|||||||
return (
|
return (
|
||||||
<GlobalContext.Provider value={contextValue}>
|
<GlobalContext.Provider value={contextValue}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<ScrollToTop>
|
<ScrollToTop>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route
|
<Route
|
||||||
|
@@ -5,10 +5,12 @@ import { HashRouter, Switch, Route } from 'react-router-dom';
|
|||||||
import SubscriberList from 'subscribers/list.jsx';
|
import SubscriberList from 'subscribers/list.jsx';
|
||||||
import SubscriberForm from 'subscribers/form.jsx';
|
import SubscriberForm from 'subscribers/form.jsx';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/new" component={SubscriberForm} />
|
<Route path="/new" component={SubscriberForm} />
|
||||||
<Route path="/edit/:id" component={SubscriberForm} />
|
<Route path="/edit/:id" component={SubscriberForm} />
|
||||||
|
@@ -7,6 +7,7 @@ import {
|
|||||||
Switch,
|
Switch,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
|
import Notices from 'notices/notices.jsx';
|
||||||
import WelcomeWizardStepsController from './welcome_wizard_controller.jsx';
|
import WelcomeWizardStepsController from './welcome_wizard_controller.jsx';
|
||||||
import WooCommerceImportController from './woocommerce_import_controller.jsx';
|
import WooCommerceImportController from './woocommerce_import_controller.jsx';
|
||||||
import RevenueTrackingPermissionController from './revenue_tracking_permission.jsx';
|
import RevenueTrackingPermissionController from './revenue_tracking_permission.jsx';
|
||||||
@@ -22,6 +23,7 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<GlobalContext.Provider value={contextValue}>
|
<GlobalContext.Provider value={contextValue}>
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
|
<Notices />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
|
<Route path="/steps/:step" component={WelcomeWizardStepsController} />
|
||||||
<Route path="/import" component={WooCommerceImportController} />
|
<Route path="/import" component={WooCommerceImportController} />
|
||||||
|
Reference in New Issue
Block a user