Browse Source

ref(notifications): replace NotificationWithToggle with Notification

It was decided along with the mute participant dialog reactification
that these types of warning messages should not be toggleable--that
they should simply always display because there is no undo action.
As such, the component NotificationWithToggle is no longer needed.
j8
Leonard Kim 7 years ago
parent
commit
ef813fbf71

+ 2
- 5
lang/main.json View File

324
         "stopRecordingWarning": "Are you sure you would like to stop the recording?",
324
         "stopRecordingWarning": "Are you sure you would like to stop the recording?",
325
         "stopLiveStreaming": "Stop live streaming",
325
         "stopLiveStreaming": "Stop live streaming",
326
         "stopRecording": "Stop recording",
326
         "stopRecording": "Stop recording",
327
-        "doNotShowWarningAgain": "Don't show this warning again",
328
         "doNotShowMessageAgain": "Don't show this message again",
327
         "doNotShowMessageAgain": "Don't show this message again",
329
         "permissionDenied": "Permission Denied",
328
         "permissionDenied": "Permission Denied",
330
         "screenSharingFailedToInstall": "Oops! Your screen sharing extension failed to install.",
329
         "screenSharingFailedToInstall": "Oops! Your screen sharing extension failed to install.",
331
         "screenSharingFailedToInstallTitle": "Screen sharing extension failed to install",
330
         "screenSharingFailedToInstallTitle": "Screen sharing extension failed to install",
332
         "screenSharingPermissionDeniedError": "Oops! Something went wrong with your screen sharing extension permissions. Please reload and try again.",
331
         "screenSharingPermissionDeniedError": "Oops! Something went wrong with your screen sharing extension permissions. Please reload and try again.",
333
-        "micErrorPresent": "There was an error connecting to your microphone.",
334
-        "cameraErrorPresent": "There was an error connecting to your camera.",
335
         "cameraUnsupportedResolutionError": "Your camera does not support required video resolution.",
332
         "cameraUnsupportedResolutionError": "Your camera does not support required video resolution.",
336
-        "cameraUnknownError": "Cannot use camera for a unknown reason.",
333
+        "cameraUnknownError": "Cannot use camera for an unknown reason.",
337
         "cameraPermissionDeniedError": "You have not granted permission to use your camera. You can still join the conference but others won't see you. Use the camera button in the address bar to fix this.",
334
         "cameraPermissionDeniedError": "You have not granted permission to use your camera. You can still join the conference but others won't see you. Use the camera button in the address bar to fix this.",
338
         "cameraNotFoundError": "Camera was not found.",
335
         "cameraNotFoundError": "Camera was not found.",
339
         "cameraConstraintFailedError": "Your camera does not satisfy some of the required constraints.",
336
         "cameraConstraintFailedError": "Your camera does not satisfy some of the required constraints.",
340
-        "micUnknownError": "Cannot use microphone for a unknown reason.",
337
+        "micUnknownError": "Cannot use microphone for an unknown reason.",
341
         "micPermissionDeniedError": "You have not granted permission to use your microphone. You can still join the conference but others won't hear you. Use the camera button in the address bar to fix this.",
338
         "micPermissionDeniedError": "You have not granted permission to use your microphone. You can still join the conference but others won't hear you. Use the camera button in the address bar to fix this.",
342
         "micNotFoundError": "Microphone was not found.",
339
         "micNotFoundError": "Microphone was not found.",
343
         "micConstraintFailedError": "Your microphone does not satisfy some of the required constraints.",
340
         "micConstraintFailedError": "Your microphone does not satisfy some of the required constraints.",

+ 15
- 29
modules/UI/UI.js View File

31
 } from '../../react/features/base/participants';
31
 } from '../../react/features/base/participants';
32
 import { openDisplayNamePrompt } from '../../react/features/display-name';
32
 import { openDisplayNamePrompt } from '../../react/features/display-name';
33
 import {
33
 import {
34
-    maybeShowNotificationWithDoNotDisplay,
35
-    setNotificationsEnabled
34
+    setNotificationsEnabled,
35
+    showWarningNotification
36
 } from '../../react/features/notifications';
36
 } from '../../react/features/notifications';
37
 import {
37
 import {
38
     checkAutoEnableDesktopSharing,
38
     checkAutoEnableDesktopSharing,
1155
 
1155
 
1156
     const { message, name } = micError;
1156
     const { message, name } = micError;
1157
 
1157
 
1158
-    const persistenceKey = `doNotShowErrorAgain-mic-${name}`;
1159
-
1160
     const micJitsiTrackErrorMsg
1158
     const micJitsiTrackErrorMsg
1161
         = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[name];
1159
         = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[name];
1162
     const micErrorMsg = micJitsiTrackErrorMsg
1160
     const micErrorMsg = micJitsiTrackErrorMsg
1164
             .microphone[JitsiTrackErrors.GENERAL];
1162
             .microphone[JitsiTrackErrors.GENERAL];
1165
     const additionalMicErrorMsg = micJitsiTrackErrorMsg ? null : message;
1163
     const additionalMicErrorMsg = micJitsiTrackErrorMsg ? null : message;
1166
 
1164
 
1167
-    APP.store.dispatch(maybeShowNotificationWithDoNotDisplay(
1168
-        persistenceKey,
1169
-        {
1170
-            additionalMessage: additionalMicErrorMsg,
1171
-            messageKey: micErrorMsg,
1172
-            showToggle: Boolean(micJitsiTrackErrorMsg),
1173
-            subtitleKey: 'dialog.micErrorPresent',
1174
-            titleKey: name === JitsiTrackErrors.PERMISSION_DENIED
1175
-                ? 'deviceError.microphonePermission'
1176
-                : 'deviceError.microphoneError',
1177
-            toggleLabelKey: 'dialog.doNotShowWarningAgain'
1178
-        }));
1165
+    APP.store.dispatch(showWarningNotification({
1166
+        description: additionalMicErrorMsg,
1167
+        descriptionKey: micErrorMsg,
1168
+        titleKey: name === JitsiTrackErrors.PERMISSION_DENIED
1169
+            ? 'deviceError.microphonePermission'
1170
+            : 'deviceError.microphoneError'
1171
+    }));
1179
 };
1172
 };
1180
 
1173
 
1181
 /**
1174
 /**
1192
 
1185
 
1193
     const { message, name } = cameraError;
1186
     const { message, name } = cameraError;
1194
 
1187
 
1195
-    const persistenceKey = `doNotShowErrorAgain-camera-${name}`;
1196
-
1197
     const cameraJitsiTrackErrorMsg
1188
     const cameraJitsiTrackErrorMsg
1198
         = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[name];
1189
         = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[name];
1199
     const cameraErrorMsg = cameraJitsiTrackErrorMsg
1190
     const cameraErrorMsg = cameraJitsiTrackErrorMsg
1201
             .camera[JitsiTrackErrors.GENERAL];
1192
             .camera[JitsiTrackErrors.GENERAL];
1202
     const additionalCameraErrorMsg = cameraJitsiTrackErrorMsg ? null : message;
1193
     const additionalCameraErrorMsg = cameraJitsiTrackErrorMsg ? null : message;
1203
 
1194
 
1204
-    APP.store.dispatch(maybeShowNotificationWithDoNotDisplay(
1205
-        persistenceKey,
1206
-        {
1207
-            additionalMessage: additionalCameraErrorMsg,
1208
-            messageKey: cameraErrorMsg,
1209
-            showToggle: Boolean(cameraJitsiTrackErrorMsg),
1210
-            subtitleKey: 'dialog.cameraErrorPresent',
1211
-            titleKey: name === JitsiTrackErrors.PERMISSION_DENIED
1212
-                ? 'deviceError.cameraPermission' : 'deviceError.cameraError',
1213
-            toggleLabelKey: 'dialog.doNotShowWarningAgain'
1214
-        }));
1195
+    APP.store.dispatch(showWarningNotification({
1196
+        description: additionalCameraErrorMsg,
1197
+        descriptionKey: cameraErrorMsg,
1198
+        titleKey: name === JitsiTrackErrors.PERMISSION_DENIED
1199
+            ? 'deviceError.cameraPermission' : 'deviceError.cameraError'
1200
+    }));
1215
 };
1201
 };
1216
 
1202
 
1217
 /**
1203
 /**

+ 0
- 25
package-lock.json View File

533
         "styled-components": "1.3.0"
533
         "styled-components": "1.3.0"
534
       }
534
       }
535
     },
535
     },
536
-    "@atlaskit/toggle": {
537
-      "version": "2.6.1",
538
-      "resolved": "https://registry.npmjs.org/@atlaskit/toggle/-/toggle-2.6.1.tgz",
539
-      "integrity": "sha1-I2R+VzTs9psaPb8VpVw0tlfim90=",
540
-      "requires": {
541
-        "@atlaskit/icon": "8.1.0",
542
-        "@atlaskit/theme": "2.2.0",
543
-        "babel-runtime": "6.26.0",
544
-        "prop-types": "15.6.0",
545
-        "styled-components": "1.3.0",
546
-        "uid": "0.0.2"
547
-      },
548
-      "dependencies": {
549
-        "@atlaskit/icon": {
550
-          "version": "8.1.0",
551
-          "resolved": "https://registry.npmjs.org/@atlaskit/icon/-/icon-8.1.0.tgz",
552
-          "integrity": "sha1-HeV48TixTcmMOFkYZbW2h+VYuDo=",
553
-          "requires": {
554
-            "babel-runtime": "6.26.0",
555
-            "prop-types": "15.6.0",
556
-            "styled-components": "1.3.0"
557
-          }
558
-        }
559
-      }
560
-    },
561
     "@atlaskit/tooltip": {
536
     "@atlaskit/tooltip": {
562
       "version": "6.0.0",
537
       "version": "6.0.0",
563
       "resolved": "https://registry.npmjs.org/@atlaskit/tooltip/-/tooltip-6.0.0.tgz",
538
       "resolved": "https://registry.npmjs.org/@atlaskit/tooltip/-/tooltip-6.0.0.tgz",

+ 0
- 1
package.json View File

30
     "@atlaskit/spinner": "4.0.0",
30
     "@atlaskit/spinner": "4.0.0",
31
     "@atlaskit/tabs": "4.0.1",
31
     "@atlaskit/tabs": "4.0.1",
32
     "@atlaskit/theme": "2.2.0",
32
     "@atlaskit/theme": "2.2.0",
33
-    "@atlaskit/toggle": "2.6.1",
34
     "@atlaskit/tooltip": "6.0.0",
33
     "@atlaskit/tooltip": "6.0.0",
35
     "@atlassian/aui": "6.0.6",
34
     "@atlassian/aui": "6.0.6",
36
     "autosize": "1.18.13",
35
     "autosize": "1.18.13",

+ 1
- 36
react/features/notifications/actions.js View File

1
-import jitsiLocalStorage from '../../../modules/util/JitsiLocalStorage';
2
-
3
 import {
1
 import {
4
     HIDE_NOTIFICATION,
2
     HIDE_NOTIFICATION,
5
     SET_NOTIFICATIONS_ENABLED,
3
     SET_NOTIFICATIONS_ENABLED,
6
     SHOW_NOTIFICATION
4
     SHOW_NOTIFICATION
7
 } from './actionTypes';
5
 } from './actionTypes';
8
-import {
9
-    Notification,
10
-    NotificationWithToggle
11
-} from './components';
6
+import { Notification } from './components';
12
 
7
 
13
 import { NOTIFICATION_TYPE } from './constants';
8
 import { NOTIFICATION_TYPE } from './constants';
14
 
9
 
96
         appearance: NOTIFICATION_TYPE.WARNING
91
         appearance: NOTIFICATION_TYPE.WARNING
97
     });
92
     });
98
 }
93
 }
99
-
100
-/**
101
- * Displays a notification unless the passed in persistenceKey value exists in
102
- * local storage and has been set to "true".
103
- *
104
- * @param {string} persistenceKey - The local storage key to look up for whether
105
- * or not the notification should display.
106
- * @param {Object} props - The props needed to show the notification component.
107
- * @returns {Function}
108
- */
109
-export function maybeShowNotificationWithDoNotDisplay(persistenceKey, props) {
110
-    return dispatch => {
111
-        if (jitsiLocalStorage.getItem(persistenceKey) === 'true') {
112
-            return;
113
-        }
114
-
115
-        const newProps = Object.assign({}, props, {
116
-            onToggleSubmit: isToggled => {
117
-                jitsiLocalStorage.setItem(persistenceKey, isToggled);
118
-            }
119
-        });
120
-
121
-        dispatch({
122
-            type: SHOW_NOTIFICATION,
123
-            component: NotificationWithToggle,
124
-            props: newProps,
125
-            uid: window.Date.now()
126
-        });
127
-    };
128
-}

+ 27
- 3
react/features/notifications/components/Notification.web.js View File

61
         defaultTitleKey: PropTypes.string,
61
         defaultTitleKey: PropTypes.string,
62
 
62
 
63
         /**
63
         /**
64
-         * The description string.
64
+         * A description string that can be used in addition to the prop
65
+         * descriptionKey.
65
          */
66
          */
66
         description: PropTypes.string,
67
         description: PropTypes.string,
67
 
68
 
161
             <Flag
162
             <Flag
162
                 actions = { this._mapAppearanceToButtons(hideErrorSupportLink) }
163
                 actions = { this._mapAppearanceToButtons(hideErrorSupportLink) }
163
                 appearance = { appearance }
164
                 appearance = { appearance }
164
-                description = { description
165
-                    || t(descriptionKey, descriptionArguments) }
165
+                description = { this._renderDescription() }
166
                 icon = { this._mapAppearanceToIcon() }
166
                 icon = { this._mapAppearanceToIcon() }
167
                 id = { uid }
167
                 id = { uid }
168
                 isDismissAllowed = { isDismissAllowed }
168
                 isDismissAllowed = { isDismissAllowed }
173
 
173
 
174
     _onDismissed: () => void;
174
     _onDismissed: () => void;
175
 
175
 
176
+    /**
177
+     * Creates a {@code ReactElement} for displaying the contents of the
178
+     * notification.
179
+     *
180
+     * @private
181
+     * @returns {ReactElement}
182
+     */
183
+    _renderDescription() {
184
+        const {
185
+            description,
186
+            descriptionArguments,
187
+            descriptionKey,
188
+            t
189
+        } = this.props;
190
+
191
+        return (
192
+            <div>
193
+                { descriptionKey
194
+                    ? t(descriptionKey, descriptionArguments) : null }
195
+                { description || null }
196
+            </div>
197
+        );
198
+    }
199
+
176
     /**
200
     /**
177
      * Calls back into {@code FlagGroup} to dismiss the notification.
201
      * Calls back into {@code FlagGroup} to dismiss the notification.
178
      *
202
      *

+ 0
- 0
react/features/notifications/components/NotificationWithToggle.native.js View File


+ 0
- 160
react/features/notifications/components/NotificationWithToggle.web.js View File

1
-import { ToggleStateless } from '@atlaskit/toggle';
2
-import PropTypes from 'prop-types';
3
-import React, { Component } from 'react';
4
-
5
-import { translate } from '../../base/i18n';
6
-
7
-import { default as Notification } from './Notification';
8
-import { NOTIFICATION_TYPE } from '../constants';
9
-
10
-/**
11
- * React {@code Component} for displaying a notification with a toggle element.
12
- *
13
- * @extends Component
14
- */
15
-class NotificationWithToggle extends Component {
16
-    /**
17
-     * {@code NotificationWithToggle} component's property types.
18
-     *
19
-     * @static
20
-     */
21
-    static propTypes = {
22
-        ...Notification.propTypes,
23
-
24
-        /**
25
-         * Any additional text to display at the end of the notification message
26
-         * body.
27
-         */
28
-        additionalMessage: PropTypes.string,
29
-
30
-        /**
31
-         * Optional callback to invoke when the notification is dismissed. The
32
-         * current value of the toggle element will be passed in.
33
-         */
34
-        onToggleSubmit: PropTypes.func,
35
-
36
-        /**
37
-         * Whether or not the toggle element should be displayed.
38
-         */
39
-        showToggle: PropTypes.bool,
40
-
41
-        /**
42
-         * Translation key for a message to display at the top of the
43
-         * notification body.
44
-         */
45
-        subtitleKey: PropTypes.string,
46
-
47
-        /*
48
-         * The translation key to be used as a label describing what setting the
49
-         * toggle will change.
50
-         */
51
-        toggleLabelKey: PropTypes.string
52
-    };
53
-
54
-    /**
55
-     * Initializes a new {@code NotificationWithToggle} instance.
56
-     *
57
-     * @param {Object} props - The read-only properties with which the new
58
-     * instance is to be initialized.
59
-     */
60
-    constructor(props) {
61
-        super(props);
62
-
63
-        this.state = {
64
-            /**
65
-             * Whether or not the toggle element is active/checked/selected.
66
-             *
67
-             * @type {boolean}
68
-             */
69
-            isToggleChecked: false
70
-        };
71
-
72
-        // Bind event handlers so they are only bound once for every instance.
73
-        this._onDismissed = this._onDismissed.bind(this);
74
-        this._onToggleChange = this._onToggleChange.bind(this);
75
-    }
76
-
77
-    /**
78
-     * Implements React's {@link Component#render()}.
79
-     *
80
-     * @inheritdoc
81
-     * @returns {ReactElement}
82
-     */
83
-    render() {
84
-        return (
85
-            <Notification
86
-                appearance = { NOTIFICATION_TYPE.WARNING }
87
-                { ...this.props }
88
-                description = { this._renderDescription() } />
89
-        );
90
-    }
91
-
92
-    /**
93
-     * Calls back into {@code FlagGroup} to dismiss the notification. Optionally
94
-     * will execute a passed in onToggleSubmit callback with the current state
95
-     * of the toggle element.
96
-     *
97
-     * @private
98
-     * @returns {void}
99
-     */
100
-    _onDismissed() {
101
-        const { onDismissed, onToggleSubmit, showToggle, uid } = this.props;
102
-
103
-        if (showToggle && onToggleSubmit) {
104
-            onToggleSubmit(this.state.isToggleChecked);
105
-        }
106
-
107
-        onDismissed(uid);
108
-    }
109
-
110
-    /**
111
-     * Updates the current known state of the toggle selection.
112
-     *
113
-     * @param {Object} event - The DOM event from changing the toggle selection.
114
-     * @private
115
-     * @returns {void}
116
-     */
117
-    _onToggleChange(event) {
118
-        this.setState({
119
-            isToggleChecked: event.target.checked
120
-        });
121
-    }
122
-
123
-    /**
124
-     * Creates a React Element for displaying the notification message as well
125
-     * as a toggle.
126
-     *
127
-     * @private
128
-     * @returns {ReactElement}
129
-     */
130
-    _renderDescription() {
131
-        const {
132
-            additionalMessage,
133
-            descriptionKey,
134
-            showToggle,
135
-            subtitleKey,
136
-            t,
137
-            toggleLabelKey
138
-        } = this.props;
139
-
140
-        return (
141
-            <div className = 'notification-with-toggle'>
142
-                <div>{ t(subtitleKey) }</div>
143
-                { descriptionKey ? <div>{ t(descriptionKey) }</div> : null }
144
-                { additionalMessage ? <div>{ additionalMessage }</div>
145
-                    : null }
146
-                { showToggle
147
-                    ? <div>
148
-                        { t(toggleLabelKey) }
149
-                        <ToggleStateless
150
-                            isChecked
151
-                                = { this.state.isToggleChecked }
152
-                            onChange = { this._onToggleChange } />
153
-                    </div>
154
-                    : null }
155
-            </div>
156
-        );
157
-    }
158
-}
159
-
160
-export default translate(NotificationWithToggle);

+ 0
- 1
react/features/notifications/components/index.js View File

1
 export { default as Notification } from './Notification';
1
 export { default as Notification } from './Notification';
2
 export { default as NotificationsContainer } from './NotificationsContainer';
2
 export { default as NotificationsContainer } from './NotificationsContainer';
3
-export { default as NotificationWithToggle } from './NotificationWithToggle';

Loading…
Cancel
Save