Этот коммит содержится в:
=Corey Hulen
2015-09-24 10:52:32 -07:00
родитель 6c0d094d13
Коммит a374419ad5
7 изменённых файлов: 5 добавлений и 291 удалений

Просмотреть файл

@@ -1,190 +0,0 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var SettingItemMin = require('./setting_item_min.jsx');
var SettingItemMax = require('./setting_item_max.jsx');
var Client = require('../utils/client.jsx');
var AsyncClient = require('../utils/async_client.jsx');
export default class FeatureTab extends React.Component {
constructor(props) {
super(props);
this.submitValetFeature = this.submitValetFeature.bind(this);
this.handleValetRadio = this.handleValetRadio.bind(this);
this.onUpdateSection = this.onUpdateSection.bind(this);
this.setupInitialState = this.setupInitialState.bind(this);
this.state = this.setupInitialState();
}
componentWillReceiveProps(newProps) {
var team = newProps.team;
var allowValet = 'false';
if (team && team.allow_valet) {
allowValet = 'true';
}
this.setState({allowValet: allowValet});
}
submitValetFeature() {
var data = {};
data.allow_valet = this.state.allowValet;
Client.updateValetFeature(data,
function success() {
this.props.updateSection('');
AsyncClient.getMyTeam();
}.bind(this),
function fail(err) {
var state = this.setupInitialState();
state.serverError = err;
this.setState(state);
}.bind(this)
);
}
handleValetRadio(val) {
this.setState({allowValet: val});
React.findDOMNode(this.refs.wrapper).focus();
}
onUpdateSection(e) {
e.preventDefault();
if (this.props.activeSection === 'valet') {
this.props.updateSection('');
} else {
this.props.updateSection('valet');
}
}
setupInitialState() {
var allowValet;
var team = this.props.team;
if (team && team.allow_valet) {
allowValet = 'true';
} else {
allowValet = 'false';
}
return {allowValet: allowValet};
}
render() {
var clientError = null;
var serverError = null;
if (this.state.clientError) {
clientError = this.state.clientError;
}
if (this.state.serverError) {
serverError = this.state.serverError;
}
var valetSection;
if (this.props.activeSection === 'valet') {
var valetActive = [false, false];
if (this.state.allowValet === 'false') {
valetActive[1] = true;
} else {
valetActive[0] = true;
}
let inputs = [];
inputs.push(
<div key='teamValetSetting'>
<div className='radio'>
<label>
<input
type='radio'
checked={valetActive[0]}
onChange={this.handleValetRadio.bind(this, 'true')}
>
On
</input>
</label>
<br/>
</div>
<div className='radio'>
<label>
<input
type='radio'
checked={valetActive[1]}
onChange={this.handleValetRadio.bind(this, 'false')}
>
Off
</input>
</label>
<br/>
</div>
<div><br/>Valet is a preview feature for enabling a non-user account limited to basic member permissions that can be manipulated by 3rd parties.<br/><br/>IMPORTANT: The preview version of Valet should not be used without a secure connection and a trusted 3rd party, since user credentials are used to connect. OAuth2 will be used in the final release.</div>
</div>
);
valetSection = (
<SettingItemMax
title='Valet (Preview - EXPERTS ONLY)'
inputs={inputs}
submit={this.submitValetFeature}
server_error={serverError}
client_error={clientError}
updateSection={this.onUpdateSection}
/>
);
} else {
var describe = '';
if (this.state.allowValet === 'false') {
describe = 'Off';
} else {
describe = 'On';
}
valetSection = (
<SettingItemMin
title='Valet (Preview - EXPERTS ONLY)'
describe={describe}
updateSection={this.onUpdateSection}
/>
);
}
return (
<div>
<div className='modal-header'>
<button
type='button'
className='close'
data-dismiss='modal'
aria-label='Close'
>
<span aria-hidden='true'>&times;</span>
</button>
<h4
className='modal-title'
ref='title'
>
<i className='modal-back'></i>Advanced Features
</h4>
</div>
<div
ref='wrapper'
className='user-settings'
>
<h3 className='tab-header'>Advanced Features</h3>
<div className='divider-dark first'/>
{valetSection}
<div className='divider-dark'/>
</div>
</div>
);
}
}
FeatureTab.defaultProps = {
team: {},
activeSection: ''
};
FeatureTab.propTypes = {
updateSection: React.PropTypes.func.isRequired,
team: React.PropTypes.object.isRequired,
activeSection: React.PropTypes.string.isRequired
};

Просмотреть файл

@@ -4,7 +4,6 @@
var TeamStore = require('../stores/team_store.jsx');
var ImportTab = require('./team_import_tab.jsx');
var ExportTab = require('./team_export_tab.jsx');
var FeatureTab = require('./team_feature_tab.jsx');
var GeneralTab = require('./team_general_tab.jsx');
var Utils = require('../utils/utils.jsx');
@@ -25,7 +24,7 @@ export default class TeamSettings extends React.Component {
onChange() {
var team = TeamStore.getCurrent();
if (!Utils.areStatesEqual(this.state.team, team)) {
this.setState({team: team});
this.setState({team});
}
}
render() {
@@ -43,17 +42,6 @@ export default class TeamSettings extends React.Component {
</div>
);
break;
case 'feature':
result = (
<div>
<FeatureTab
team={this.state.team}
activeSection={this.props.activeSection}
updateSection={this.props.updateSection}
/>
</div>
);
break;
case 'import':
result = (
<div>

Просмотреть файл

@@ -20,8 +20,8 @@ export default class TeamSettingsModal extends React.Component {
$('body').on('click', '.modal-back', function handleBackClick() {
$(this).closest('.modal-dialog').removeClass('display--content');
});
$('body').on('click', '.modal-header .close', function handleCloseClick() {
setTimeout(function removeContent() {
$('body').on('click', '.modal-header .close', () => {
setTimeout(() => {
$('.modal-dialog.display--content').removeClass('display--content');
}, 500);
});
@@ -33,11 +33,10 @@ export default class TeamSettingsModal extends React.Component {
this.setState({activeSection: section});
}
render() {
let tabs = [];
const tabs = [];
tabs.push({name: 'general', uiName: 'General', icon: 'glyphicon glyphicon-cog'});
tabs.push({name: 'import', uiName: 'Import', icon: 'glyphicon glyphicon-upload'});
tabs.push({name: 'export', uiName: 'Export', icon: 'glyphicon glyphicon-download'});
tabs.push({name: 'feature', uiName: 'Advanced', icon: 'glyphicon glyphicon-wrench'});
return (
<div
@@ -63,7 +62,7 @@ export default class TeamSettingsModal extends React.Component {
className='modal-title'
ref='title'
>
Team Settings
{'Team Settings'}
</h4>
</div>
<div className='modal-body'>

Просмотреть файл

@@ -1042,23 +1042,6 @@ export function getMyTeam(success, error) {
});
}
export function updateValetFeature(data, success, error) {
$.ajax({
url: '/api/v1/teams/update_valet_feature',
dataType: 'json',
contentType: 'application/json',
type: 'POST',
data: JSON.stringify(data),
success,
error: function onError(xhr, status, err) {
var e = handleError('updateValetFeature', xhr, status, err);
error(e);
}
});
track('api', 'api_teams_update_valet_feature');
}
export function registerOAuthApp(app, success, error) {
$.ajax({
url: '/api/v1/oauth/register',