fix command comparator and team store
Этот коммит содержится в:
@@ -9,6 +9,8 @@ import (
|
|||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
"github.com/mattermost/platform/utils"
|
"github.com/mattermost/platform/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -19,14 +21,13 @@ var commands = []commandHandler{
|
|||||||
logoutCommand,
|
logoutCommand,
|
||||||
joinCommand,
|
joinCommand,
|
||||||
loadTestCommand,
|
loadTestCommand,
|
||||||
|
echoCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitCommand(r *mux.Router) {
|
func InitCommand(r *mux.Router) {
|
||||||
l4g.Debug("Initializing command api routes")
|
l4g.Debug("Initializing command api routes")
|
||||||
r.Handle("/command", ApiUserRequired(command)).Methods("POST")
|
r.Handle("/command", ApiUserRequired(command)).Methods("POST")
|
||||||
|
|
||||||
commands = append(commands, echoCommand)
|
|
||||||
|
|
||||||
hub.Start()
|
hub.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +76,10 @@ func checkCommand(c *Context, command *model.Command) bool {
|
|||||||
allowValet = tResult.Data.(*model.Team).AllowValet
|
allowValet = tResult.Data.(*model.Team).AllowValet
|
||||||
}
|
}
|
||||||
|
|
||||||
var ec commandHandler
|
ec := runtime.FuncForPC(reflect.ValueOf(echoCommand).Pointer()).Name()
|
||||||
ec = echoCommand
|
|
||||||
for _, v := range commands {
|
for _, v := range commands {
|
||||||
if !allowValet && &v == &ec {
|
if !allowValet && ec == runtime.FuncForPC(reflect.ValueOf(v).Pointer()).Name() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,16 @@ var FeatureTab = React.createClass({
|
|||||||
this.setState({ allow_valet: val });
|
this.setState({ allow_valet: val });
|
||||||
this.refs.wrapper.getDOMNode().focus();
|
this.refs.wrapper.getDOMNode().focus();
|
||||||
},
|
},
|
||||||
|
componentWillReceiveProps: function(newProps) {
|
||||||
|
var team = newProps.team;
|
||||||
|
|
||||||
|
var allow_valet = "false";
|
||||||
|
if (team && team.allow_valet) {
|
||||||
|
allow_valet = "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ allow_valet: allow_valet });
|
||||||
|
},
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
var team = this.props.team;
|
var team = this.props.team;
|
||||||
|
|
||||||
|
|||||||
@@ -22,35 +22,20 @@ var TeamStore = assign({}, EventEmitter.prototype, {
|
|||||||
this.removeListener(CHANGE_EVENT, callback);
|
this.removeListener(CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
get: function(id) {
|
get: function(id) {
|
||||||
var current = null;
|
|
||||||
var c = this._getTeams();
|
var c = this._getTeams();
|
||||||
|
return c[id];
|
||||||
c.some(function(team) {
|
|
||||||
if (team.id == id) {
|
|
||||||
current = team;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return current;
|
|
||||||
},
|
},
|
||||||
getByName: function(name) {
|
getByName: function(name) {
|
||||||
var current = null;
|
var current = null;
|
||||||
var c = this._getTeams();
|
var t = this._getTeams();
|
||||||
|
|
||||||
c.some(function(team) {
|
for (id in t) {
|
||||||
if (team.name == name) {
|
if (t[id].name == name) {
|
||||||
current = team;
|
return t[id];
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return current;
|
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
getAll: function() {
|
getAll: function() {
|
||||||
return this._getTeams();
|
return this._getTeams();
|
||||||
@@ -78,12 +63,13 @@ var TeamStore = assign({}, EventEmitter.prototype, {
|
|||||||
this._storeTeams(teams);
|
this._storeTeams(teams);
|
||||||
},
|
},
|
||||||
_storeTeams: function(teams) {
|
_storeTeams: function(teams) {
|
||||||
sessionStorage.setItem("teams", JSON.stringify(teams));
|
sessionStorage.setItem("user_teams", JSON.stringify(teams));
|
||||||
},
|
},
|
||||||
_getTeams: function() {
|
_getTeams: function() {
|
||||||
var teams = [];
|
var teams = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
teams = JSON.parse(sessionStorage.teams);
|
teams = JSON.parse(sessionStorage.user_teams);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user