Browse Source

Fix(AddPeopleDialog): Close dialog on submit (#1761)

* Fix(AddPeopleDialog): Fixes error state and close dialog

* (to-squash) Addresses comments
master
yanas 7 years ago
parent
commit
4ccd5c6072

+ 4
- 0
css/modals/_dialog.scss View File

86
         border: $modalMockAKInputBorder;
86
         border: $modalMockAKInputBorder;
87
         color: inherit;
87
         color: inherit;
88
     }
88
     }
89
+
90
+    &-error {
91
+        margin-bottom: 8px;
92
+    }
89
 }
93
 }
90
 .modal-dialog-footer {
94
 .modal-dialog-footer {
91
     font-size: $modalButtonFontSize;
95
     font-size: $modalButtonFontSize;

+ 2
- 1
lang/main.json View File

463
         "add": "Add",
463
         "add": "Add",
464
         "noResults": "No matching search results",
464
         "noResults": "No matching search results",
465
         "searchPlaceholder": "Search for people and rooms to add",
465
         "searchPlaceholder": "Search for people and rooms to add",
466
-        "title": "Add people to your call"
466
+        "title": "Add people to your call",
467
+        "failedToAdd": "Failed to add participants"
467
     },
468
     },
468
     "inlineDialogFailure": {
469
     "inlineDialogFailure": {
469
         "msg": "We stumbled a bit.",
470
         "msg": "We stumbled a bit.",

+ 1
- 0
package.json View File

23
     "@atlaskit/field-text": "2.7.0",
23
     "@atlaskit/field-text": "2.7.0",
24
     "@atlaskit/icon": "7.0.0",
24
     "@atlaskit/icon": "7.0.0",
25
     "@atlaskit/inline-dialog": "3.2.0",
25
     "@atlaskit/inline-dialog": "3.2.0",
26
+    "@atlaskit/inline-message": "2.1.1",
26
     "@atlaskit/modal-dialog": "2.1.2",
27
     "@atlaskit/modal-dialog": "2.1.2",
27
     "@atlaskit/multi-select": "6.2.0",
28
     "@atlaskit/multi-select": "6.2.0",
28
     "@atlaskit/spinner": "2.2.3",
29
     "@atlaskit/spinner": "2.2.3",

+ 3
- 1
react/features/base/react/components/web/InlineDialogFailure.js View File

35
         const { t } = this.props;
35
         const { t } = this.props;
36
 
36
 
37
         const supportLink = interfaceConfig.SUPPORT_URL;
37
         const supportLink = interfaceConfig.SUPPORT_URL;
38
+        const supportString = t('inlineDialogFailure.supportMsg');
38
         const supportLinkElem
39
         const supportLinkElem
39
             = supportLink
40
             = supportLink
40
                 ? ( // eslint-disable-line no-extra-parens
41
                 ? ( // eslint-disable-line no-extra-parens
41
                     <div className = 'inline-dialog-error-text'>
42
                     <div className = 'inline-dialog-error-text'>
42
-                        <span>{ t('inlineDialogFailure.supportMsg') }</span>
43
+                        <span>{ supportString.padEnd(supportString.length + 1) }
44
+                        </span>
43
                         <span>
45
                         <span>
44
                             <a
46
                             <a
45
                                 href = { supportLink }
47
                                 href = { supportLink }

+ 58
- 4
react/features/invite/components/AddPeopleDialog.web.js View File

2
 import { Immutable } from 'nuclear-js';
2
 import { Immutable } from 'nuclear-js';
3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 import Avatar from '@atlaskit/avatar';
4
 import Avatar from '@atlaskit/avatar';
5
+import InlineMessage from '@atlaskit/inline-message';
5
 
6
 
6
 import { getInviteURL } from '../../base/connection';
7
 import { getInviteURL } from '../../base/connection';
7
-import { Dialog } from '../../base/dialog';
8
+import { Dialog, hideDialog } from '../../base/dialog';
8
 import { translate } from '../../base/i18n';
9
 import { translate } from '../../base/i18n';
9
 import MultiSelectAutocomplete
10
 import MultiSelectAutocomplete
10
     from '../../base/react/components/web/MultiSelectAutocomplete';
11
     from '../../base/react/components/web/MultiSelectAutocomplete';
11
 
12
 
12
 import { invitePeople, searchPeople } from '../functions';
13
 import { invitePeople, searchPeople } from '../functions';
13
 
14
 
15
+declare var interfaceConfig: Object;
16
+
14
 /**
17
 /**
15
  * The dialog that allows to invite people to the call.
18
  * The dialog that allows to invite people to the call.
16
  */
19
  */
41
          */
44
          */
42
         _peopleSearchUrl: React.PropTypes.string,
45
         _peopleSearchUrl: React.PropTypes.string,
43
 
46
 
47
+        /**
48
+         * The function closing the dialog.
49
+         */
50
+        hideDialog: React.PropTypes.func,
51
+
44
         /**
52
         /**
45
          * Invoked to obtain translated strings.
53
          * Invoked to obtain translated strings.
46
          */
54
          */
132
                 onSubmit = { this._onSubmit }
140
                 onSubmit = { this._onSubmit }
133
                 titleKey = 'addPeople.title'
141
                 titleKey = 'addPeople.title'
134
                 width = 'small'>
142
                 width = 'small'>
135
-                { this._getUserInputForm() }
143
+                { this._renderUserInputForm() }
136
             </Dialog>
144
             </Dialog>
137
         );
145
         );
138
     }
146
     }
143
      * @returns {ReactElement}
151
      * @returns {ReactElement}
144
      * @private
152
      * @private
145
      */
153
      */
146
-    _getUserInputForm() {
154
+    _renderUserInputForm() {
147
         const { t } = this.props;
155
         const { t } = this.props;
148
 
156
 
149
         return (
157
         return (
150
             <div className = 'add-people-form-wrap'>
158
             <div className = 'add-people-form-wrap'>
159
+                { this._renderErrorMessage() }
151
                 <MultiSelectAutocomplete
160
                 <MultiSelectAutocomplete
152
                     isDisabled
161
                     isDisabled
153
                         = { this.state.addToCallInProgress || false }
162
                         = { this.state.addToCallInProgress || false }
210
                 this.setState({
219
                 this.setState({
211
                     addToCallInProgress: false
220
                     addToCallInProgress: false
212
                 });
221
                 });
222
+
223
+                this.props.hideDialog();
213
             })
224
             })
214
             .catch(() => {
225
             .catch(() => {
215
                 this.setState({
226
                 this.setState({
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
      * Sets the instance variable for the multi select component
278
      * Sets the instance variable for the multi select component
225
      * element so it can be accessed directly.
279
      * element so it can be accessed directly.
256
 }
310
 }
257
 
311
 
258
 export default translate(
312
 export default translate(
259
-    connect(_mapStateToProps)(AddPeopleDialog));
313
+    connect(_mapStateToProps, { hideDialog })(AddPeopleDialog));

Loading…
Cancel
Save