summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/team.go8
-rw-r--r--api/team_test.go9
-rw-r--r--model/client.go2
-rw-r--r--web/react/components/navbar_dropdown.jsx13
4 files changed, 18 insertions, 14 deletions
diff --git a/api/team.go b/api/team.go
index 6aa5ec1bb..7148caac3 100644
--- a/api/team.go
+++ b/api/team.go
@@ -409,14 +409,12 @@ func findTeams(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
teams := result.Data.([]*model.Team)
-
- s := make([]string, 0, len(teams))
-
+ m := make(map[string]*model.Team)
for _, v := range teams {
- s = append(s, v.Name)
+ m[v.Id] = v
}
- w.Write([]byte(model.ArrayToJson(s)))
+ w.Write([]byte(model.TeamMapToJson(m)))
}
}
diff --git a/api/team_test.go b/api/team_test.go
index 9b701911b..507f4252a 100644
--- a/api/team_test.go
+++ b/api/team_test.go
@@ -121,9 +121,12 @@ func TestFindTeamByEmail(t *testing.T) {
if r1, err := Client.FindTeams(user.Email); err != nil {
t.Fatal(err)
} else {
- domains := r1.Data.([]string)
- if domains[0] != team.Name {
- t.Fatal(domains)
+ teams := r1.Data.(map[string]*model.Team)
+ if teams[team.Id].Name != team.Name {
+ t.Fatal()
+ }
+ if teams[team.Id].DisplayName != team.DisplayName {
+ t.Fatal()
}
}
diff --git a/model/client.go b/model/client.go
index 77b0aaad2..19c99df72 100644
--- a/model/client.go
+++ b/model/client.go
@@ -185,7 +185,7 @@ func (c *Client) FindTeams(email string) (*Result, *AppError) {
} else {
return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ArrayFromJson(r.Body)}, nil
+ r.Header.Get(HEADER_ETAG_SERVER), TeamMapFromJson(r.Body)}, nil
}
}
diff --git a/web/react/components/navbar_dropdown.jsx b/web/react/components/navbar_dropdown.jsx
index 49d517419..b3f8e4418 100644
--- a/web/react/components/navbar_dropdown.jsx
+++ b/web/react/components/navbar_dropdown.jsx
@@ -145,7 +145,7 @@ export default class NavbarDropdown extends React.Component {
var teams = [];
- if (this.state.teams.length > 1) {
+ if (Object.keys(this.state.teams).length > 1) {
teams.push(
<li
className='divider'
@@ -154,11 +154,14 @@ export default class NavbarDropdown extends React.Component {
</li>
);
- this.state.teams.forEach((teamName) => {
- if (teamName !== this.props.teamName) {
- teams.push(<li key={teamName}><a href={Utils.getWindowLocationOrigin() + '/' + teamName}>{'Switch to ' + teamName}</a></li>);
+ for (let teamId in this.state.teams) {
+ if (this.state.teams.hasOwnProperty(teamId)) {
+ let team = this.state.teams[teamId];
+ if (team.name !== this.props.teamName) {
+ teams.push(<li key={team.name}><a href={Utils.getWindowLocationOrigin() + '/' + team.name}>{'Switch to ' + team.display_name}</a></li>);
+ }
}
- });
+ }
}
if (global.window.config.EnableTeamCreation === 'true') {