forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_gif_settings.jsx
107 lines (98 loc) · 4.02 KB
/
custom_gif_settings.jsx
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
29
30
31
32
33
34
35
36
37
38
39
40
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {FormattedMessage} from 'react-intl';
import AdminSettings from './admin_settings.jsx';
import BooleanSetting from './boolean_setting.jsx';
import TextSetting from './text_setting.jsx';
import SettingsGroup from './settings_group.jsx';
export default class CustomGifSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
getConfigFromState(config) {
config.ServiceSettings.EnableGifPicker = this.state.enableGifPicker;
config.ServiceSettings.GfycatApiKey = this.state.gfycatApiKey;
config.ServiceSettings.GfycatApiSecret = this.state.gfycatApiSecret;
return config;
}
getStateFromConfig(config) {
return {
enableGifPicker: config.ServiceSettings.EnableGifPicker,
gfycatApiKey: config.ServiceSettings.GfycatApiKey,
gfycatApiSecret: config.ServiceSettings.GfycatApiSecret,
};
}
renderTitle() {
return (
<FormattedMessage
id='admin.customization.gif'
defaultMessage='GIF (Beta)'
/>
);
}
renderSettings() {
return (
<SettingsGroup>
<BooleanSetting
id='enableGifPicker'
label={
<FormattedMessage
id='admin.customization.enableGifPickerTitle'
defaultMessage='Enable GIF Picker:'
/>
}
helpText={
<FormattedMessage
id='admin.customization.enableGifPickerDesc'
defaultMessage='Allow users to select GIFs from the emoji picker via a Gfycat integration.'
/>
}
value={this.state.enableGifPicker}
onChange={this.handleChange}
setByEnv={this.isSetByEnv('ServiceSettings.EnableGifPicker')}
/>
<TextSetting
id='gfycatApiKey'
label={
<FormattedMessage
id='admin.customization.gfycatApiKey'
defaultMessage='Gfycat API Key:'
/>
}
helpText={
<FormattedMessage
id='admin.customization.gfycatApiKeyDescription'
defaultMessage='Request an API key at https://developers.gfycat.com/signup/#/. Enter the client ID you receive via email to this field.'
/>
}
value={this.state.gfycatApiKey}
placeholder=''
onChange={this.handleChange}
setByEnv={this.isSetByEnv('ServiceSettings.GfycatAPIKey')}
/>
<TextSetting
id='gfycatApiSecret'
label={
<FormattedMessage
id='admin.customization.gfycatApiSecret'
defaultMessage='Gfycat API Secret:'
/>
}
helpText={
<FormattedMessage
id='admin.customization.gfycatApiSecretDescription'
defaultMessage='The API secret generated by Gfycat for your API key.'
/>
}
value={this.state.gfycatApiSecret}
placeholder=''
onChange={this.handleChange}
setByEnv={this.isSetByEnv('ServiceSettings.GfycatAPISecret')}
/>
</SettingsGroup>
);
}
}