// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import SettingItemMin from 'components/setting_item_min.jsx';
import SettingItemMax from 'components/setting_item_max.jsx';
import * as Utils from 'utils/utils.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
import React from 'react';
import {FormattedMessage} from 'react-intl';
export default class DesktopNotificationSettings extends React.Component {
constructor(props) {
super(props);
this.buildMaximizedSetting = this.buildMaximizedSetting.bind(this);
this.buildMinimizedSetting = this.buildMinimizedSetting.bind(this);
this.state = {};
}
buildMaximizedSetting() {
const inputs = [];
let extraInfo = null;
const activityRadio = [false, false, false];
if (this.props.activity === 'mention') {
activityRadio[1] = true;
} else if (this.props.activity === 'none') {
activityRadio[2] = true;
} else {
activityRadio[0] = true;
}
let soundSection;
let durationSection;
if (this.props.activity !== 'none') {
const soundRadio = [false, false];
if (this.props.sound === 'false') {
soundRadio[1] = true;
} else {
soundRadio[0] = true;
}
if (UserAgent.isFirefox()) {
soundSection = (
);
} else {
soundSection = (
);
}
const durationRadio = [false, false, false, false];
if (this.props.duration === '3') {
durationRadio[0] = true;
} else if (this.props.duration === '10') {
durationRadio[2] = true;
} else if (this.props.duration === '0') {
durationRadio[3] = true;
} else {
durationRadio[1] = true;
}
durationSection = (
);
extraInfo = (
);
}
inputs.push(
);
return (
);
}
buildMinimizedSetting() {
let describe = '';
if (this.props.activity === 'mention') {
if (UserAgent.isFirefox()) {
if (this.props.duration === '0') {
describe = (
);
} else {
describe = (
);
}
} else if (this.props.sound === 'false') {
if (this.props.duration === '0') {
describe = (
);
} else {
describe = (
);
}
} else {
if (this.props.duration === '0') { //eslint-disable-line no-lonely-if
describe = (
);
} else {
describe = (
);
}
}
} else if (this.props.activity === 'none') {
describe = (
);
} else {
if (UserAgent.isFirefox()) { //eslint-disable-line no-lonely-if
if (this.props.duration === '0') {
describe = (
);
} else {
describe = (
);
}
} else if (this.props.sound === 'false') {
if (this.props.duration === '0') {
describe = (
);
} else {
describe = (
);
}
} else {
if (this.props.duration === '0') { //eslint-disable-line no-lonely-if
describe = (
);
} else {
describe = (
);
}
}
}
const handleUpdateDesktopSection = function updateDesktopSection() {
this.props.updateSection('desktop');
}.bind(this);
return (
);
}
render() {
if (this.props.active) {
return this.buildMaximizedSetting();
}
return this.buildMinimizedSetting();
}
}
DesktopNotificationSettings.propTypes = {
activity: React.PropTypes.string.isRequired,
sound: React.PropTypes.string.isRequired,
duration: React.PropTypes.string.isRequired,
updateSection: React.PropTypes.func,
setParentState: React.PropTypes.func,
submit: React.PropTypes.func,
cancel: React.PropTypes.func,
error: React.PropTypes.string,
active: React.PropTypes.bool
};