Commit 5f21143b authored by Harrison Healey's avatar Harrison Healey Committed by Christopher Speller
Browse files

PLT-3143 Added serverside code for custom Emoji (#3311)

* Added model objects for emoji

* Added database tables for emoji

* Added settings for custom emoji

* Added serverside APIs and unit tests for custom emoji

* Added additional validation to catch duplicate emoji names earlier on

* Added additional validation to prevent users from adding emoji as another user
parent 67434911
......@@ -532,6 +532,16 @@ export default class AdminSidebar extends React.Component {
}
>
{customBranding}
<AdminSidebarSection
name='custom_emoji'
title={
<FormattedMessage
id='admin.sidebar.customEmoji'
defaultMessage='Custom Emoji'
/>
}
/>
<AdminSidebarSection
name='legal_and_support'
title={
......
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
import BooleanSetting from './boolean_setting.jsx';
import DropdownSetting from './dropdown_setting.jsx';
import {FormattedMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
export default class CustomEmojiSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableCustomEmoji: props.config.ServiceSettings.EnableCustomEmoji,
restrictCustomEmojiCreation: props.config.ServiceSettings.RestrictCustomEmojiCreation
});
}
getConfigFromState(config) {
config.ServiceSettings.EnableCustomEmoji = this.state.enableCustomEmoji;
config.ServiceSettings.RestrictCustomEmojiCreation = this.state.restrictCustomEmojiCreation;
return config;
}
renderTitle() {
return (
<h3>
<FormattedMessage
id='admin.customization.customEmoji'
defaultMessage='Custom Emoji'
/>
</h3>
);
}
renderSettings() {
return (
<SettingsGroup>
<BooleanSetting
id='enableCustomEmoji'
label={
<FormattedMessage
id='admin.customization.enableCustomEmojiTitle'
defaultMessage='Enable Custom Emoji:'
/>
}
helpText={
<FormattedMessage
id='admin.customization.enableCustomEmojiDesc'
defaultMessage='Enable users to create custom emoji for use in chat messages.'
/>
}
value={this.state.enableCustomEmoji}
onChange={this.handleChange}
/>
<DropdownSetting
id='restrictCustomEmojiCreation'
values={[
{value: 'all', text: Utils.localizeMessage('admin.customization.restrictCustomEmojiCreationAll', 'Allow everyone to create custom emoji')},
{value: 'system_admin', text: Utils.localizeMessage('admin.customization.restrictCustomEmojiCreationSystemAdmin', 'Only allow system admins to create custom emoji')}
]}
label={
<FormattedMessage
id='admin.customization.restrictCustomEmojiCreationTitle'
defaultMessage='Restrict Custom Emoji Creation:'
/>
}
helpText={
<FormattedMessage
id='admin.customization.restrictCustomEmojiCreationDesc'
defaultMessage='Restrict the creation of custom emoji to certain users.'
/>
}
value={this.state.restrictCustomEmojiCreation}
onChange={this.handleChange}
disabled={!this.state.enableCustomEmoji}
/>
</SettingsGroup>
);
}
}
\ No newline at end of file
......@@ -125,6 +125,13 @@
"admin.connectionSecurityTitle": "Connection Security:",
"admin.connectionSecurityTls": "TLS",
"admin.connectionSecurityTlsDescription": "Encrypts the communication between Mattermost and your server.",
"admin.customization.customEmoji": "Custom Emoji",
"admin.customization.enableCustomEmojiDesc": "Enable users to create custom emoji for use in chat messages.",
"admin.customization.enableCustomEmojiTitle": "Enable Custom Emoji:",
"admin.customization.restrictCustomEmojiCreationAll": "Allow everyone to create custom emoji",
"admin.customization.restrictCustomEmojiCreationDesc": "Restrict the creation of custom emoji to certain users.",
"admin.customization.restrictCustomEmojiCreationSystemAdmin": "Only allow system admins to create custom emoji",
"admin.customization.restrictCustomEmojiCreationTitle": "Restrict Custom Emoji Creation:",
"admin.email.agreeHPNS": " I understand and accept the Mattermost Hosted Push Notification Service <a href=\"https://about.mattermost.com/hpns-terms/\" target=\"_blank\">Terms of Service</a> and <a href=\"https://about.mattermost.com/hpns-privacy/\" target=\"_blank\">Privacy Policy</a>.",
"admin.email.allowEmailSignInDescription": "When true, Mattermost allows users to sign in using their email and password.",
"admin.email.allowEmailSignInTitle": "Allow Sign In With Email: ",
......@@ -422,6 +429,7 @@
"admin.sidebar.configuration": "Configuration",
"admin.sidebar.connections": "Connections",
"admin.sidebar.customBrand": "Custom Branding",
"admin.sidebar.customEmoji": "Custom Emoji",
"admin.sidebar.customization": "Customization",
"admin.sidebar.database": "Database",
"admin.sidebar.developer": "Developer",
......
......@@ -73,6 +73,7 @@ import DatabaseSettings from 'components/admin_console/database_settings.jsx';
import StorageSettings from 'components/admin_console/storage_settings.jsx';
import ImageSettings from 'components/admin_console/image_settings.jsx';
import CustomBrandSettings from 'components/admin_console/custom_brand_settings.jsx';
import CustomEmojiSettings from 'components/admin_console/custom_emoji_settings.jsx';
import LegalAndSupportSettings from 'components/admin_console/legal_and_support_settings.jsx';
import ComplianceSettings from 'components/admin_console/compliance_settings.jsx';
import RateSettings from 'components/admin_console/rate_settings.jsx';
......@@ -461,6 +462,10 @@ function renderRootComponent() {
path='custom_brand'
component={CustomBrandSettings}
/>
<Route
path='custom_emoji'
component={CustomEmojiSettings}
/>
<Route
path='legal_and_support'
component={LegalAndSupportSettings}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment