diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js
index 5815fafab..dbfd47c4e 100644
--- a/src/components/Dashboard/Dashboard.js
+++ b/src/components/Dashboard/Dashboard.js
@@ -12,6 +12,7 @@ import DashboardSplitPane from 'components/Dashboard/DashboardSplitePane';
import GlobalHotkeys from './GlobalHotkeys';
import DashboardProvider from './DashboardProvider';
import DrawersContainer from 'components/DrawersContainer';
+import AlertsContainer from 'containers/AlertsContainer';
import EnsureSubscriptionIsActive from '../Guards/EnsureSubscriptionIsActive';
/**
@@ -55,6 +56,7 @@ export default function Dashboard() {
+
);
}
diff --git a/src/containers/Accounts/AccountsAlerts.js b/src/containers/Accounts/AccountsAlerts.js
index 1fb967e42..d242072d0 100644
--- a/src/containers/Accounts/AccountsAlerts.js
+++ b/src/containers/Accounts/AccountsAlerts.js
@@ -1,26 +1,20 @@
import React from 'react';
-import AccountDeleteAlert from 'containers/Alerts/AccountDeleteAlert';
-import AccountInactivateAlert from 'containers/Alerts/AccountInactivateAlert';
-import AccountActivateAlert from 'containers/Alerts/AccountActivateAlert';
+
+const AccountDeleteAlert = React.lazy(() =>
+ import('containers/Alerts/AccountDeleteAlert'),
+);
+const AccountInactivateAlert = React.lazy(() =>
+ import('containers/Alerts/AccountInactivateAlert'),
+);
+const AccountActivateAlert = React.lazy(() =>
+ import('containers/Alerts/AccountActivateAlert'),
+);
// import AccountBulkDeleteAlert from 'containers/Alerts/AccountBulkDeleteAlert';
// import AccountBulkInactivateAlert from 'containers/Alerts/AccountBulkInactivateAlert';
// import AccountBulkActivateAlert from 'containers/Alerts/AccountBulkActivateAlert';
-/**
- * Accounts alert.
- */
-export default function AccountsAlerts({
-
-}) {
- return (
-
- )
-}
\ No newline at end of file
+export default [
+ { name: 'account-delete', component: AccountDeleteAlert },
+ { name: 'account-inactivate', component: AccountInactivateAlert },
+ { name: 'account-activate', component: AccountActivateAlert },
+];
diff --git a/src/containers/Accounts/AccountsChart.js b/src/containers/Accounts/AccountsChart.js
index af2d627b6..ba0cd2839 100644
--- a/src/containers/Accounts/AccountsChart.js
+++ b/src/containers/Accounts/AccountsChart.js
@@ -7,7 +7,6 @@ import { AccountsChartProvider } from './AccountsChartProvider';
import AccountsViewsTabs from 'containers/Accounts/AccountsViewsTabs';
import AccountsActionsBar from 'containers/Accounts/AccountsActionsBar';
-import AccountsAlerts from './AccountsAlerts';
import AccountsDataTable from './AccountsDataTable';
import withAccounts from 'containers/Accounts/withAccounts';
@@ -49,8 +48,6 @@ function AccountsChart({
-
-
);
}
diff --git a/src/containers/AlertsContainer/components.js b/src/containers/AlertsContainer/components.js
new file mode 100644
index 000000000..41411de1b
--- /dev/null
+++ b/src/containers/AlertsContainer/components.js
@@ -0,0 +1,100 @@
+import React, { Suspense } from 'react';
+import * as R from 'ramda';
+import { Intent, Classes, ProgressBar } from '@blueprintjs/core';
+import { debounce } from 'lodash';
+import styled from 'styled-components';
+import clsx from 'classnames';
+
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { AppToaster } from 'components';
+
+function AlertLazyFallbackMessage({ amount }) {
+ return (
+
+ Alert content is loading, just a second.
+ = 100,
+ })}
+ intent={amount < 100 ? Intent.PRIMARY : Intent.SUCCESS}
+ value={amount / 100}
+ />
+
+ );
+}
+
+function AlertLazyFallback({}) {
+ const progressToastInterval = React.useRef(null);
+ const toastKey = React.useRef(null);
+
+ const toastProgressLoading = (amount) => {
+ return {
+ message: ,
+ onDismiss: (didTimeoutExpire) => {
+ if (!didTimeoutExpire) {
+ window.clearInterval(progressToastInterval.current);
+ }
+ },
+ timeout: amount < 100 ? 0 : 2000,
+ };
+ };
+
+ const triggerProgressToast = () => {
+ let progress = 0;
+ toastKey.current = AppToaster.show(toastProgressLoading(0));
+
+ progressToastInterval.current = window.setInterval(() => {
+ if (toastKey.current == null || progress > 100) {
+ window.clearInterval(progressToastInterval.current);
+ } else {
+ progress += 10 + Math.random() * 20;
+ AppToaster.show(toastProgressLoading(progress), toastKey.current);
+ }
+ }, 100);
+ };
+
+ const hideProgressToast = () => {
+ window.clearInterval(progressToastInterval.current);
+ AppToaster.dismiss(toastKey.current);
+ };
+
+ // Debounce the trigger.
+ const dobounceTrigger = React.useRef(
+ debounce(() => {
+ triggerProgressToast();
+ }, 500),
+ );
+ React.useEffect(() => {
+ dobounceTrigger.current();
+
+ return () => {
+ hideProgressToast();
+ dobounceTrigger.current.cancel();
+ };
+ });
+
+ return null;
+}
+
+function AlertLazyInside({ isOpen, name, Component }) {
+ if (!isOpen) {
+ return null;
+ }
+
+ return (
+ }>
+
+
+ );
+}
+
+export const AlertLazy = R.compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+)(AlertLazyInside);
+
+const ToastText = styled.div`
+ margin-bottom: 10px;
+`;
diff --git a/src/containers/AlertsContainer/index.js b/src/containers/AlertsContainer/index.js
new file mode 100644
index 000000000..bfc591513
--- /dev/null
+++ b/src/containers/AlertsContainer/index.js
@@ -0,0 +1,13 @@
+import React from 'react';
+import { AlertLazy } from './components'
+import registered from './registered';
+
+export default function AlertsContainer() {
+ return (
+
+ {registered.map((alert) => (
+
+ ))}
+
+ );
+}
diff --git a/src/containers/AlertsContainer/registered.js b/src/containers/AlertsContainer/registered.js
new file mode 100644
index 000000000..5fb789c4b
--- /dev/null
+++ b/src/containers/AlertsContainer/registered.js
@@ -0,0 +1,3 @@
+import AccountsAlerts from '../Accounts/AccountsAlerts';
+
+export default [...AccountsAlerts];
diff --git a/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js b/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js
index cdb7a897b..b0ce27e35 100644
--- a/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js
+++ b/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.js
@@ -14,7 +14,6 @@ import {
Icon,
T,
} from '../../../components';
-import AccountsAlerts from './../../Accounts/AccountsAlerts';
import { useCashFlowAccountsContext } from './CashFlowAccountsProvider';
@@ -173,8 +172,6 @@ export default function CashflowAccountsGrid() {
)}
-
-
);
}