Skip to content

Commit eca0acd

Browse files
authored
move getRenderer to Dynamics (#285)
1 parent 76fd3ed commit eca0acd

File tree

1 file changed

+3
-79
lines changed

1 file changed

+3
-79
lines changed

src/containers/AlertContainer/index.js

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,106 +2,30 @@ import React, { PropTypes } from 'react';
22
import { connect } from 'react-redux';
33

44
import Alert from 'ringcentral-integration/modules/Alert';
5-
import Brand from 'ringcentral-integration/modules/Brand';
65
import Locale from 'ringcentral-integration/modules/Locale';
7-
import RateLimiter from 'ringcentral-integration/modules/RateLimiter';
86

97
import AlertDisplay from '../../components/AlertDisplay';
108

11-
import AuthAlert from '../../components/AuthAlert';
12-
import CallAlert from '../../components/CallAlert';
13-
import CallingSettingsAlert from '../../components/CallingSettingsAlert';
14-
import RegionSettingsAlert from '../../components/RegionSettingsAlert';
15-
import MessageSenderAlert from '../../components/MessageSenderAlert';
16-
import RateExceededAlert from '../../components/RateExceededAlert';
17-
import ConnectivityAlert from '../../components/ConnectivityAlert';
18-
import WebphoneAlert from '../../components/WebphoneAlert';
19-
import RolesAndPermissionsAlert from '../../components/RolesAndPermissionsAlert';
20-
219
const AlertContainer = connect((state, {
2210
locale,
2311
alert,
2412
}) => ({
2513
currentLocale: locale.currentLocale,
2614
messages: alert.messages,
2715
}), (dispatch, {
28-
rateLimiter,
29-
brand,
16+
getRenderer,
3017
alert,
3118
}) => ({
32-
getRenderer: (message) => {
33-
if (AuthAlert.handleMessage(message)) {
34-
return AuthAlert;
35-
}
36-
if (CallAlert.handleMessage(message)) {
37-
return props => (
38-
<CallAlert
39-
{...props}
40-
regionSettingsUrl="/settings/region" />
41-
);
42-
}
43-
if (CallingSettingsAlert.handleMessage(message)) {
44-
return props => (
45-
<CallingSettingsAlert
46-
{...props}
47-
brand={brand.fullName}
48-
callingSettingsUrl="/settings/calling" />
49-
);
50-
}
51-
52-
if (RegionSettingsAlert.handleMessage(message)) {
53-
return props => (
54-
<RegionSettingsAlert
55-
{...props}
56-
regionSettingsUrl="/settings/region" />
57-
);
58-
}
59-
60-
if (MessageSenderAlert.handleMessage(message)) {
61-
return props => (
62-
<MessageSenderAlert
63-
{...props}
64-
regionSettingsUrl="/settings/region" />
65-
);
66-
}
67-
68-
if (RateExceededAlert.handleMessage(message)) {
69-
return props => (
70-
<RateExceededAlert
71-
{...props}
72-
timestamp={rateLimiter.timestamp}
73-
duration={rateLimiter._throttleDuration} />
74-
);
75-
}
76-
77-
if (ConnectivityAlert.handleMessage(message)) {
78-
return ConnectivityAlert;
79-
}
80-
81-
if (WebphoneAlert.handleMessage(message)) {
82-
return WebphoneAlert;
83-
}
84-
if (RolesAndPermissionsAlert.handleMessage(message)) {
85-
return props => (
86-
<RolesAndPermissionsAlert
87-
{...props}
88-
brand={brand.fullName}
89-
application={brand.application} />
90-
);
91-
}
92-
93-
return undefined;
94-
},
19+
getRenderer,
9520
dismiss: (id) => {
9621
alert.dismiss(id);
9722
},
9823
}))(AlertDisplay);
9924

10025
AlertContainer.propTypes = {
10126
alert: PropTypes.instanceOf(Alert).isRequired,
102-
brand: PropTypes.instanceOf(Brand).isRequired,
27+
getRenderer: PropTypes.func.isRequired,
10328
locale: PropTypes.instanceOf(Locale).isRequired,
104-
rateLimiter: PropTypes.instanceOf(RateLimiter).isRequired,
10529
};
10630

10731
export default AlertContainer;

0 commit comments

Comments
 (0)