summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Wang <R-Wang97@users.noreply.github.com>2016-08-25 10:45:24 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-08-25 10:45:24 -0400
commitdfaccff44be27c1f8b144941b4c7793744278862 (patch)
treee648f27c780bb7e519632b83b86babbf7f843725
parentb49a019cec73e387cc224fbd67b20ec1292bb5bd (diff)
downloadchat-dfaccff44be27c1f8b144941b4c7793744278862.tar.gz
chat-dfaccff44be27c1f8b144941b4c7793744278862.tar.bz2
chat-dfaccff44be27c1f8b144941b4c7793744278862.zip
Sorted teams by alphabetical order under System Console > Teams (#3868)
-rw-r--r--webapp/components/admin_console/select_team_modal.jsx28
1 files changed, 23 insertions, 5 deletions
diff --git a/webapp/components/admin_console/select_team_modal.jsx b/webapp/components/admin_console/select_team_modal.jsx
index 6a1fe9bea..2ea6cc58c 100644
--- a/webapp/components/admin_console/select_team_modal.jsx
+++ b/webapp/components/admin_console/select_team_modal.jsx
@@ -14,6 +14,7 @@ export default class SelectTeamModal extends React.Component {
this.doSubmit = this.doSubmit.bind(this);
this.doCancel = this.doCancel.bind(this);
+ this.compare = this.compare.bind(this);
}
doSubmit(e) {
@@ -23,15 +24,32 @@ export default class SelectTeamModal extends React.Component {
doCancel() {
this.props.onModalDismissed();
}
+ compare(a, b) {
+ if (a.display_name < b.display_name) {
+ return -1;
+ }
+ if (a.display_name > b.display_name) {
+ return 1;
+ }
+ return 0;
+ }
+
render() {
if (this.props.teams == null) {
return <div/>;
}
- var options = [];
- var teams = this.props.teams;
- Reflect.ownKeys(teams).forEach((key) => {
- var team = teams[key];
+ const options = [];
+ const teamsArray = [];
+
+ Reflect.ownKeys(this.props.teams).forEach((key) => {
+ teamsArray.push(this.props.teams[key]);
+ });
+
+ teamsArray.sort(this.compare);
+
+ for (let i = 0; i < teamsArray.length; i++) {
+ const team = teamsArray[i];
options.push(
<option
key={'opt_' + team.id}
@@ -40,7 +58,7 @@ export default class SelectTeamModal extends React.Component {
{team.display_name}
</option>
);
- });
+ }
return (
<Modal