Selaa lähdekoodia

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

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

* (to-squash) Addresses comments
master
yanas 7 vuotta sitten
vanhempi
commit
4ccd5c6072

+ 4
- 0
css/modals/_dialog.scss Näytä tiedosto

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

+ 2
- 1
lang/main.json Näytä tiedosto

@@ -463,7 +463,8 @@
463 463
         "add": "Add",
464 464
         "noResults": "No matching search results",
465 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 469
     "inlineDialogFailure": {
469 470
         "msg": "We stumbled a bit.",

+ 1
- 0
package.json Näytä tiedosto

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

+ 3
- 1
react/features/base/react/components/web/InlineDialogFailure.js Näytä tiedosto

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

+ 58
- 4
react/features/invite/components/AddPeopleDialog.web.js Näytä tiedosto

@@ -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));

Loading…
Peruuta
Tallenna