|
@@ -2,15 +2,18 @@ import React, { Component } from 'react';
|
2
|
2
|
import { Immutable } from 'nuclear-js';
|
3
|
3
|
import { connect } from 'react-redux';
|
4
|
4
|
import Avatar from '@atlaskit/avatar';
|
|
5
|
+import InlineMessage from '@atlaskit/inline-message';
|
5
|
6
|
|
6
|
7
|
import { getInviteURL } from '../../base/connection';
|
7
|
|
-import { Dialog } from '../../base/dialog';
|
|
8
|
+import { Dialog, hideDialog } from '../../base/dialog';
|
8
|
9
|
import { translate } from '../../base/i18n';
|
9
|
10
|
import MultiSelectAutocomplete
|
10
|
11
|
from '../../base/react/components/web/MultiSelectAutocomplete';
|
11
|
12
|
|
12
|
13
|
import { invitePeople, searchPeople } from '../functions';
|
13
|
14
|
|
|
15
|
+declare var interfaceConfig: Object;
|
|
16
|
+
|
14
|
17
|
/**
|
15
|
18
|
* The dialog that allows to invite people to the call.
|
16
|
19
|
*/
|
|
@@ -41,6 +44,11 @@ class AddPeopleDialog extends Component {
|
41
|
44
|
*/
|
42
|
45
|
_peopleSearchUrl: React.PropTypes.string,
|
43
|
46
|
|
|
47
|
+ /**
|
|
48
|
+ * The function closing the dialog.
|
|
49
|
+ */
|
|
50
|
+ hideDialog: React.PropTypes.func,
|
|
51
|
+
|
44
|
52
|
/**
|
45
|
53
|
* Invoked to obtain translated strings.
|
46
|
54
|
*/
|
|
@@ -132,7 +140,7 @@ class AddPeopleDialog extends Component {
|
132
|
140
|
onSubmit = { this._onSubmit }
|
133
|
141
|
titleKey = 'addPeople.title'
|
134
|
142
|
width = 'small'>
|
135
|
|
- { this._getUserInputForm() }
|
|
143
|
+ { this._renderUserInputForm() }
|
136
|
144
|
</Dialog>
|
137
|
145
|
);
|
138
|
146
|
}
|
|
@@ -143,11 +151,12 @@ class AddPeopleDialog extends Component {
|
143
|
151
|
* @returns {ReactElement}
|
144
|
152
|
* @private
|
145
|
153
|
*/
|
146
|
|
- _getUserInputForm() {
|
|
154
|
+ _renderUserInputForm() {
|
147
|
155
|
const { t } = this.props;
|
148
|
156
|
|
149
|
157
|
return (
|
150
|
158
|
<div className = 'add-people-form-wrap'>
|
|
159
|
+ { this._renderErrorMessage() }
|
151
|
160
|
<MultiSelectAutocomplete
|
152
|
161
|
isDisabled
|
153
|
162
|
= { this.state.addToCallInProgress || false }
|
|
@@ -210,6 +219,8 @@ class AddPeopleDialog extends Component {
|
210
|
219
|
this.setState({
|
211
|
220
|
addToCallInProgress: false
|
212
|
221
|
});
|
|
222
|
+
|
|
223
|
+ this.props.hideDialog();
|
213
|
224
|
})
|
214
|
225
|
.catch(() => {
|
215
|
226
|
this.setState({
|
|
@@ -220,6 +231,49 @@ class AddPeopleDialog extends Component {
|
220
|
231
|
}
|
221
|
232
|
}
|
222
|
233
|
|
|
234
|
+ /**
|
|
235
|
+ * Renders the error message if the add doesn't succeed.
|
|
236
|
+ *
|
|
237
|
+ * @returns {ReactElement|null}
|
|
238
|
+ * @private
|
|
239
|
+ */
|
|
240
|
+ _renderErrorMessage() {
|
|
241
|
+ if (!this.state.addToCallError) {
|
|
242
|
+ return null;
|
|
243
|
+ }
|
|
244
|
+
|
|
245
|
+ const { t } = this.props;
|
|
246
|
+ const supportString = t('inlineDialogFailure.supportMsg');
|
|
247
|
+ const supportLink = interfaceConfig.SUPPORT_URL;
|
|
248
|
+ const supportLinkContent
|
|
249
|
+ = ( // eslint-disable-line no-extra-parens
|
|
250
|
+ <span>
|
|
251
|
+ <span>
|
|
252
|
+ { supportString.padEnd(supportString.length + 1) }
|
|
253
|
+ </span>
|
|
254
|
+ <span>
|
|
255
|
+ <a
|
|
256
|
+ href = { supportLink }
|
|
257
|
+ rel = 'noopener noreferrer'
|
|
258
|
+ target = '_blank'>
|
|
259
|
+ { t('inlineDialogFailure.support') }
|
|
260
|
+ </a>
|
|
261
|
+ </span>
|
|
262
|
+ <span>.</span>
|
|
263
|
+ </span>
|
|
264
|
+ );
|
|
265
|
+
|
|
266
|
+ return (
|
|
267
|
+ <div className = 'modal-dialog-form-error'>
|
|
268
|
+ <InlineMessage
|
|
269
|
+ title = { t('addPeople.failedToAdd') }
|
|
270
|
+ type = 'error'>
|
|
271
|
+ { supportLinkContent }
|
|
272
|
+ </InlineMessage>
|
|
273
|
+ </div>
|
|
274
|
+ );
|
|
275
|
+ }
|
|
276
|
+
|
223
|
277
|
/**
|
224
|
278
|
* Sets the instance variable for the multi select component
|
225
|
279
|
* element so it can be accessed directly.
|
|
@@ -256,4 +310,4 @@ function _mapStateToProps(state) {
|
256
|
310
|
}
|
257
|
311
|
|
258
|
312
|
export default translate(
|
259
|
|
- connect(_mapStateToProps)(AddPeopleDialog));
|
|
313
|
+ connect(_mapStateToProps, { hideDialog })(AddPeopleDialog));
|