|
|
@@ -13,6 +13,7 @@ import {
|
|
13
|
13
|
} from '../../analytics';
|
|
14
|
14
|
|
|
15
|
15
|
import { refreshCalendar } from '../actions';
|
|
|
16
|
+import { ERRORS } from '../constants';
|
|
16
|
17
|
import { isCalendarEnabled } from '../functions';
|
|
17
|
18
|
|
|
18
|
19
|
import CalendarListContent from './CalendarListContent';
|
|
|
@@ -24,6 +25,12 @@ declare var interfaceConfig: Object;
|
|
24
|
25
|
*/
|
|
25
|
26
|
type Props = {
|
|
26
|
27
|
|
|
|
28
|
+ /**
|
|
|
29
|
+ * The error object containing details about any error that has occurred
|
|
|
30
|
+ * while interacting with calendar integration.
|
|
|
31
|
+ */
|
|
|
32
|
+ _calendarError: ?Object,
|
|
|
33
|
+
|
|
27
|
34
|
/**
|
|
28
|
35
|
* Whether or not a calendar may be connected for fetching calendar events.
|
|
29
|
36
|
*/
|
|
|
@@ -87,6 +94,54 @@ class CalendarList extends AbstractPage<Props> {
|
|
87
|
94
|
);
|
|
88
|
95
|
}
|
|
89
|
96
|
|
|
|
97
|
+ /**
|
|
|
98
|
+ * Returns a component for showing the error message related to calendar
|
|
|
99
|
+ * sync.
|
|
|
100
|
+ *
|
|
|
101
|
+ * @private
|
|
|
102
|
+ * @returns {React$Component}
|
|
|
103
|
+ */
|
|
|
104
|
+ _getErrorMessage() {
|
|
|
105
|
+ const { _calendarError = {}, t } = this.props;
|
|
|
106
|
+
|
|
|
107
|
+ let errorMessageKey = 'calendarSync.error.generic';
|
|
|
108
|
+ let showRefreshButton = true;
|
|
|
109
|
+ let showSettingsButton = true;
|
|
|
110
|
+
|
|
|
111
|
+ if (_calendarError.error === ERRORS.GOOGLE_APP_MISCONFIGURED) {
|
|
|
112
|
+ errorMessageKey = 'calendarSync.error.appConfiguration';
|
|
|
113
|
+ showRefreshButton = false;
|
|
|
114
|
+ showSettingsButton = false;
|
|
|
115
|
+ } else if (_calendarError.error === ERRORS.AUTH_FAILED) {
|
|
|
116
|
+ errorMessageKey = 'calendarSync.error.notSignedIn';
|
|
|
117
|
+ showRefreshButton = false;
|
|
|
118
|
+ }
|
|
|
119
|
+
|
|
|
120
|
+ return (
|
|
|
121
|
+ <div className = 'meetings-list-empty'>
|
|
|
122
|
+ <p className = 'description'>
|
|
|
123
|
+ { t(errorMessageKey) }
|
|
|
124
|
+ </p>
|
|
|
125
|
+ <div className = 'calendar-action-buttons'>
|
|
|
126
|
+ { showSettingsButton
|
|
|
127
|
+ && <div
|
|
|
128
|
+ className = 'button'
|
|
|
129
|
+ onClick = { this._onOpenSettings }>
|
|
|
130
|
+ { t('calendarSync.permissionButton') }
|
|
|
131
|
+ </div>
|
|
|
132
|
+ }
|
|
|
133
|
+ { showRefreshButton
|
|
|
134
|
+ && <div
|
|
|
135
|
+ className = 'button'
|
|
|
136
|
+ onClick = { this._onRefreshEvents }>
|
|
|
137
|
+ { t('calendarSync.refresh') }
|
|
|
138
|
+ </div>
|
|
|
139
|
+ }
|
|
|
140
|
+ </div>
|
|
|
141
|
+ </div>
|
|
|
142
|
+ );
|
|
|
143
|
+ }
|
|
|
144
|
+
|
|
90
|
145
|
_getRenderListEmptyComponent: () => Object;
|
|
91
|
146
|
|
|
92
|
147
|
/**
|
|
|
@@ -97,12 +152,21 @@ class CalendarList extends AbstractPage<Props> {
|
|
97
|
152
|
* @returns {React$Component}
|
|
98
|
153
|
*/
|
|
99
|
154
|
_getRenderListEmptyComponent() {
|
|
100
|
|
- const { _hasIntegrationSelected, _hasLoadedEvents, t } = this.props;
|
|
|
155
|
+ const {
|
|
|
156
|
+ _calendarError,
|
|
|
157
|
+ _hasIntegrationSelected,
|
|
|
158
|
+ _hasLoadedEvents,
|
|
|
159
|
+ t
|
|
|
160
|
+ } = this.props;
|
|
101
|
161
|
|
|
102
|
|
- if (_hasIntegrationSelected && _hasLoadedEvents) {
|
|
|
162
|
+ if (_calendarError) {
|
|
|
163
|
+ return this._getErrorMessage();
|
|
|
164
|
+ } else if (_hasIntegrationSelected && _hasLoadedEvents) {
|
|
103
|
165
|
return (
|
|
104
|
166
|
<div className = 'meetings-list-empty'>
|
|
105
|
|
- <div>{ t('calendarSync.noEvents') }</div>
|
|
|
167
|
+ <p className = 'description'>
|
|
|
168
|
+ { t('calendarSync.noEvents') }
|
|
|
169
|
+ </p>
|
|
106
|
170
|
<div
|
|
107
|
171
|
className = 'button'
|
|
108
|
172
|
onClick = { this._onRefreshEvents }>
|
|
|
@@ -172,18 +236,21 @@ class CalendarList extends AbstractPage<Props> {
|
|
172
|
236
|
* @param {Object} state - The Redux state.
|
|
173
|
237
|
* @private
|
|
174
|
238
|
* @returns {{
|
|
|
239
|
+ * _calendarError: Object,
|
|
175
|
240
|
* _hasIntegrationSelected: boolean,
|
|
176
|
241
|
* _hasLoadedEvents: boolean
|
|
177
|
242
|
* }}
|
|
178
|
243
|
*/
|
|
179
|
244
|
function _mapStateToProps(state) {
|
|
180
|
245
|
const {
|
|
|
246
|
+ error,
|
|
181
|
247
|
events,
|
|
182
|
248
|
integrationType,
|
|
183
|
249
|
isLoadingEvents
|
|
184
|
250
|
} = state['features/calendar-sync'];
|
|
185
|
251
|
|
|
186
|
252
|
return {
|
|
|
253
|
+ _calendarError: error,
|
|
187
|
254
|
_hasIntegrationSelected: Boolean(integrationType),
|
|
188
|
255
|
_hasLoadedEvents: Boolean(events) || !isLoadingEvents
|
|
189
|
256
|
};
|