// 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 {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import BooleanSetting from './boolean_setting.jsx';
import TextSetting from './text_setting.jsx';
export default class WebrtcSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
getConfigFromState(config) {
config.WebrtcSettings.Enable = this.state.enableWebrtc;
config.WebrtcSettings.GatewayWebsocketUrl = this.state.gatewayWebsocketUrl;
config.WebrtcSettings.GatewayAdminUrl = this.state.gatewayAdminUrl;
config.WebrtcSettings.GatewayAdminSecret = this.state.gatewayAdminSecret;
config.WebrtcSettings.StunURI = this.state.stunURI;
config.WebrtcSettings.TurnURI = this.state.turnURI;
config.WebrtcSettings.TurnUsername = this.state.turnUsername;
config.WebrtcSettings.TurnSharedKey = this.state.turnSharedKey;
return config;
}
getStateFromConfig(config) {
const settings = config.WebrtcSettings;
return {
hasErrors: false,
enableWebrtc: settings.Enable,
gatewayWebsocketUrl: settings.GatewayWebsocketUrl,
gatewayAdminUrl: settings.GatewayAdminUrl,
gatewayAdminSecret: settings.GatewayAdminSecret,
stunURI: settings.StunURI,
turnURI: settings.TurnURI,
turnUsername: settings.TurnUsername,
turnSharedKey: settings.TurnSharedKey
};
}
renderTitle() {
return (
);
}
renderSettings() {
return (
}
helpText={
}
value={this.state.enableWebrtc}
onChange={this.handleChange}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.gatewayWebsocketUrlExample', 'Ex "wss://webrtc.mattermost.com:8189"')}
helpText={
}
value={this.state.gatewayWebsocketUrl}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.gatewayAdminUrlExample', 'Ex "https://webrtc.mattermost.com:7089/admin"')}
helpText={
}
value={this.state.gatewayAdminUrl}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.gatewayAdminSecretExample', 'Ex "PVRzWNN1Tg6szn7IQWvhpAvLByScWxdy"')}
helpText={
}
value={this.state.gatewayAdminSecret}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.stunUriExample', 'Ex "stun:webrtc.mattermost.com:5349"')}
helpText={
}
value={this.state.stunURI}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.turnUriExample', 'Ex "turn:webrtc.mattermost.com:5349"')}
helpText={
}
value={this.state.turnURI}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.turnUsernameExample', 'Ex "myusername"')}
helpText={
}
value={this.state.turnUsername}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc || !this.state.turnURI}
/>
}
placeholder={Utils.localizeMessage('admin.webrtc.turnSharedKeyExample', 'Ex "bXdkOWQxc3d0Ynk3emY5ZmsxZ3NtazRjaWg="')}
helpText={
}
value={this.state.turnSharedKey}
onChange={this.handleChange}
disabled={!this.state.enableWebrtc || !this.state.turnURI}
/>
);
}
}