emoji_page.jsx 2.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import React from 'react';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import {Link} from 'react-router-dom';

import * as Utils from 'utils/utils.jsx';

import EmojiList from './emoji_list';

export default class EmojiPage extends React.Component {
    static propTypes = {

        /**
         * Non-UI team name for the current team.
         */
        teamName: PropTypes.string.isRequired,

        /**
         * UI team name for the current team.
         */
        teamDisplayName: PropTypes.string.isRequired,

        /**
         * Title of the app or site.
         */
29
30
31
32
33
        siteName: PropTypes.string,

        /**
         * Function to scroll list to top.
         */
34
        scrollToTop: PropTypes.func.isRequired,
35
36
37
38
39
    }

    static defaultProps = {
        teamName: '',
        teamDisplayName: '',
40
        siteName: '',
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
    }

    componentDidMount() {
        this.updateTitle();
    }

    updateTitle = (props = this.props) => {
        document.title = Utils.localizeMessage('custom_emoji.header', 'Custom Emoji') + ' - ' + props.teamDisplayName + ' ' + props.siteName;
    }

    componentWillReceiveProps(nextProps) {
        if (this.props.siteName !== nextProps.siteName) {
            this.updateTitle(nextProps);
        }
    }

    render() {
        return (
            <div className='backstage-content emoji-list'>
                <div className='backstage-header'>
                    <h1>
                        <FormattedMessage
                            id='emoji_list.header'
                            defaultMessage='Custom Emoji'
                        />
                    </h1>
                    <Link
                        className='add-link'
                        to={'/' + this.props.teamName + '/emoji/add'}
                    >
                        <button
                            type='button'
                            className='btn btn-primary'
                        >
                            <FormattedMessage
                                id='emoji_list.add'
                                defaultMessage='Add Custom Emoji'
                            />
                        </button>
                    </Link>
81
                    <EmojiList scrollToTop={this.props.scrollToTop}/>
82
83
84
85
86
                </div>
            </div>
        );
    }
}