瀏覽代碼

ref(toolbar): kill Stateless Toolbar and Invite, Feedback, Profile buttons

master
Leonard Kim 7 年之前
父節點
當前提交
1e69dc93d6

+ 0
- 113
react/features/feedback/components/FeedbackButton.web.js 查看文件

@@ -1,113 +0,0 @@
1
-// @flow
2
-
3
-import Tooltip from '@atlaskit/tooltip';
4
-import React, { Component } from 'react';
5
-import { connect } from 'react-redux';
6
-
7
-import { translate } from '../../base/i18n';
8
-
9
-import { openFeedbackDialog } from '../actions';
10
-
11
-/**
12
- * The type of the React {@code Component} props of {@link FeedbackButton}.
13
- */
14
-type Props = {
15
-
16
-    /**
17
-     * The JitsiConference for which the feedback will be about.
18
-     *
19
-     * FIXME define JitsiConference type
20
-     * @type {JitsiConference}
21
-     */
22
-    _conference: Object,
23
-
24
-    /**
25
-     * Redux store dispatch function.
26
-     */
27
-    dispatch: Dispatch<*>,
28
-
29
-    /**
30
-     * Invoked to obtain translated strings.
31
-     */
32
-    t: Function,
33
-
34
-    /**
35
-     * From which side of the button the tooltip should appear from.
36
-     */
37
-    tooltipPosition: string
38
-}
39
-
40
-/**
41
- * Implements a Web/React Component which renders a feedback button.
42
- */
43
-class FeedbackButton extends Component<Props> {
44
-    _onClick: Function;
45
-
46
-    /**
47
-     * Initializes a new FeedbackButton instance.
48
-     *
49
-     * @param {Object} props - The read-only properties with which the new
50
-     * instance is to be initialized.
51
-     */
52
-    constructor(props: Object) {
53
-        super(props);
54
-
55
-        // Bind event handlers so they are only bound once for every instance.
56
-        this._onClick = this._onClick.bind(this);
57
-    }
58
-
59
-    /**
60
-     * Implements React's {@link Component#render()}.
61
-     *
62
-     * @inheritdoc
63
-     * @returns {ReactElement}
64
-     */
65
-    render() {
66
-        return (
67
-            <div id = 'feedbackButton'>
68
-                <Tooltip
69
-                    description = { this.props.t('welcomepage.sendFeedback') }
70
-                    position = { this.props.tooltipPosition } >
71
-                    <a
72
-                        className = 'button icon-feedback'
73
-                        onClick = { this._onClick } />
74
-                </Tooltip>
75
-            </div>
76
-        );
77
-    }
78
-
79
-    /**
80
-     * Dispatches an action to open a dialog requesting call feedback.
81
-     *
82
-     * @private
83
-     * @returns {void}
84
-     */
85
-    _onClick() {
86
-        const { _conference, dispatch } = this.props;
87
-
88
-        dispatch(openFeedbackDialog(_conference));
89
-    }
90
-}
91
-
92
-/**
93
- * Maps (parts of) the Redux state to the associated Conference's props.
94
- *
95
- * @param {Object} state - The Redux state.
96
- * @private
97
- * @returns {{
98
- *     _toolboxVisible: boolean
99
- * }}
100
- */
101
-function _mapStateToProps(state) {
102
-    return {
103
-        /**
104
-         * The JitsiConference for which the feedback will be about.
105
-         *
106
-         * @private
107
-         * @type {JitsiConference}
108
-         */
109
-        _conference: state['features/base/conference'].conference
110
-    };
111
-}
112
-
113
-export default translate(connect(_mapStateToProps)(FeedbackButton));

+ 0
- 1
react/features/feedback/components/index.js 查看文件

@@ -1,2 +1 @@
1
-export { default as FeedbackButton } from './FeedbackButton';
2 1
 export { default as FeedbackDialog } from './FeedbackDialog';

+ 0
- 1
react/features/invite/components/InviteButton.native.js 查看文件

@@ -1 +0,0 @@
1
-

+ 0
- 0
react/features/toolbox/components/ProfileButton.native.js 查看文件


+ 0
- 147
react/features/toolbox/components/ProfileButton.web.js 查看文件

@@ -1,147 +0,0 @@
1
-/* @flow */
2
-
3
-import PropTypes from 'prop-types';
4
-import React, { Component } from 'react';
5
-import { connect } from 'react-redux';
6
-
7
-import {
8
-    createToolbarEvent,
9
-    sendAnalytics
10
-} from '../../analytics';
11
-import {
12
-    getAvatarURL,
13
-    getLocalParticipant
14
-} from '../../base/participants';
15
-import UIEvents from '../../../../service/UI/UIEvents';
16
-
17
-import ToolbarButton from './ToolbarButton';
18
-
19
-declare var APP: Object;
20
-
21
-/**
22
- * The default configuration for the button.
23
- *
24
- * @type {Object}
25
- */
26
-const DEFAULT_BUTTON_CONFIGURATION = {
27
-    buttonName: 'profile',
28
-    classNames: [ 'button' ],
29
-    enabled: true,
30
-    id: 'toolbar_button_profile',
31
-    tooltipKey: 'profile.setDisplayNameLabel'
32
-};
33
-
34
-/**
35
- * React {@code Component} for the profile button.
36
- *
37
- * @extends Component
38
- */
39
-class ProfileButton extends Component<*> {
40
-    _onClick: Function;
41
-
42
-    /**
43
-     * {@code ProfileButton}'s property types.
44
-     *
45
-     * @static
46
-     */
47
-    static propTypes = {
48
-        /**
49
-         * The redux representation of the local participant.
50
-         */
51
-        _localParticipant: PropTypes.object,
52
-
53
-        /**
54
-         * Whether the button support clicking or not.
55
-         */
56
-        _unclickable: PropTypes.bool,
57
-
58
-        /**
59
-         * Whether the side panel is opened or not.
60
-         */
61
-        toggled: PropTypes.bool,
62
-
63
-        /**
64
-         * From which side tooltips should display. Will be re-used for
65
-         * displaying the inline dialog for video quality adjustment.
66
-         */
67
-        tooltipPosition: PropTypes.string
68
-    };
69
-
70
-    /**
71
-     * Initializes a new {@code ProfileButton} instance.
72
-     *
73
-     * @param {Object} props - The read-only properties with which the new
74
-     * instance is to be initialized.
75
-     */
76
-    constructor(props) {
77
-        super(props);
78
-
79
-        // Bind event handlers so they are only bound once for every instance.
80
-        this._onClick = this._onClick.bind(this);
81
-    }
82
-
83
-    /**
84
-     * Implements React's {@link Component#render()}.
85
-     *
86
-     * @inheritdoc
87
-     * @returns {ReactElement}
88
-     */
89
-    render() {
90
-        const {
91
-            _localParticipant,
92
-            _unclickable,
93
-            tooltipPosition,
94
-            toggled
95
-        } = this.props;
96
-        const buttonConfiguration = {
97
-            ...DEFAULT_BUTTON_CONFIGURATION,
98
-            unclickable: _unclickable,
99
-            toggled
100
-        };
101
-
102
-        return (
103
-            <ToolbarButton
104
-                button = { buttonConfiguration }
105
-                onClick = { this._onClick }
106
-                tooltipPosition = { tooltipPosition }>
107
-                <img
108
-                    id = 'avatar'
109
-                    src = { getAvatarURL(_localParticipant) } />
110
-            </ToolbarButton>
111
-        );
112
-    }
113
-
114
-    /**
115
-     * Click handler for the button.
116
-     *
117
-     * @returns {void}
118
-     */
119
-    _onClick() {
120
-        if (!this.props._unclickable) {
121
-            // TODO: Include an 'enable' attribute, which specifies whether
122
-            // the profile panel was opened or closed.
123
-            sendAnalytics(createToolbarEvent('profile'));
124
-            APP.UI.emitEvent(UIEvents.TOGGLE_PROFILE);
125
-        }
126
-    }
127
-}
128
-
129
-/**
130
- * Maps (parts of) the Redux state to the associated {@code ProfileButton}
131
- * component's props.
132
- *
133
- * @param {Object} state - The Redux state.
134
- * @private
135
- * @returns {{
136
- *     _localParticipant: Object,
137
- *     _unclickable: boolean
138
- * }}
139
- */
140
-function _mapStateToProps(state) {
141
-    return {
142
-        _localParticipant: getLocalParticipant(state),
143
-        _unclickable: !state['features/base/jwt'].isGuest
144
-    };
145
-}
146
-
147
-export default connect(_mapStateToProps)(ProfileButton);

+ 0
- 65
react/features/toolbox/components/StatelessToolbar.web.js 查看文件

@@ -1,65 +0,0 @@
1
-/* @flow */
2
-
3
-import PropTypes from 'prop-types';
4
-import React, { Component } from 'react';
5
-
6
-/**
7
- * Implements a toolbar in React/Web. It is a strip that contains a set of
8
- * toolbar items such as buttons.
9
- *
10
- * @class StatelessToolbar
11
- * @extends Component
12
- */
13
-export default class StatelessToolbar extends Component<*> {
14
-    /**
15
-     * Base toolbar component's property types.
16
-     *
17
-     * @static
18
-     */
19
-    static propTypes = {
20
-        /**
21
-         * Children of current React component.
22
-         */
23
-        children: PropTypes.node,
24
-
25
-        /**
26
-         * Toolbar's class name.
27
-         */
28
-        className: PropTypes.string,
29
-
30
-        /**
31
-         *  Handler for mouse out event.
32
-         */
33
-        onMouseOut: PropTypes.func,
34
-
35
-        /**
36
-         * Handler for mouse over event.
37
-         */
38
-        onMouseOver: PropTypes.func
39
-    };
40
-
41
-    /**
42
-     * Implements React's {@link Component#render()}.
43
-     *
44
-     * @inheritdoc
45
-     * @returns {ReactElement}
46
-     */
47
-    render(): React$Element<*> {
48
-        const {
49
-            className,
50
-            onMouseOut,
51
-            onMouseOver
52
-        } = this.props;
53
-
54
-        return (
55
-            <div
56
-                className = { `toolbar ${className}` }
57
-                onMouseOut = { onMouseOut }
58
-                onMouseOver = { onMouseOver }>
59
-                {
60
-                    this.props.children
61
-                }
62
-            </div>
63
-        );
64
-    }
65
-}

+ 0
- 130
react/features/toolbox/components/StatelessToolbarButton.js 查看文件

@@ -1,130 +0,0 @@
1
-/* @flow */
2
-
3
-import PropTypes from 'prop-types';
4
-import React from 'react';
5
-
6
-import AbstractToolbarButton from './AbstractToolbarButton';
7
-
8
-type MapOfAttributes = { [key: string]: * };
9
-
10
-
11
-/* eslint-disable flowtype/space-before-type-colon */
12
-
13
-/**
14
- * Takes toolbar button props and maps them to HTML attributes to set.
15
- *
16
- * @param {Object} props - Props set to the React component.
17
- * @returns {MapOfAttributes}
18
- */
19
-function getButtonAttributesByProps(props: Object = {})
20
-        : MapOfAttributes {
21
-    // XXX Make sure to not modify props.classNames because that'd be bad
22
-    // practice.
23
-    const classNames = (props.classNames && [ ...props.classNames ]) || [];
24
-
25
-    props.toggled && classNames.push('toggled');
26
-    props.unclickable && classNames.push('unclickable');
27
-
28
-    const result: MapOfAttributes = {
29
-        className: classNames.join(' '),
30
-        'data-container': 'body',
31
-        'data-placement': 'bottom',
32
-        id: props.id
33
-    };
34
-
35
-    if (!props.enabled) {
36
-        result.disabled = 'disabled';
37
-    }
38
-
39
-    if (props.hidden) {
40
-        result.style = { display: 'none' };
41
-    }
42
-
43
-    if (props.tooltipText) {
44
-        result.content = props.tooltipText;
45
-    }
46
-
47
-    return result;
48
-}
49
-
50
-/* eslint-enable flowtype/space-before-type-colon */
51
-
52
-/**
53
- * Represents a button in Toolbar on React.
54
- *
55
- * @class ToolbarButton
56
- * @extends AbstractToolbarButton
57
- */
58
-export default class StatelessToolbarButton extends AbstractToolbarButton {
59
-    _onClick: Function;
60
-
61
-    /**
62
-     * Toolbar button component's property types.
63
-     *
64
-     * @static
65
-     */
66
-    static propTypes = {
67
-        ...AbstractToolbarButton.propTypes,
68
-
69
-        /**
70
-         * Object describing button.
71
-         */
72
-        button: PropTypes.object.isRequired
73
-    };
74
-
75
-    /**
76
-     * Initializes new ToolbarButton instance.
77
-     *
78
-     * @param {Object} props - The read-only properties with which the new
79
-     * instance is to be initialized.
80
-     */
81
-    constructor(props: Object) {
82
-        super(props);
83
-
84
-        // Bind methods to save the context
85
-        this._onClick = this._onClick.bind(this);
86
-    }
87
-
88
-    /**
89
-     * Implements React's {@link Component#render()}.
90
-     *
91
-     * @inheritdoc
92
-     * @returns {ReactElement}
93
-     */
94
-    render(): React$Element<*> {
95
-        const { button } = this.props;
96
-        const attributes = getButtonAttributesByProps(button);
97
-
98
-        return (
99
-            <div className = 'toolbar-button'>
100
-                <a
101
-                    { ...attributes }
102
-                    onClick = { this._onClick }>
103
-                    { this.props.children }
104
-                </a>
105
-            </div>
106
-        );
107
-    }
108
-
109
-    /**
110
-     * Wrapper on on click handler props for current button.
111
-     *
112
-     * @param {Event} event - Click event object.
113
-     * @returns {void}
114
-     * @private
115
-     */
116
-    _onClick(event: Event): void {
117
-        const {
118
-            button,
119
-            onClick
120
-        } = this.props;
121
-        const {
122
-            enabled,
123
-            unclickable
124
-        } = button;
125
-
126
-        if (enabled && !unclickable && onClick) {
127
-            onClick(event);
128
-        }
129
-    }
130
-}

Loading…
取消
儲存