Selaa lähdekoodia

feat(toolbox) notify click for hangup-menu and end-meeting menu button

factor2
Shawn 2 vuotta sitten
vanhempi
commit
93ab7725e7

+ 2
- 0
config.js Näytä tiedosto

@@ -767,11 +767,13 @@ var config = {
767 767
     //     'desktop',
768 768
     //     'download',
769 769
     //     'embedmeeting',
770
+    //     'end-meeting',
770 771
     //     'etherpad',
771 772
     //     'feedback',
772 773
     //     'filmstrip',
773 774
     //     'fullscreen',
774 775
     //     'hangup',
776
+    //     'hangup-menu',
775 777
     //     'help',
776 778
     //     {
777 779
     //         key: 'invite',

+ 2
- 0
react/features/base/config/configType.ts Näytä tiedosto

@@ -39,11 +39,13 @@ type ButtonsWithNotifyClick = 'camera' |
39 39
     'desktop' |
40 40
     'download' |
41 41
     'embedmeeting' |
42
+    'end-meeting' |
42 43
     'etherpad' |
43 44
     'feedback' |
44 45
     'filmstrip' |
45 46
     'fullscreen' |
46 47
     'hangup' |
48
+    'hangup-menu' |
47 49
     'help' |
48 50
     'invite' |
49 51
     'livestreaming' |

+ 27
- 6
react/features/toolbox/components/web/EndConferenceButton.tsx Näytä tiedosto

@@ -4,16 +4,36 @@ import { useDispatch, useSelector } from 'react-redux';
4 4
 
5 5
 import { endConference } from '../../../base/conference/actions';
6 6
 import { isLocalParticipantModerator } from '../../../base/participants/functions';
7
-import Button from '../../../base/ui/components/web/Button';
8 7
 import { BUTTON_TYPES } from '../../../base/ui/constants.web';
9 8
 import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
10 9
 
10
+import { HangupContextMenuItem } from './HangupContextMenuItem';
11
+
12
+/**
13
+ * The type of the React {@code Component} props of {@link EndConferenceButton}.
14
+ */
15
+type Props = {
16
+
17
+    /**
18
+     * Key to use for toolbarButtonClicked event.
19
+     */
20
+    buttonKey: string;
21
+
22
+    /**
23
+     * Notify mode for `toolbarButtonClicked` event -
24
+     * whether to only notify or to also prevent button click routine.
25
+     */
26
+    notifyMode?: string;
27
+};
28
+
29
+
11 30
 /**
12 31
  * Button to end the conference for all participants.
13 32
  *
33
+ * @param {Object} props - Component's props.
14 34
  * @returns {JSX.Element} - The end conference button.
15 35
  */
16
-export const EndConferenceButton = () => {
36
+export const EndConferenceButton = (props: Props) => {
17 37
     const { t } = useTranslation();
18 38
     const dispatch = useDispatch();
19 39
     const _isLocalParticipantModerator = useSelector(isLocalParticipantModerator);
@@ -24,11 +44,12 @@ export const EndConferenceButton = () => {
24 44
     }, [ dispatch ]);
25 45
 
26 46
     return (<>
27
-        { !_isInBreakoutRoom && _isLocalParticipantModerator && <Button
47
+        { !_isInBreakoutRoom && _isLocalParticipantModerator && <HangupContextMenuItem
28 48
             accessibilityLabel = { t('toolbar.accessibilityLabel.endConference') }
29
-            fullWidth = { true }
49
+            buttonKey = { props.buttonKey }
50
+            buttonType = { BUTTON_TYPES.DESTRUCTIVE }
30 51
             label = { t('toolbar.endConference') }
31
-            onClick = { onEndConference }
32
-            type = { BUTTON_TYPES.DESTRUCTIVE } /> }
52
+            notifyMode = { props.notifyMode }
53
+            onClick = { onEndConference } /> }
33 54
     </>);
34 55
 };

+ 75
- 0
react/features/toolbox/components/web/HangupContextMenuItem.tsx Näytä tiedosto

@@ -0,0 +1,75 @@
1
+import React, { useCallback } from 'react';
2
+
3
+import Button from '../../../base/ui/components/web/Button';
4
+import { NOTIFY_CLICK_MODE } from '../../constants';
5
+
6
+
7
+/**
8
+ * The type of the React {@code Component} props of {@link HangupContextMenuItem}.
9
+ */
10
+type Props = {
11
+
12
+    /**
13
+     * Accessibility label for the button.
14
+     */
15
+    accessibilityLabel: string;
16
+
17
+    /**
18
+     * Key to use for toolbarButtonClicked event.
19
+     */
20
+    buttonKey: string;
21
+
22
+    /**
23
+     * Type of button to display.
24
+     */
25
+    buttonType: string;
26
+
27
+    /**
28
+     * Text associated with the button.
29
+     */
30
+    label: string;
31
+
32
+    /**
33
+     * Notify mode for `toolbarButtonClicked` event -
34
+     * whether to only notify or to also prevent button click routine.
35
+     */
36
+    notifyMode?: string;
37
+
38
+    /**
39
+     * Callback that performs the actual hangup action.
40
+     */
41
+    onClick: Function;
42
+};
43
+
44
+declare let APP: any;
45
+
46
+/**
47
+ * Implementation of a button to be rendered within Hangup context menu.
48
+ *
49
+ * @param {Object} props - Component's props.
50
+ * @returns {JSX.Element} - Button that would trigger the hangup action.
51
+ */
52
+export const HangupContextMenuItem = (props: Props) => {
53
+    const shouldNotify = props.notifyMode !== undefined;
54
+    const shouldPreventExecution = props.notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY;
55
+
56
+    const _onClick = useCallback(() => {
57
+        if (shouldNotify) {
58
+            APP.API.notifyToolbarButtonClicked(props.buttonKey, shouldPreventExecution);
59
+        }
60
+
61
+        if (!shouldPreventExecution) {
62
+            props.onClick();
63
+        }
64
+    }, []);
65
+
66
+    return (
67
+        <Button
68
+            accessibilityLabel = { props.accessibilityLabel }
69
+            fullWidth = { true }
70
+            label = { props.label }
71
+            onClick = { _onClick }
72
+            type = { props.buttonType } />
73
+    );
74
+};
75
+

+ 8
- 0
react/features/toolbox/components/web/HangupMenuButton.tsx Näytä tiedosto

@@ -28,6 +28,12 @@ interface IProps extends WithTranslation {
28 28
      */
29 29
     isOpen: boolean;
30 30
 
31
+    /**
32
+     * Notify mode for `toolbarButtonClicked` event -
33
+     * whether to only notify or to also prevent button click routine.
34
+     */
35
+    notifyMode?: string;
36
+
31 37
     /**
32 38
      * Callback to change the visibility of the hangup menu.
33 39
      */
@@ -88,9 +94,11 @@ class HangupMenuButton extends Component<IProps> {
88 94
                     trigger = 'click'
89 95
                     visible = { isOpen }>
90 96
                     <HangupToggleButton
97
+                        buttonKey = 'hangup-menu'
91 98
                         customClass = 'hangup-menu-button'
92 99
                         handleClick = { this._toggleDialogVisibility }
93 100
                         isOpen = { isOpen }
101
+                        notifyMode = { this.props.notifyMode }
94 102
                         onKeyDown = { this._onEscClick } />
95 103
                 </Popover>
96 104
             </div>

+ 27
- 6
react/features/toolbox/components/web/LeaveConferenceButton.tsx Näytä tiedosto

@@ -5,15 +5,35 @@ import { useDispatch } from 'react-redux';
5 5
 import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
6 6
 import { sendAnalytics } from '../../../analytics/functions';
7 7
 import { leaveConference } from '../../../base/conference/actions';
8
-import Button from '../../../base/ui/components/web/Button';
9 8
 import { BUTTON_TYPES } from '../../../base/ui/constants.web';
10 9
 
10
+import { HangupContextMenuItem } from './HangupContextMenuItem';
11
+
12
+/**
13
+ * The type of the React {@code Component} props of {@link LeaveConferenceButton}.
14
+ */
15
+type Props = {
16
+
17
+    /**
18
+     * Key to use for toolbarButtonClicked event.
19
+     */
20
+    buttonKey: string;
21
+
22
+    /**
23
+     * Notify mode for `toolbarButtonClicked` event -
24
+     * whether to only notify or to also prevent button click routine.
25
+     */
26
+    notifyMode?: string;
27
+};
28
+
29
+
11 30
 /**
12 31
  * Button to leave the conference.
13 32
  *
33
+ * @param {Object} props - Component's props.
14 34
  * @returns {JSX.Element} - The leave conference button.
15 35
  */
16
-export const LeaveConferenceButton = () => {
36
+export const LeaveConferenceButton = (props: Props) => {
17 37
     const { t } = useTranslation();
18 38
     const dispatch = useDispatch();
19 39
 
@@ -23,11 +43,12 @@ export const LeaveConferenceButton = () => {
23 43
     }, [ dispatch ]);
24 44
 
25 45
     return (
26
-        <Button
46
+        <HangupContextMenuItem
27 47
             accessibilityLabel = { t('toolbar.accessibilityLabel.leaveConference') }
28
-            fullWidth = { true }
48
+            buttonKey = { props.buttonKey }
49
+            buttonType = { BUTTON_TYPES.SECONDARY }
29 50
             label = { t('toolbar.leaveConference') }
30
-            onClick = { onLeaveConference }
31
-            type = { BUTTON_TYPES.SECONDARY } />
51
+            notifyMode = { props.notifyMode }
52
+            onClick = { onLeaveConference } />
32 53
     );
33 54
 };

+ 7
- 2
react/features/toolbox/components/web/Toolbox.tsx Näytä tiedosto

@@ -1489,6 +1489,7 @@ class Toolbox extends Component<IProps> {
1489 1489
                                     ariaControls = 'hangup-menu'
1490 1490
                                     isOpen = { _hangupMenuVisible }
1491 1491
                                     key = 'hangup-menu'
1492
+                                    notifyMode = { this._getButtonNotifyMode('hangup-menu') }
1492 1493
                                     onVisibilityChange = { this._onSetHangupVisible }>
1493 1494
                                     <ContextMenu
1494 1495
                                         accessibilityLabel = { t(toolbarAccLabel) }
@@ -1496,8 +1497,12 @@ class Toolbox extends Component<IProps> {
1496 1497
                                         hidden = { false }
1497 1498
                                         inDrawer = { _overflowDrawer }
1498 1499
                                         onKeyDown = { this._onEscKey }>
1499
-                                        <EndConferenceButton />
1500
-                                        <LeaveConferenceButton />
1500
+                                        <EndConferenceButton
1501
+                                            buttonKey = 'end-meeting'
1502
+                                            notifyMode = { this._getButtonNotifyMode('end-meeting') } />
1503
+                                        <LeaveConferenceButton
1504
+                                            buttonKey = 'hangup'
1505
+                                            notifyMode = { this._getButtonNotifyMode('hangup') } />
1501 1506
                                     </ContextMenu>
1502 1507
                                 </HangupMenuButton>
1503 1508
                                 : <HangupButton

Loading…
Peruuta
Tallenna