瀏覽代碼

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 年之前
父節點
當前提交
ef813fbf71

+ 2
- 5
lang/main.json 查看文件

@@ -324,20 +324,17 @@
324 324
         "stopRecordingWarning": "Are you sure you would like to stop the recording?",
325 325
         "stopLiveStreaming": "Stop live streaming",
326 326
         "stopRecording": "Stop recording",
327
-        "doNotShowWarningAgain": "Don't show this warning again",
328 327
         "doNotShowMessageAgain": "Don't show this message again",
329 328
         "permissionDenied": "Permission Denied",
330 329
         "screenSharingFailedToInstall": "Oops! Your screen sharing extension failed to install.",
331 330
         "screenSharingFailedToInstallTitle": "Screen sharing extension failed to install",
332 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 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 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 335
         "cameraNotFoundError": "Camera was not found.",
339 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 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 339
         "micNotFoundError": "Microphone was not found.",
343 340
         "micConstraintFailedError": "Your microphone does not satisfy some of the required constraints.",

+ 15
- 29
modules/UI/UI.js 查看文件

@@ -31,8 +31,8 @@ import {
31 31
 } from '../../react/features/base/participants';
32 32
 import { openDisplayNamePrompt } from '../../react/features/display-name';
33 33
 import {
34
-    maybeShowNotificationWithDoNotDisplay,
35
-    setNotificationsEnabled
34
+    setNotificationsEnabled,
35
+    showWarningNotification
36 36
 } from '../../react/features/notifications';
37 37
 import {
38 38
     checkAutoEnableDesktopSharing,
@@ -1155,8 +1155,6 @@ UI.showMicErrorNotification = function(micError) {
1155 1155
 
1156 1156
     const { message, name } = micError;
1157 1157
 
1158
-    const persistenceKey = `doNotShowErrorAgain-mic-${name}`;
1159
-
1160 1158
     const micJitsiTrackErrorMsg
1161 1159
         = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[name];
1162 1160
     const micErrorMsg = micJitsiTrackErrorMsg
@@ -1164,18 +1162,13 @@ UI.showMicErrorNotification = function(micError) {
1164 1162
             .microphone[JitsiTrackErrors.GENERAL];
1165 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,8 +1185,6 @@ UI.showCameraErrorNotification = function(cameraError) {
1192 1185
 
1193 1186
     const { message, name } = cameraError;
1194 1187
 
1195
-    const persistenceKey = `doNotShowErrorAgain-camera-${name}`;
1196
-
1197 1188
     const cameraJitsiTrackErrorMsg
1198 1189
         = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[name];
1199 1190
     const cameraErrorMsg = cameraJitsiTrackErrorMsg
@@ -1201,17 +1192,12 @@ UI.showCameraErrorNotification = function(cameraError) {
1201 1192
             .camera[JitsiTrackErrors.GENERAL];
1202 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 查看文件

@@ -533,31 +533,6 @@
533 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 536
     "@atlaskit/tooltip": {
562 537
       "version": "6.0.0",
563 538
       "resolved": "https://registry.npmjs.org/@atlaskit/tooltip/-/tooltip-6.0.0.tgz",

+ 0
- 1
package.json 查看文件

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

+ 1
- 36
react/features/notifications/actions.js 查看文件

@@ -1,14 +1,9 @@
1
-import jitsiLocalStorage from '../../../modules/util/JitsiLocalStorage';
2
-
3 1
 import {
4 2
     HIDE_NOTIFICATION,
5 3
     SET_NOTIFICATIONS_ENABLED,
6 4
     SHOW_NOTIFICATION
7 5
 } from './actionTypes';
8
-import {
9
-    Notification,
10
-    NotificationWithToggle
11
-} from './components';
6
+import { Notification } from './components';
12 7
 
13 8
 import { NOTIFICATION_TYPE } from './constants';
14 9
 
@@ -96,33 +91,3 @@ export function showWarningNotification(props) {
96 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 查看文件

@@ -61,7 +61,8 @@ class Notification extends Component<*> {
61 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 67
         description: PropTypes.string,
67 68
 
@@ -161,8 +162,7 @@ class Notification extends Component<*> {
161 162
             <Flag
162 163
                 actions = { this._mapAppearanceToButtons(hideErrorSupportLink) }
163 164
                 appearance = { appearance }
164
-                description = { description
165
-                    || t(descriptionKey, descriptionArguments) }
165
+                description = { this._renderDescription() }
166 166
                 icon = { this._mapAppearanceToIcon() }
167 167
                 id = { uid }
168 168
                 isDismissAllowed = { isDismissAllowed }
@@ -173,6 +173,30 @@ class Notification extends Component<*> {
173 173
 
174 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 201
      * Calls back into {@code FlagGroup} to dismiss the notification.
178 202
      *

+ 0
- 0
react/features/notifications/components/NotificationWithToggle.native.js 查看文件


+ 0
- 160
react/features/notifications/components/NotificationWithToggle.web.js 查看文件

@@ -1,160 +0,0 @@
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 查看文件

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

Loading…
取消
儲存