summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-06-14 09:38:19 -0400
committerChristopher Speller <crspeller@gmail.com>2016-06-14 07:38:19 -0600
commita0cc913b85dea5023b705697afa5cd8749a6e5de (patch)
treedebe3365ea1e66e94bd0a4738bf4faa0f10eac05 /webapp
parent661f221727109f2298812fea89347bfeaf984109 (diff)
downloadchat-a0cc913b85dea5023b705697afa5cd8749a6e5de.tar.gz
chat-a0cc913b85dea5023b705697afa5cd8749a6e5de.tar.bz2
chat-a0cc913b85dea5023b705697afa5cd8749a6e5de.zip
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
Diffstat (limited to 'webapp')
-rw-r--r--webapp/components/admin_console/admin_sidebar.jsx10
-rw-r--r--webapp/components/admin_console/custom_emoji_settings.jsx91
-rw-r--r--webapp/i18n/en.json8
-rw-r--r--webapp/root.jsx5
4 files changed, 114 insertions, 0 deletions
diff --git a/webapp/components/admin_console/admin_sidebar.jsx b/webapp/components/admin_console/admin_sidebar.jsx
index c947be5cb..28769d484 100644
--- a/webapp/components/admin_console/admin_sidebar.jsx
+++ b/webapp/components/admin_console/admin_sidebar.jsx
@@ -533,6 +533,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={
<FormattedMessage
diff --git a/webapp/components/admin_console/custom_emoji_settings.jsx b/webapp/components/admin_console/custom_emoji_settings.jsx
new file mode 100644
index 000000000..332c7b216
--- /dev/null
+++ b/webapp/components/admin_console/custom_emoji_settings.jsx
@@ -0,0 +1,91 @@
+// 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
diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json
index 85f221c7c..b1ab4964f 100644
--- a/webapp/i18n/en.json
+++ b/webapp/i18n/en.json
@@ -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",
diff --git a/webapp/root.jsx b/webapp/root.jsx
index a96ab713b..b6302a76f 100644
--- a/webapp/root.jsx
+++ b/webapp/root.jsx
@@ -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';
@@ -462,6 +463,10 @@ function renderRootComponent() {
component={CustomBrandSettings}
/>
<Route
+ path='custom_emoji'
+ component={CustomEmojiSettings}
+ />
+ <Route
path='legal_and_support'
component={LegalAndSupportSettings}
/>