Merge pull request #787 from mattermost/PLT-30
PLT-30 Removing old valet crud
Этот коммит содержится в:
47
api/team.go
47
api/team.go
@@ -31,7 +31,6 @@ func InitTeam(r *mux.Router) {
|
|||||||
sr.Handle("/email_teams", ApiAppHandler(emailTeams)).Methods("POST")
|
sr.Handle("/email_teams", ApiAppHandler(emailTeams)).Methods("POST")
|
||||||
sr.Handle("/invite_members", ApiUserRequired(inviteMembers)).Methods("POST")
|
sr.Handle("/invite_members", ApiUserRequired(inviteMembers)).Methods("POST")
|
||||||
sr.Handle("/update_name", ApiUserRequired(updateTeamDisplayName)).Methods("POST")
|
sr.Handle("/update_name", ApiUserRequired(updateTeamDisplayName)).Methods("POST")
|
||||||
sr.Handle("/update_valet_feature", ApiUserRequired(updateValetFeature)).Methods("POST")
|
|
||||||
sr.Handle("/me", ApiUserRequired(getMyTeam)).Methods("GET")
|
sr.Handle("/me", ApiUserRequired(getMyTeam)).Methods("GET")
|
||||||
// These should be moved to the global admain console
|
// These should be moved to the global admain console
|
||||||
sr.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST")
|
sr.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST")
|
||||||
@@ -581,52 +580,6 @@ func updateTeamDisplayName(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Write([]byte(model.MapToJson(props)))
|
w.Write([]byte(model.MapToJson(props)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateValetFeature(c *Context, w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
props := model.MapFromJson(r.Body)
|
|
||||||
|
|
||||||
allowValetStr := props["allow_valet"]
|
|
||||||
if len(allowValetStr) == 0 {
|
|
||||||
c.SetInvalidParam("updateValetFeature", "allow_valet")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
teamId := props["team_id"]
|
|
||||||
if len(teamId) > 0 && len(teamId) != 26 {
|
|
||||||
c.SetInvalidParam("updateValetFeature", "team_id")
|
|
||||||
return
|
|
||||||
} else if len(teamId) == 0 {
|
|
||||||
teamId = c.Session.TeamId
|
|
||||||
}
|
|
||||||
|
|
||||||
tchan := Srv.Store.Team().Get(teamId)
|
|
||||||
|
|
||||||
if !c.HasPermissionsToTeam(teamId, "updateValetFeature") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
|
||||||
c.Err = model.NewAppError("updateValetFeature", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
|
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var team *model.Team
|
|
||||||
if tResult := <-tchan; tResult.Err != nil {
|
|
||||||
c.Err = tResult.Err
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
team = tResult.Data.(*model.Team)
|
|
||||||
}
|
|
||||||
|
|
||||||
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
|
|
||||||
c.Err = result.Err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.Write([]byte(model.MapToJson(props)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if len(c.Session.TeamId) == 0 {
|
if len(c.Session.TeamId) == 0 {
|
||||||
|
|||||||
@@ -218,15 +218,6 @@ func (c *Client) UpdateTeamDisplayName(data map[string]string) (*Result, *AppErr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateValetFeature(data map[string]string) (*Result, *AppError) {
|
|
||||||
if r, err := c.DoApiPost("/teams/update_valet_feature", MapToJson(data)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else {
|
|
||||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
|
||||||
r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) CreateUser(user *User, hash string) (*Result, *AppError) {
|
func (c *Client) CreateUser(user *User, hash string) (*Result, *AppError) {
|
||||||
if r, err := c.DoApiPost("/users/create", user.ToJson()); err != nil {
|
if r, err := c.DoApiPost("/users/create", user.ToJson()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -580,15 +571,6 @@ func (c *Client) CreatePost(post *Post) (*Result, *AppError) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateValetPost(post *Post) (*Result, *AppError) {
|
|
||||||
if r, err := c.DoApiPost("/channels/"+post.ChannelId+"/valet_create", post.ToJson()); err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else {
|
|
||||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
|
||||||
r.Header.Get(HEADER_ETAG_SERVER), PostFromJson(r.Body)}, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UpdatePost(post *Post) (*Result, *AppError) {
|
func (c *Client) UpdatePost(post *Post) (*Result, *AppError) {
|
||||||
if r, err := c.DoApiPost("/channels/"+post.ChannelId+"/update", post.ToJson()); err != nil {
|
if r, err := c.DoApiPost("/channels/"+post.ChannelId+"/update", post.ToJson()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ const (
|
|||||||
USER_NOTIFY_ALL = "all"
|
USER_NOTIFY_ALL = "all"
|
||||||
USER_NOTIFY_MENTION = "mention"
|
USER_NOTIFY_MENTION = "mention"
|
||||||
USER_NOTIFY_NONE = "none"
|
USER_NOTIFY_NONE = "none"
|
||||||
BOT_USERNAME = "valet"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|||||||
@@ -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'>×</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 TeamStore = require('../stores/team_store.jsx');
|
||||||
var ImportTab = require('./team_import_tab.jsx');
|
var ImportTab = require('./team_import_tab.jsx');
|
||||||
var ExportTab = require('./team_export_tab.jsx');
|
var ExportTab = require('./team_export_tab.jsx');
|
||||||
var FeatureTab = require('./team_feature_tab.jsx');
|
|
||||||
var GeneralTab = require('./team_general_tab.jsx');
|
var GeneralTab = require('./team_general_tab.jsx');
|
||||||
var Utils = require('../utils/utils.jsx');
|
var Utils = require('../utils/utils.jsx');
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ export default class TeamSettings extends React.Component {
|
|||||||
onChange() {
|
onChange() {
|
||||||
var team = TeamStore.getCurrent();
|
var team = TeamStore.getCurrent();
|
||||||
if (!Utils.areStatesEqual(this.state.team, team)) {
|
if (!Utils.areStatesEqual(this.state.team, team)) {
|
||||||
this.setState({team: team});
|
this.setState({team});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
@@ -43,17 +42,6 @@ export default class TeamSettings extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'feature':
|
|
||||||
result = (
|
|
||||||
<div>
|
|
||||||
<FeatureTab
|
|
||||||
team={this.state.team}
|
|
||||||
activeSection={this.props.activeSection}
|
|
||||||
updateSection={this.props.updateSection}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'import':
|
case 'import':
|
||||||
result = (
|
result = (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ export default class TeamSettingsModal extends React.Component {
|
|||||||
$('body').on('click', '.modal-back', function handleBackClick() {
|
$('body').on('click', '.modal-back', function handleBackClick() {
|
||||||
$(this).closest('.modal-dialog').removeClass('display--content');
|
$(this).closest('.modal-dialog').removeClass('display--content');
|
||||||
});
|
});
|
||||||
$('body').on('click', '.modal-header .close', function handleCloseClick() {
|
$('body').on('click', '.modal-header .close', () => {
|
||||||
setTimeout(function removeContent() {
|
setTimeout(() => {
|
||||||
$('.modal-dialog.display--content').removeClass('display--content');
|
$('.modal-dialog.display--content').removeClass('display--content');
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
@@ -33,13 +33,12 @@ export default class TeamSettingsModal extends React.Component {
|
|||||||
this.setState({activeSection: section});
|
this.setState({activeSection: section});
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
let tabs = [];
|
const tabs = [];
|
||||||
tabs.push({name: 'general', uiName: 'General', icon: 'glyphicon glyphicon-cog'});
|
tabs.push({name: 'general', uiName: 'General', icon: 'glyphicon glyphicon-cog'});
|
||||||
tabs.push({name: 'import', uiName: 'Import', icon: 'glyphicon glyphicon-upload'});
|
tabs.push({name: 'import', uiName: 'Import', icon: 'glyphicon glyphicon-upload'});
|
||||||
|
|
||||||
// To enable export uncomment this line
|
// To enable export uncomment this line
|
||||||
//tabs.push({name: 'export', uiName: 'Export', icon: 'glyphicon glyphicon-download'});
|
//tabs.push({name: 'export', uiName: 'Export', icon: 'glyphicon glyphicon-download'});
|
||||||
tabs.push({name: 'feature', uiName: 'Advanced', icon: 'glyphicon glyphicon-wrench'});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -65,7 +64,7 @@ export default class TeamSettingsModal extends React.Component {
|
|||||||
className='modal-title'
|
className='modal-title'
|
||||||
ref='title'
|
ref='title'
|
||||||
>
|
>
|
||||||
Team Settings
|
{'Team Settings'}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div className='modal-body'>
|
<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) {
|
export function registerOAuthApp(app, success, error) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/api/v1/oauth/register',
|
url: '/api/v1/oauth/register',
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user