summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml11
-rw-r--r--CHANGELOG.md23
-rw-r--r--Makefile15
-rw-r--r--README.md6
-rw-r--r--api/admin.go46
-rw-r--r--api/admin_test.go82
-rw-r--r--api/channel_test.go4
-rw-r--r--api/command.go6
-rw-r--r--api/context.go2
-rw-r--r--config/config.json37
-rw-r--r--doc/developer/code-contribution.md16
-rw-r--r--docker/0.6/config_docker.json6
-rw-r--r--docker/0.7/config_docker.json6
-rw-r--r--docker/dev/config_docker.json6
-rw-r--r--mattermost.go19
-rw-r--r--model/client.go19
-rw-r--r--model/config.go151
-rw-r--r--model/system.go34
-rw-r--r--model/system_test.go19
-rw-r--r--model/utils.go7
-rw-r--r--model/version.go90
-rw-r--r--model/version_test.go74
-rw-r--r--store/sql_channel_store.go5
-rw-r--r--store/sql_post_store.go4
-rw-r--r--store/sql_post_store_test.go8
-rw-r--r--store/sql_store.go101
-rw-r--r--store/sql_system_store.go92
-rw-r--r--store/sql_system_store_test.go33
-rw-r--r--store/sql_user_store.go4
-rw-r--r--store/store.go7
-rw-r--r--utils/config.go189
-rw-r--r--web/react/components/admin_console/admin_controller.jsx46
-rw-r--r--web/react/components/admin_console/admin_navbar_dropdown.jsx102
-rw-r--r--web/react/components/admin_console/admin_sidebar.jsx147
-rw-r--r--web/react/components/admin_console/admin_sidebar_header.jsx60
-rw-r--r--web/react/components/admin_console/jobs_settings.jsx183
-rw-r--r--web/react/components/admin_console/log_settings.jsx261
-rw-r--r--web/react/components/admin_console/logs.jsx2
-rw-r--r--web/react/components/channel_header.jsx2
-rw-r--r--web/react/components/channel_invite_modal.jsx2
-rw-r--r--web/react/components/channel_members.jsx2
-rw-r--r--web/react/components/member_list_item.jsx3
-rw-r--r--web/react/components/navbar.jsx3
-rw-r--r--web/react/components/navbar_dropdown.jsx75
-rw-r--r--web/react/components/new_channel_modal.jsx10
-rw-r--r--web/react/components/post_body.jsx4
-rw-r--r--web/react/components/post_info.jsx7
-rw-r--r--web/react/components/post_list.jsx2
-rw-r--r--web/react/components/rhs_comment.jsx5
-rw-r--r--web/react/components/rhs_root_post.jsx9
-rw-r--r--web/react/components/sidebar_header.jsx3
-rw-r--r--web/react/components/sidebar_right_menu.jsx2
-rw-r--r--web/react/components/user_settings_security.jsx11
-rw-r--r--web/react/package.json3
-rw-r--r--web/react/stores/admin_store.jsx30
-rw-r--r--web/react/stores/browser_store.jsx7
-rw-r--r--web/react/utils/async_client.jsx26
-rw-r--r--web/react/utils/client.jsx31
-rw-r--r--web/react/utils/markdown.jsx16
-rw-r--r--web/react/utils/text_formatting.jsx84
-rw-r--r--web/react/utils/utils.jsx23
-rw-r--r--web/sass-files/sass/partials/_forms.scss6
-rw-r--r--web/sass-files/sass/partials/_sidebar--left.scss2
64 files changed, 1682 insertions, 612 deletions
diff --git a/.gitignore b/.gitignore
index 79761adac..ebd5e4342 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,8 @@ dist
npm-debug.log
bundle*.js
-
+model/version.go
+model/version.go.bak
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
diff --git a/.travis.yml b/.travis.yml
index 877977dd4..02e1234d3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,10 @@
language: go
go:
- 1.4.2
+- 1.5.1
+env:
+- TRAVIS_DB=mysql
+- TRAVIS_DB=postgres
before_install:
- gem install compass
- sudo apt-get update -qq
@@ -24,6 +28,9 @@ before_script:
- mysql -e "CREATE DATABASE IF NOT EXISTS mattermost_test ;" -uroot
- mysql -e "CREATE USER 'mmuser'@'%' IDENTIFIED BY 'mostest' ;" -uroot
- mysql -e "GRANT ALL ON mattermost_test.* TO 'mmuser'@'%' ;" -uroot
+- psql -c "create database mattermost_test ;" -U postgres
+- psql -c "create user mmuser with password 'mostest' ;" -U postgres
+- psql -c 'grant all privileges on database "mattermost_test" to mmuser ;' -U postgres
services:
- redis-server
addons:
@@ -38,6 +45,8 @@ deploy:
on:
repo: mattermost/platform
tags: true
+ go: 1.4.2
+ condition: $TRAVIS_DB = mysql
- provider: s3
access_key_id: AKIAJCO3KJYEGWJIKDIQ
@@ -52,3 +61,5 @@ deploy:
on:
repo: mattermost/platform
branch: master
+ go: 1.4.2
+ condition: $TRAVIS_DB = mysql
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7aac49ff2..18238d9eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,18 @@ The "UNDER DEVELOPMENT" section of the Mattermost changelog appears in the produ
### New Features
-- [See Product Roadmap for anticipated features](https://mattermost.atlassian.net/issues/?filter=10002)
+Messaging, Comments and Notifications
+
+- (Preview) Added support for emoji codes rendering to image files
+
+Admin Console
+
+- (Preview) Ability to view server logs and change config settings
+
+Integrations
+
+- (Preview) Added API for incoming webhooks
+- (Preview) Added OAuth2 as a service provider to allow for more secure connection to external apps
### Improvements
@@ -32,6 +43,10 @@ Performance
Code Quality
- Reformatted Javascript per Mattermost Style Guide
+
+UI
+
+- Added version, build number, build date and build hash under Account Settings -> Security (to be moved to "About" dialog later)
### Bug Fixes
@@ -42,7 +57,11 @@ Code Quality
Many thanks to our external contributors. In no particular order:
-- TBA
+- [Trozz](https://github.com/Trozz)
+- [LAndres](https://github.com/LAndreas)
+- [JessBot](https://github.com/JessBot)
+- [apaatsio](https://github.com/apaatsio)
+- [chengweiv5](https://github.com/chengweiv5)
## Release v0.7.0 (Beta1)
diff --git a/Makefile b/Makefile
index 972ebe960..4459da9dd 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,8 @@
GOPATH ?= $(GOPATH:)
GOFLAGS ?= $(GOFLAGS:)
BUILD_NUMBER ?= $(BUILD_NUMBER:)
+BUILD_DATE = $(shell date -u)
+BUILD_HASH = $(shell git rev-parse HEAD)
GO=$(GOPATH)/bin/godep go
ESLINT=node_modules/eslint/bin/eslint.js
@@ -32,6 +34,11 @@ all: travis
travis:
@echo building for travis
+ if [ "$(TRAVIS_DB)" = "postgres" ]; then \
+ sed -i'.bak' 's|mysql|postgres|g' config/config.json; \
+ sed -i'.bak' 's|mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8|postgres://mmuser:mostest@dockerhost:5432/mattermost_test?sslmode=disable\&connect_timeout=10|g' config/config.json; \
+ fi
+
rm -Rf $(DIST_ROOT)
@$(GO) clean $(GOFLAGS) -i ./...
@@ -49,6 +56,10 @@ travis:
exit 1; \
fi
+ @sed -i'.bak' 's|_BUILD_NUMBER_|$(BUILD_NUMBER)|g' ./model/version.go
+ @sed -i'.bak' 's|_BUILD_DATE_|$(BUILD_DATE)|g' ./model/version.go
+ @sed -i'.bak' 's|_BUILD_HASH_|$(BUILD_HASH)|g' ./model/version.go
+
@$(GO) build $(GOFLAGS) ./...
@$(GO) install $(GOFLAGS) ./...
@@ -222,6 +233,10 @@ cleandb:
fi
dist: install
+ @sed -i'.bak' 's|_BUILD_NUMBER_|$(BUILD_NUMBER)|g' ./model/version.go
+ @sed -i'.bak' 's|_BUILD_DATE_|$(BUILD_DATE)|g' ./model/version.go
+ @sed -i'.bak' 's|_BUILD_HASH_|$(BUILD_HASH)|g' ./model/version.go
+
@$(GO) build $(GOFLAGS) -i ./...
@$(GO) install $(GOFLAGS) ./...
diff --git a/README.md b/README.md
index 8cbddc1c6..d6b721dd1 100644
--- a/README.md
+++ b/README.md
@@ -48,8 +48,10 @@ There are multiple ways to install Mattermost depending on your needs.
#### Development Install
-- [Developer Machine Setup](doc/install/dev-setup.md) - Setup your local machine development environment using Docker on Mac OSX or Ubuntu.
-
+- [Developer Machine Setup](doc/install/dev-setup.md) - Setup your local machine development environment using Docker on Mac OSX or Ubuntu. Pull the latest stable release or pull the latest code from our development build.
+
+[![Build Status](https://travis-ci.org/mattermost/platform.svg?branch=master)](https://travis-ci.org/mattermost/platform)
+
#### Production Deployment (for Beta2 and later)
Prior to production installation, please review [Mattermost system requirements](doc/install/requirements.md).
diff --git a/api/admin.go b/api/admin.go
index 6d7a9028f..646597755 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -7,6 +7,7 @@ import (
"bufio"
"net/http"
"os"
+ "strings"
l4g "code.google.com/p/log4go"
"github.com/gorilla/mux"
@@ -20,6 +21,8 @@ func InitAdmin(r *mux.Router) {
sr := r.PathPrefix("/admin").Subrouter()
sr.Handle("/logs", ApiUserRequired(getLogs)).Methods("GET")
+ sr.Handle("/config", ApiUserRequired(getConfig)).Methods("GET")
+ sr.Handle("/save_config", ApiUserRequired(saveConfig)).Methods("POST")
sr.Handle("/client_props", ApiAppHandler(getClientProperties)).Methods("GET")
}
@@ -33,7 +36,7 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
if utils.Cfg.LogSettings.FileEnable {
- file, err := os.Open(utils.Cfg.LogSettings.FileLocation)
+ file, err := os.Open(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation))
if err != nil {
c.Err = model.NewAppError("getLogs", "Error reading log file", err.Error())
}
@@ -54,3 +57,44 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
func getClientProperties(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.MapToJson(utils.ClientProperties)))
}
+
+func getConfig(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !c.HasSystemAdminPermissions("getConfig") {
+ return
+ }
+
+ json := utils.Cfg.ToJson()
+ cfg := model.ConfigFromJson(strings.NewReader(json))
+ json = cfg.ToJson()
+
+ w.Write([]byte(json))
+}
+
+func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !c.HasSystemAdminPermissions("getConfig") {
+ return
+ }
+
+ cfg := model.ConfigFromJson(r.Body)
+ if cfg == nil {
+ c.SetInvalidParam("saveConfig", "config")
+ return
+ }
+
+ if len(cfg.ServiceSettings.Port) == 0 {
+ c.SetInvalidParam("saveConfig", "config")
+ return
+ }
+
+ if cfg.TeamSettings.MaxUsersPerTeam == 0 {
+ c.SetInvalidParam("saveConfig", "config")
+ return
+ }
+
+ // TODO run some cleanup validators
+
+ utils.SaveConfig(utils.CfgFileName, cfg)
+ utils.LoadConfig(utils.CfgFileName)
+ json := utils.Cfg.ToJson()
+ w.Write([]byte(json))
+}
diff --git a/api/admin_test.go b/api/admin_test.go
index e67077c55..e1778b5ac 100644
--- a/api/admin_test.go
+++ b/api/admin_test.go
@@ -8,6 +8,7 @@ import (
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
+ "github.com/mattermost/platform/utils"
)
func TestGetLogs(t *testing.T) {
@@ -20,6 +21,12 @@ func TestGetLogs(t *testing.T) {
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
store.Must(Srv.Store.User().VerifyEmail(user.Id))
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ if _, err := Client.GetLogs(); err == nil {
+ t.Fatal("Shouldn't have permissions")
+ }
+
c := &Context{}
c.RequestId = model.NewId()
c.IpAddress = "cmd_line"
@@ -37,8 +44,81 @@ func TestGetLogs(t *testing.T) {
func TestGetClientProperties(t *testing.T) {
Setup()
- if _, err := Client.GetClientProperties(); err != nil {
+ if result, err := Client.GetClientProperties(); err != nil {
+ t.Fatal(err)
+ } else {
+ props := result.Data.(map[string]string)
+
+ if len(props["Version"]) == 0 {
+ t.Fatal()
+ }
+ }
+}
+
+func TestGetConfig(t *testing.T) {
+ Setup()
+
+ team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
+ team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
+
+ user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"}
+ user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
+ store.Must(Srv.Store.User().VerifyEmail(user.Id))
+
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ if _, err := Client.GetConfig(); err == nil {
+ t.Fatal("Shouldn't have permissions")
+ }
+
+ c := &Context{}
+ c.RequestId = model.NewId()
+ c.IpAddress = "cmd_line"
+ UpdateRoles(c, user, model.ROLE_SYSTEM_ADMIN)
+
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ if result, err := Client.GetConfig(); err != nil {
+ t.Fatal(err)
+ } else {
+ cfg := result.Data.(*model.Config)
+
+ if len(cfg.ServiceSettings.SiteName) == 0 {
+ t.Fatal()
+ }
+ }
+}
+
+func TestSaveConfig(t *testing.T) {
+ Setup()
+
+ team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
+ team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
+ user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"}
+ user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
+ store.Must(Srv.Store.User().VerifyEmail(user.Id))
+
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ if _, err := Client.SaveConfig(utils.Cfg); err == nil {
+ t.Fatal("Shouldn't have permissions")
+ }
+
+ c := &Context{}
+ c.RequestId = model.NewId()
+ c.IpAddress = "cmd_line"
+ UpdateRoles(c, user, model.ROLE_SYSTEM_ADMIN)
+
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ if result, err := Client.SaveConfig(utils.Cfg); err != nil {
t.Fatal(err)
+ } else {
+ cfg := result.Data.(*model.Config)
+
+ if len(cfg.ServiceSettings.SiteName) == 0 {
+ t.Fatal()
+ }
}
}
diff --git a/api/channel_test.go b/api/channel_test.go
index 7e9267192..14bfe1cf7 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -57,7 +57,7 @@ func TestCreateChannel(t *testing.T) {
rchannel.Data.(*model.Channel).Id = ""
if _, err := Client.CreateChannel(rchannel.Data.(*model.Channel)); err != nil {
- if err.Message != "A channel with that handle already exists" {
+ if err.Message != "A channel with that URL already exists" {
t.Fatal(err)
}
}
@@ -68,7 +68,7 @@ func TestCreateChannel(t *testing.T) {
Client.DeleteChannel(savedId)
if _, err := Client.CreateChannel(rchannel.Data.(*model.Channel)); err != nil {
- if err.Message != "A channel with that handle was previously created" {
+ if err.Message != "A channel with that URL was previously created" {
t.Fatal(err)
}
}
diff --git a/api/command.go b/api/command.go
index be1d3229b..bc55f206b 100644
--- a/api/command.go
+++ b/api/command.go
@@ -341,7 +341,7 @@ func loadTestSetupCommand(c *Context, command *model.Command) bool {
}
}
} else {
- client.MockSession(c.Session.Id)
+ client.MockSession(c.Session.Token)
CreateTestEnviromentInTeam(
client,
c.Session.TeamId,
@@ -406,7 +406,7 @@ func loadTestChannelsCommand(c *Context, command *model.Command) bool {
channelsr = utils.Range{20, 30}
}
client := model.NewClient(c.GetSiteURL())
- client.MockSession(c.Session.Id)
+ client.MockSession(c.Session.Token)
channelCreator := NewAutoChannelCreator(client, c.Session.TeamId)
channelCreator.Fuzzy = doFuzz
channelCreator.CreateTestChannels(channelsr)
@@ -458,7 +458,7 @@ func loadTestPostsCommand(c *Context, command *model.Command) bool {
}
client := model.NewClient(c.GetSiteURL())
- client.MockSession(c.Session.Id)
+ client.MockSession(c.Session.Token)
testPoster := NewAutoPostCreator(client, command.ChannelId)
testPoster.Fuzzy = doFuzz
testPoster.Users = usernames
diff --git a/api/context.go b/api/context.go
index 5925c817f..02716bb33 100644
--- a/api/context.go
+++ b/api/context.go
@@ -125,7 +125,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c.setSiteURL(protocol + "://" + r.Host)
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)
- w.Header().Set(model.HEADER_VERSION_ID, utils.Cfg.ServiceSettings.Version+fmt.Sprintf(".%v", utils.CfgLastModified))
+ w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v", model.CurrentVersion, utils.CfgLastModified))
// Instruct the browser not to display us in an iframe for anti-clickjacking
if !h.isApi {
diff --git a/config/config.json b/config/config.json
index 4c4fbb255..38948641c 100644
--- a/config/config.json
+++ b/config/config.json
@@ -9,13 +9,11 @@
},
"ServiceSettings": {
"SiteName": "Mattermost",
- "Mode" : "dev",
- "AllowTesting" : false,
+ "Mode": "dev",
+ "AllowTesting": false,
"UseSSL": false,
"Port": "8065",
"Version": "developer",
- "Shards": {
- },
"InviteSalt": "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6",
"PublicLinkSalt": "TO3pTyXIZzwHiwyZgGql7lM7DG3zeId4",
"ResetSalt": "IPxFzSfnDFsNsRafZxz8NaYqFKhf9y2t",
@@ -26,21 +24,12 @@
"DisableEmailSignUp": false,
"EnableOAuthServiceProvider": false
},
- "SSOSettings": {
- "gitlab": {
- "Allow": false,
- "Secret" : "",
- "Id": "",
- "Scope": "",
- "AuthEndpoint": "",
- "TokenEndpoint": "",
- "UserApiEndpoint": ""
- }
- },
"SqlSettings": {
"DriverName": "mysql",
"DataSource": "mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8",
- "DataSourceReplicas": ["mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8"],
+ "DataSourceReplicas": [
+ "mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8"
+ ],
"MaxIdleConns": 10,
"MaxOpenConns": 10,
"Trace": false,
@@ -62,7 +51,7 @@
"InitialFont": "luximbi.ttf"
},
"EmailSettings": {
- "ByPassEmail" : true,
+ "ByPassEmail": true,
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "",
@@ -95,8 +84,20 @@
"MaxUsersPerTeam": 150,
"AllowPublicLink": true,
"AllowValetDefault": false,
+ "TourLink": "",
"DefaultThemeColor": "#2389D7",
"DisableTeamCreation": false,
"RestrictCreationToDomains": ""
+ },
+ "SSOSettings": {
+ "gitlab": {
+ "Allow": false,
+ "Secret": "",
+ "Id": "",
+ "Scope": "",
+ "AuthEndpoint": "",
+ "TokenEndpoint": "",
+ "UserApiEndpoint": ""
+ }
}
-}
+} \ No newline at end of file
diff --git a/doc/developer/code-contribution.md b/doc/developer/code-contribution.md
index c796a82a5..325a67546 100644
--- a/doc/developer/code-contribution.md
+++ b/doc/developer/code-contribution.md
@@ -31,7 +31,21 @@ git checkout -b <branch name>
## Submitting a Pull Request
-1. Please add yourself to the contributor list prior to submitting by completing the [contributor license agreement](http://www.mattermost.org/mattermost-contributor-agreement/).
+1. Please add yourself to the Mattermost [approved contributor list](https://docs.google.com/spreadsheets/d/1NTCeG-iL_VS9bFqtmHSfwETo5f-8MQ7oMDE5IUYJi_Y/pubhtml?gid=0&single=true) prior to submitting by completing the [contributor license agreement](http://www.mattermost.org/mattermost-contributor-agreement/).
+
+ For pull requests made by contributors not yet added to the approved contributor list, a reviewer may respond:
+
+ ```
+ Thanks @[username] for the pull request!
+
+ Before we can review, we need to add you to the list of [approved contributors](https://docs.google.com/spreadsheets/d/1NTCeG-iL_VS9bFqtmHSfwETo5f-8MQ7oMDE5IUYJi_Y/pubhtml?gid=0&single=true).
+ Please help complete the Mattermost [contribution license agreement](http://www.mattermost.org/mattermost-contributor-agreement/), which is a standard procedure for many open source projects. More information is in the above link.
+
+ Please let us know if you have any questions.
+
+ We are very happy to have you join our growing community!
+```
+
2. When you submit your pull request please include the Ticket ID at the beginning of your pull request comment, followed by a colon.
diff --git a/docker/0.6/config_docker.json b/docker/0.6/config_docker.json
index 157120b99..b1c72c4bd 100644
--- a/docker/0.6/config_docker.json
+++ b/docker/0.6/config_docker.json
@@ -10,7 +10,7 @@
"ServiceSettings": {
"SiteName": "Mattermost",
"Mode" : "dev",
- "AllowTesting" : false,
+ "AllowTesting" : false,
"UseSSL": false,
"Port": "80",
"Version": "developer",
@@ -63,8 +63,8 @@
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "",
- "UseTLS": false,
- "UseStartTLS": false,
+ "UseTLS": false,
+ "UseStartTLS": false,
"FeedbackEmail": "",
"FeedbackName": "",
"ApplePushServer": "",
diff --git a/docker/0.7/config_docker.json b/docker/0.7/config_docker.json
index 794ac95ae..cbac2ea69 100644
--- a/docker/0.7/config_docker.json
+++ b/docker/0.7/config_docker.json
@@ -10,7 +10,7 @@
"ServiceSettings": {
"SiteName": "Mattermost",
"Mode" : "dev",
- "AllowTesting" : true,
+ "AllowTesting" : true,
"UseSSL": false,
"Port": "80",
"Version": "developer",
@@ -65,8 +65,8 @@
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "",
- "UseTLS": false,
- "UseStartTLS": false,
+ "UseTLS": false,
+ "UseStartTLS": false,
"FeedbackEmail": "",
"FeedbackName": "",
"ApplePushServer": "",
diff --git a/docker/dev/config_docker.json b/docker/dev/config_docker.json
index bc42951b8..aceeb95b4 100644
--- a/docker/dev/config_docker.json
+++ b/docker/dev/config_docker.json
@@ -10,7 +10,7 @@
"ServiceSettings": {
"SiteName": "Mattermost",
"Mode" : "dev",
- "AllowTesting" : true,
+ "AllowTesting" : true,
"UseSSL": false,
"Port": "80",
"Version": "developer",
@@ -66,8 +66,8 @@
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "",
- "UseTLS": false,
- "UseStartTLS": false,
+ "UseTLS": false,
+ "UseStartTLS": false,
"FeedbackEmail": "",
"FeedbackName": "",
"ApplePushServer": "",
diff --git a/mattermost.go b/mattermost.go
index 0bdb90424..f54bcf15f 100644
--- a/mattermost.go
+++ b/mattermost.go
@@ -23,6 +23,7 @@ import (
var flagCmdCreateTeam bool
var flagCmdCreateUser bool
var flagCmdAssignRole bool
+var flagCmdVersion bool
var flagCmdResetPassword bool
var flagConfigFile string
var flagEmail string
@@ -42,6 +43,7 @@ func main() {
}
pwd, _ := os.Getwd()
+ l4g.Info("Current version is %v (%v/%v/%v)", model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash)
l4g.Info("Current working directory is %v", pwd)
l4g.Info("Loaded config file from %v", utils.FindConfigFile(flagConfigFile))
@@ -83,14 +85,16 @@ func parseCmds() {
flag.BoolVar(&flagCmdCreateTeam, "create_team", false, "")
flag.BoolVar(&flagCmdCreateUser, "create_user", false, "")
flag.BoolVar(&flagCmdAssignRole, "assign_role", false, "")
+ flag.BoolVar(&flagCmdVersion, "version", false, "")
flag.BoolVar(&flagCmdResetPassword, "reset_password", false, "")
flag.Parse()
- flagRunCmds = flagCmdCreateTeam || flagCmdCreateUser || flagCmdAssignRole || flagCmdResetPassword
+ flagRunCmds = flagCmdCreateTeam || flagCmdCreateUser || flagCmdAssignRole || flagCmdResetPassword || flagCmdVersion
}
func runCmds() {
+ cmdVersion()
cmdCreateTeam()
cmdCreateUser()
cmdAssignRole()
@@ -184,6 +188,17 @@ func cmdCreateUser() {
}
}
+func cmdVersion() {
+ if flagCmdVersion {
+ fmt.Fprintln(os.Stderr, "Version: "+model.CurrentVersion)
+ fmt.Fprintln(os.Stderr, "Build Number: "+model.BuildNumber)
+ fmt.Fprintln(os.Stderr, "Build Date: "+model.BuildDate)
+ fmt.Fprintln(os.Stderr, "Build Hash: "+model.BuildHash)
+
+ os.Exit(0)
+ }
+}
+
func cmdAssignRole() {
if flagCmdAssignRole {
if len(flagTeamName) == 0 {
@@ -298,6 +313,8 @@ Usage:
platform [options]
+ -version Display the current version
+
-config="config.json" Path to the config file
-email="user@example.com" Email address used in other commands
diff --git a/model/client.go b/model/client.go
index 9a89e8208..f9127719f 100644
--- a/model/client.go
+++ b/model/client.go
@@ -385,6 +385,24 @@ func (c *Client) GetClientProperties() (*Result, *AppError) {
}
}
+func (c *Client) GetConfig() (*Result, *AppError) {
+ if r, err := c.DoApiGet("/admin/config", "", ""); err != nil {
+ return nil, err
+ } else {
+ return &Result{r.Header.Get(HEADER_REQUEST_ID),
+ r.Header.Get(HEADER_ETAG_SERVER), ConfigFromJson(r.Body)}, nil
+ }
+}
+
+func (c *Client) SaveConfig(config *Config) (*Result, *AppError) {
+ if r, err := c.DoApiPost("/admin/save_config", config.ToJson()); err != nil {
+ return nil, err
+ } else {
+ return &Result{r.Header.Get(HEADER_REQUEST_ID),
+ r.Header.Get(HEADER_ETAG_SERVER), ConfigFromJson(r.Body)}, nil
+ }
+}
+
func (c *Client) CreateChannel(channel *Channel) (*Result, *AppError) {
if r, err := c.DoApiPost("/channels/create", channel.ToJson()); err != nil {
return nil, err
@@ -790,4 +808,5 @@ func (c *Client) GetAccessToken(data url.Values) (*Result, *AppError) {
func (c *Client) MockSession(sessionToken string) {
c.AuthToken = sessionToken
+ c.AuthType = HEADER_BEARER
}
diff --git a/model/config.go b/model/config.go
new file mode 100644
index 000000000..3b333dbe1
--- /dev/null
+++ b/model/config.go
@@ -0,0 +1,151 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type ServiceSettings struct {
+ SiteName string
+ Mode string
+ AllowTesting bool
+ UseSSL bool
+ Port string
+ Version string
+ InviteSalt string
+ PublicLinkSalt string
+ ResetSalt string
+ AnalyticsUrl string
+ UseLocalStorage bool
+ StorageDirectory string
+ AllowedLoginAttempts int
+ DisableEmailSignUp bool
+ EnableOAuthServiceProvider bool
+}
+
+type SSOSetting struct {
+ Allow bool
+ Secret string
+ Id string
+ Scope string
+ AuthEndpoint string
+ TokenEndpoint string
+ UserApiEndpoint string
+}
+
+type SqlSettings struct {
+ DriverName string
+ DataSource string
+ DataSourceReplicas []string
+ MaxIdleConns int
+ MaxOpenConns int
+ Trace bool
+ AtRestEncryptKey string
+}
+
+type LogSettings struct {
+ ConsoleEnable bool
+ ConsoleLevel string
+ FileEnable bool
+ FileLevel string
+ FileFormat string
+ FileLocation string
+}
+
+type AWSSettings struct {
+ S3AccessKeyId string
+ S3SecretAccessKey string
+ S3Bucket string
+ S3Region string
+}
+
+type ImageSettings struct {
+ ThumbnailWidth uint
+ ThumbnailHeight uint
+ PreviewWidth uint
+ PreviewHeight uint
+ ProfileWidth uint
+ ProfileHeight uint
+ InitialFont string
+}
+
+type EmailSettings struct {
+ ByPassEmail bool
+ SMTPUsername string
+ SMTPPassword string
+ SMTPServer string
+ UseTLS bool
+ UseStartTLS bool
+ FeedbackEmail string
+ FeedbackName string
+ ApplePushServer string
+ ApplePushCertPublic string
+ ApplePushCertPrivate string
+}
+
+type RateLimitSettings struct {
+ UseRateLimiter bool
+ PerSec int
+ MemoryStoreSize int
+ VaryByRemoteAddr bool
+ VaryByHeader string
+}
+
+type PrivacySettings struct {
+ ShowEmailAddress bool
+ ShowPhoneNumber bool
+ ShowSkypeId bool
+ ShowFullName bool
+}
+
+type ClientSettings struct {
+ SegmentDeveloperKey string
+ GoogleDeveloperKey string
+}
+
+type TeamSettings struct {
+ MaxUsersPerTeam int
+ AllowPublicLink bool
+ AllowValetDefault bool
+ TourLink string
+ DefaultThemeColor string
+ DisableTeamCreation bool
+ RestrictCreationToDomains string
+}
+
+type Config struct {
+ LogSettings LogSettings
+ ServiceSettings ServiceSettings
+ SqlSettings SqlSettings
+ AWSSettings AWSSettings
+ ImageSettings ImageSettings
+ EmailSettings EmailSettings
+ RateLimitSettings RateLimitSettings
+ PrivacySettings PrivacySettings
+ ClientSettings ClientSettings
+ TeamSettings TeamSettings
+ SSOSettings map[string]SSOSetting
+}
+
+func (o *Config) ToJson() string {
+ b, err := json.Marshal(o)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func ConfigFromJson(data io.Reader) *Config {
+ decoder := json.NewDecoder(data)
+ var o Config
+ err := decoder.Decode(&o)
+ if err == nil {
+ return &o
+ } else {
+ return nil
+ }
+}
diff --git a/model/system.go b/model/system.go
new file mode 100644
index 000000000..c79391cca
--- /dev/null
+++ b/model/system.go
@@ -0,0 +1,34 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type System struct {
+ Name string `json:"name"`
+ Value string `json:"value"`
+}
+
+func (o *System) ToJson() string {
+ b, err := json.Marshal(o)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func SystemFromJson(data io.Reader) *System {
+ decoder := json.NewDecoder(data)
+ var o System
+ err := decoder.Decode(&o)
+ if err == nil {
+ return &o
+ } else {
+ return nil
+ }
+}
diff --git a/model/system_test.go b/model/system_test.go
new file mode 100644
index 000000000..14ba0db2e
--- /dev/null
+++ b/model/system_test.go
@@ -0,0 +1,19 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestSystemJson(t *testing.T) {
+ system := System{Name: "test", Value: NewId()}
+ json := system.ToJson()
+ result := SystemFromJson(strings.NewReader(json))
+
+ if result.Name != "test" {
+ t.Fatal("Ids do not match")
+ }
+}
diff --git a/model/utils.go b/model/utils.go
index 04b92947b..e19cceba5 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -16,11 +16,6 @@ import (
"time"
)
-const (
- // Also change web/react/stores/browser_store.jsx BROWSER_STORE_VERSION
- ETAG_ROOT_VERSION = "12"
-)
-
type StringMap map[string]string
type StringArray []string
type EncryptStringMap map[string]string
@@ -235,7 +230,7 @@ func IsValidAlphaNum(s string, allowUnderscores bool) bool {
func Etag(parts ...interface{}) string {
- etag := ETAG_ROOT_VERSION
+ etag := CurrentVersion
for _, part := range parts {
etag += fmt.Sprintf(".%v", part)
diff --git a/model/version.go b/model/version.go
new file mode 100644
index 000000000..8f0c76ebe
--- /dev/null
+++ b/model/version.go
@@ -0,0 +1,90 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strconv"
+ "strings"
+)
+
+// This is a list of all the current viersions including any patches.
+// It should be maitained in chronological order with most current
+// release at the front of the list.
+var versions = []string{
+ "0.8.0",
+ "0.7.1",
+ "0.7.0",
+ "0.6.0",
+ "0.5.0",
+}
+
+var CurrentVersion string = versions[0]
+var BuildNumber = "_BUILD_NUMBER_"
+var BuildDate = "_BUILD_DATE_"
+var BuildHash = "_BUILD_HASH_"
+
+func SplitVersion(version string) (int64, int64, int64) {
+ parts := strings.Split(version, ".")
+
+ major := int64(0)
+ minor := int64(0)
+ patch := int64(0)
+
+ if len(parts) > 0 {
+ major, _ = strconv.ParseInt(parts[0], 10, 64)
+ }
+
+ if len(parts) > 1 {
+ minor, _ = strconv.ParseInt(parts[1], 10, 64)
+ }
+
+ if len(parts) > 2 {
+ patch, _ = strconv.ParseInt(parts[2], 10, 64)
+ }
+
+ return major, minor, patch
+}
+
+func GetPreviousVersion(currentVersion string) (int64, int64) {
+ currentIndex := -1
+ currentMajor, currentMinor, _ := SplitVersion(currentVersion)
+
+ for index, version := range versions {
+ major, minor, _ := SplitVersion(version)
+
+ if currentMajor == major && currentMinor == minor {
+ currentIndex = index
+ }
+
+ if currentIndex >= 0 {
+ if currentMajor != major || currentMinor != minor {
+ return major, minor
+ }
+ }
+ }
+
+ return 0, 0
+}
+
+func IsCurrentVersion(versionToCheck string) bool {
+ currentMajor, currentMinor, _ := SplitVersion(CurrentVersion)
+ toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
+
+ if toCheckMajor == currentMajor && toCheckMinor == currentMinor {
+ return true
+ } else {
+ return false
+ }
+}
+
+func IsPreviousVersion(versionToCheck string) bool {
+ toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
+ prevMajor, prevMinor := GetPreviousVersion(CurrentVersion)
+
+ if toCheckMajor == prevMajor && toCheckMinor == prevMinor {
+ return true
+ } else {
+ return false
+ }
+}
diff --git a/model/version_test.go b/model/version_test.go
new file mode 100644
index 000000000..da40006be
--- /dev/null
+++ b/model/version_test.go
@@ -0,0 +1,74 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestSplitVersion(t *testing.T) {
+ major1, minor1, patch1 := SplitVersion("junk")
+ if major1 != 0 || minor1 != 0 || patch1 != 0 {
+ t.Fatal()
+ }
+
+ major2, minor2, patch2 := SplitVersion("1.2.3")
+ if major2 != 1 || minor2 != 2 || patch2 != 3 {
+ t.Fatal()
+ }
+
+ major3, minor3, patch3 := SplitVersion("1.2")
+ if major3 != 1 || minor3 != 2 || patch3 != 0 {
+ t.Fatal()
+ }
+
+ major4, minor4, patch4 := SplitVersion("1")
+ if major4 != 1 || minor4 != 0 || patch4 != 0 {
+ t.Fatal()
+ }
+
+ major5, minor5, patch5 := SplitVersion("1.2.3.junkgoeswhere")
+ if major5 != 1 || minor5 != 2 || patch5 != 3 {
+ t.Fatal()
+ }
+}
+
+func TestGetPreviousVersion(t *testing.T) {
+ if major, minor := GetPreviousVersion("0.8.0"); major != 0 || minor != 7 {
+ t.Fatal(major, minor)
+ }
+
+ if major, minor := GetPreviousVersion("0.7.0"); major != 0 || minor != 6 {
+ t.Fatal(major, minor)
+ }
+
+ if major, minor := GetPreviousVersion("0.7.1"); major != 0 || minor != 6 {
+ t.Fatal(major, minor)
+ }
+
+ if major, minor := GetPreviousVersion("0.7111.1"); major != 0 || minor != 0 {
+ t.Fatal(major, minor)
+ }
+}
+
+func TestIsCurrentVersion(t *testing.T) {
+ major, minor, patch := SplitVersion(CurrentVersion)
+
+ if !IsCurrentVersion(CurrentVersion) {
+ t.Fatal()
+ }
+
+ if !IsCurrentVersion(fmt.Sprintf("%v.%v.%v", major, minor, patch+100)) {
+ t.Fatal()
+ }
+
+ if IsCurrentVersion(fmt.Sprintf("%v.%v.%v", major, minor+1, patch)) {
+ t.Fatal()
+ }
+
+ if IsCurrentVersion(fmt.Sprintf("%v.%v.%v", major+1, minor, patch)) {
+ t.Fatal()
+ }
+}
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 3d1007874..877246fc3 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -37,7 +37,6 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
}
func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
- s.CreateColumnIfNotExists("Channels", "CreatorId", "varchar(26)", "character varying(26)", "")
}
func (s SqlChannelStore) CreateIndexesIfNotExists() {
@@ -86,9 +85,9 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel {
dupChannel := model.Channel{}
s.GetReplica().SelectOne(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name = :Name AND DeleteAt > 0", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name})
if dupChannel.DeleteAt > 0 {
- result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that handle was previously created", "id="+channel.Id+", "+err.Error())
+ result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that URL was previously created", "id="+channel.Id+", "+err.Error())
} else {
- result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that handle already exists", "id="+channel.Id+", "+err.Error())
+ result.Err = model.NewAppError("SqlChannelStore.Update", "A channel with that URL already exists", "id="+channel.Id+", "+err.Error())
}
} else {
result.Err = model.NewAppError("SqlChannelStore.Save", "We couldn't save the channel", "id="+channel.Id+", "+err.Error())
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 20de23eb7..21e8e9d00 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -196,9 +196,9 @@ func (s SqlPostStore) GetEtag(channelId string) StoreChannel {
var et etagPosts
err := s.GetReplica().SelectOne(&et, "SELECT Id, UpdateAt FROM Posts WHERE ChannelId = :ChannelId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"ChannelId": channelId})
if err != nil {
- result.Data = fmt.Sprintf("%v.0.%v", model.ETAG_ROOT_VERSION, model.GetMillis())
+ result.Data = fmt.Sprintf("%v.0.%v", model.CurrentVersion, model.GetMillis())
} else {
- result.Data = fmt.Sprintf("%v.%v.%v", model.ETAG_ROOT_VERSION, et.Id, et.UpdateAt)
+ result.Data = fmt.Sprintf("%v.%v.%v", model.CurrentVersion, et.Id, et.UpdateAt)
}
storeChannel <- result
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index d48dea51c..bc1cb2c2c 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -37,14 +37,14 @@ func TestPostStoreGet(t *testing.T) {
o1.Message = "a" + model.NewId() + "b"
etag1 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
- if strings.Index(etag1, model.ETAG_ROOT_VERSION+".0.") != 0 {
+ if strings.Index(etag1, model.CurrentVersion+".0.") != 0 {
t.Fatal("Invalid Etag")
}
o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
etag2 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
- if strings.Index(etag2, model.ETAG_ROOT_VERSION+"."+o1.Id) != 0 {
+ if strings.Index(etag2, model.CurrentVersion+"."+o1.Id) != 0 {
t.Fatal("Invalid Etag")
}
@@ -136,7 +136,7 @@ func TestPostStoreDelete(t *testing.T) {
o1.Message = "a" + model.NewId() + "b"
etag1 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
- if strings.Index(etag1, model.ETAG_ROOT_VERSION+".0.") != 0 {
+ if strings.Index(etag1, model.CurrentVersion+".0.") != 0 {
t.Fatal("Invalid Etag")
}
@@ -160,7 +160,7 @@ func TestPostStoreDelete(t *testing.T) {
}
etag2 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
- if strings.Index(etag2, model.ETAG_ROOT_VERSION+"."+o1.Id) != 0 {
+ if strings.Index(etag2, model.CurrentVersion+"."+o1.Id) != 0 {
t.Fatal("Invalid Etag")
}
}
diff --git a/store/sql_store.go b/store/sql_store.go
index c0b3c2021..adac47b4d 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -39,6 +39,7 @@ type SqlStore struct {
audit AuditStore
session SessionStore
oauth OAuthStore
+ system SystemStore
}
func NewSqlStore() Store {
@@ -56,9 +57,30 @@ func NewSqlStore() Store {
utils.Cfg.SqlSettings.Trace)
}
+ schemaVersion := sqlStore.GetCurrentSchemaVersion()
+
+ // If the version is already set then we are potentially in an 'upgrade needed' state
+ if schemaVersion != "" {
+ // Check to see if it's the most current database schema version
+ if !model.IsCurrentVersion(schemaVersion) {
+ // If we are upgrading from the previous version then print a warning and continue
+ if model.IsPreviousVersion(schemaVersion) {
+ l4g.Warn("The database schema version of " + schemaVersion + " appears to be out of date")
+ l4g.Warn("Attempting to upgrade the database schema version to " + model.CurrentVersion)
+ } else {
+ // If this is an 'upgrade needed' state but the user is attempting to skip a version then halt the world
+ l4g.Critical("The database schema version of " + schemaVersion + " cannot be upgraded. You must not skip a version.")
+ time.Sleep(time.Second)
+ panic("The database schema version of " + schemaVersion + " cannot be upgraded. You must not skip a version.")
+ }
+ }
+ }
+
// Temporary upgrade code, remove after 0.8.0 release
- if sqlStore.DoesColumnExist("Sessions", "AltId") {
- sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
+ if sqlStore.DoesTableExist("Sessions") {
+ if sqlStore.DoesColumnExist("Sessions", "AltId") {
+ sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
+ }
}
sqlStore.team = NewSqlTeamStore(sqlStore)
@@ -68,6 +90,7 @@ func NewSqlStore() Store {
sqlStore.audit = NewSqlAuditStore(sqlStore)
sqlStore.session = NewSqlSessionStore(sqlStore)
sqlStore.oauth = NewSqlOAuthStore(sqlStore)
+ sqlStore.system = NewSqlSystemStore(sqlStore)
sqlStore.master.CreateTablesIfNotExists()
@@ -78,6 +101,7 @@ func NewSqlStore() Store {
sqlStore.audit.(*SqlAuditStore).UpgradeSchemaIfNeeded()
sqlStore.session.(*SqlSessionStore).UpgradeSchemaIfNeeded()
sqlStore.oauth.(*SqlOAuthStore).UpgradeSchemaIfNeeded()
+ sqlStore.system.(*SqlSystemStore).UpgradeSchemaIfNeeded()
sqlStore.team.(*SqlTeamStore).CreateIndexesIfNotExists()
sqlStore.channel.(*SqlChannelStore).CreateIndexesIfNotExists()
@@ -86,6 +110,17 @@ func NewSqlStore() Store {
sqlStore.audit.(*SqlAuditStore).CreateIndexesIfNotExists()
sqlStore.session.(*SqlSessionStore).CreateIndexesIfNotExists()
sqlStore.oauth.(*SqlOAuthStore).CreateIndexesIfNotExists()
+ sqlStore.system.(*SqlSystemStore).CreateIndexesIfNotExists()
+
+ if model.IsPreviousVersion(schemaVersion) {
+ sqlStore.system.Update(&model.System{Name: "Version", Value: model.CurrentVersion})
+ l4g.Warn("The database schema has been upgraded to version " + model.CurrentVersion)
+ }
+
+ if schemaVersion == "" {
+ sqlStore.system.Save(&model.System{Name: "Version", Value: model.CurrentVersion})
+ l4g.Info("The database schema has been set to version " + model.CurrentVersion)
+ }
return sqlStore
}
@@ -94,12 +129,12 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
db, err := dbsql.Open(driver, dataSource)
if err != nil {
- l4g.Critical("Failed to open sql connection to '%v' err:%v", dataSource, err)
+ l4g.Critical("Failed to open sql connection to err:%v", err)
time.Sleep(time.Second)
panic("Failed to open sql connection" + err.Error())
}
- l4g.Info("Pinging sql %v database at '%v'", con_type, dataSource)
+ l4g.Info("Pinging sql %v database", con_type)
err = db.Ping()
if err != nil {
l4g.Critical("Failed to ping db err:%v", err)
@@ -131,6 +166,56 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
return dbmap
}
+func (ss SqlStore) GetCurrentSchemaVersion() string {
+ version, _ := ss.GetMaster().SelectStr("SELECT Value FROM Systems WHERE Name='Version'")
+ return version
+}
+
+func (ss SqlStore) DoesTableExist(tableName string) bool {
+ if utils.Cfg.SqlSettings.DriverName == "postgres" {
+ count, err := ss.GetMaster().SelectInt(
+ `SELECT count(relname) FROM pg_class WHERE relname=$1`,
+ strings.ToLower(tableName),
+ )
+
+ if err != nil {
+ l4g.Critical("Failed to check if table exists %v", err)
+ time.Sleep(time.Second)
+ panic("Failed to check if table exists " + err.Error())
+ }
+
+ return count > 0
+
+ } else if utils.Cfg.SqlSettings.DriverName == "mysql" {
+
+ count, err := ss.GetMaster().SelectInt(
+ `SELECT
+ COUNT(0) AS table_exists
+ FROM
+ information_schema.TABLES
+ WHERE
+ TABLE_SCHEMA = DATABASE()
+ AND TABLE_NAME = ?
+ `,
+ tableName,
+ )
+
+ if err != nil {
+ l4g.Critical("Failed to check if table exists %v", err)
+ time.Sleep(time.Second)
+ panic("Failed to check if table exists " + err.Error())
+ }
+
+ return count > 0
+
+ } else {
+ l4g.Critical("Failed to check if column exists because of missing driver")
+ time.Sleep(time.Second)
+ panic("Failed to check if column exists because of missing driver")
+ }
+
+}
+
func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool {
if utils.Cfg.SqlSettings.DriverName == "postgres" {
count, err := ss.GetMaster().SelectInt(
@@ -144,6 +229,10 @@ func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool {
)
if err != nil {
+ if err.Error() == "pq: relation \""+strings.ToLower(tableName)+"\" does not exist" {
+ return false
+ }
+
l4g.Critical("Failed to check if column exists %v", err)
time.Sleep(time.Second)
panic("Failed to check if column exists " + err.Error())
@@ -376,6 +465,10 @@ func (ss SqlStore) OAuth() OAuthStore {
return ss.oauth
}
+func (ss SqlStore) System() SystemStore {
+ return ss.system
+}
+
type mattermConverter struct{}
func (me mattermConverter) ToDb(val interface{}) (interface{}, error) {
diff --git a/store/sql_system_store.go b/store/sql_system_store.go
new file mode 100644
index 000000000..ca22de2a6
--- /dev/null
+++ b/store/sql_system_store.go
@@ -0,0 +1,92 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package store
+
+import (
+ "github.com/mattermost/platform/model"
+)
+
+type SqlSystemStore struct {
+ *SqlStore
+}
+
+func NewSqlSystemStore(sqlStore *SqlStore) SystemStore {
+ s := &SqlSystemStore{sqlStore}
+
+ for _, db := range sqlStore.GetAllConns() {
+ table := db.AddTableWithName(model.System{}, "Systems").SetKeys(false, "Name")
+ table.ColMap("Name").SetMaxSize(64)
+ table.ColMap("Value").SetMaxSize(1024)
+ }
+
+ return s
+}
+
+func (s SqlSystemStore) UpgradeSchemaIfNeeded() {
+}
+
+func (s SqlSystemStore) CreateIndexesIfNotExists() {
+}
+
+func (s SqlSystemStore) Save(system *model.System) StoreChannel {
+
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ if err := s.GetMaster().Insert(system); err != nil {
+ result.Err = model.NewAppError("SqlSystemStore.Save", "We encounted an error saving the system property", "")
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
+func (s SqlSystemStore) Update(system *model.System) StoreChannel {
+
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ if _, err := s.GetMaster().Update(system); err != nil {
+ result.Err = model.NewAppError("SqlSystemStore.Save", "We encounted an error updating the system property", "")
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
+func (s SqlSystemStore) Get() StoreChannel {
+
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var systems []model.System
+ props := make(model.StringMap)
+ if _, err := s.GetReplica().Select(&systems, "SELECT * FROM Systems"); err != nil {
+ result.Err = model.NewAppError("SqlSystemStore.Get", "We encounted an error finding the system properties", "")
+ } else {
+ for _, prop := range systems {
+ props[prop.Name] = prop.Value
+ }
+
+ result.Data = props
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
diff --git a/store/sql_system_store_test.go b/store/sql_system_store_test.go
new file mode 100644
index 000000000..0f03b8f0e
--- /dev/null
+++ b/store/sql_system_store_test.go
@@ -0,0 +1,33 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package store
+
+import (
+ "github.com/mattermost/platform/model"
+ "testing"
+)
+
+func TestSqlSystemStore(t *testing.T) {
+ Setup()
+
+ system := &model.System{Name: model.NewId(), Value: "value"}
+ Must(store.System().Save(system))
+
+ result := <-store.System().Get()
+ systems := result.Data.(model.StringMap)
+
+ if systems[system.Name] != system.Value {
+ t.Fatal()
+ }
+
+ system.Value = "value2"
+ Must(store.System().Update(system))
+
+ result2 := <-store.System().Get()
+ systems2 := result2.Data.(model.StringMap)
+
+ if systems2[system.Name] != system.Value {
+ t.Fatal()
+ }
+}
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 52d670d56..778df367e 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -325,9 +325,9 @@ func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users WHERE TeamId = :TeamId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"TeamId": teamId})
if err != nil {
- result.Data = fmt.Sprintf("%v.%v", model.ETAG_ROOT_VERSION, model.GetMillis())
+ result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
} else {
- result.Data = fmt.Sprintf("%v.%v", model.ETAG_ROOT_VERSION, updateAt)
+ result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, updateAt)
}
storeChannel <- result
diff --git a/store/store.go b/store/store.go
index 0218bc757..1344c4ebe 100644
--- a/store/store.go
+++ b/store/store.go
@@ -35,6 +35,7 @@ type Store interface {
Audit() AuditStore
Session() SessionStore
OAuth() OAuthStore
+ System() SystemStore
Close()
}
@@ -130,3 +131,9 @@ type OAuthStore interface {
GetAccessDataByAuthCode(authCode string) StoreChannel
RemoveAccessData(token string) StoreChannel
}
+
+type SystemStore interface {
+ Save(system *model.System) StoreChannel
+ Update(system *model.System) StoreChannel
+ Get() StoreChannel
+}
diff --git a/utils/config.go b/utils/config.go
index 0eb8329d1..dd2c17977 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -6,11 +6,14 @@ package utils
import (
"encoding/json"
"fmt"
+ "io/ioutil"
"os"
"path/filepath"
"strconv"
l4g "code.google.com/p/log4go"
+
+ "github.com/mattermost/platform/model"
)
const (
@@ -20,139 +23,9 @@ const (
LOG_ROTATE_SIZE = 10000
)
-type ServiceSettings struct {
- SiteName string
- Mode string
- AllowTesting bool
- UseSSL bool
- Port string
- Version string
- InviteSalt string
- PublicLinkSalt string
- ResetSalt string
- AnalyticsUrl string
- UseLocalStorage bool
- StorageDirectory string
- AllowedLoginAttempts int
- DisableEmailSignUp bool
- EnableOAuthServiceProvider bool
-}
-
-type SSOSetting struct {
- Allow bool
- Secret string
- Id string
- Scope string
- AuthEndpoint string
- TokenEndpoint string
- UserApiEndpoint string
-}
-
-type SqlSettings struct {
- DriverName string
- DataSource string
- DataSourceReplicas []string
- MaxIdleConns int
- MaxOpenConns int
- Trace bool
- AtRestEncryptKey string
-}
-
-type LogSettings struct {
- ConsoleEnable bool
- ConsoleLevel string
- FileEnable bool
- FileLevel string
- FileFormat string
- FileLocation string
-}
-
-type AWSSettings struct {
- S3AccessKeyId string
- S3SecretAccessKey string
- S3Bucket string
- S3Region string
-}
-
-type ImageSettings struct {
- ThumbnailWidth uint
- ThumbnailHeight uint
- PreviewWidth uint
- PreviewHeight uint
- ProfileWidth uint
- ProfileHeight uint
- InitialFont string
-}
-
-type EmailSettings struct {
- ByPassEmail bool
- SMTPUsername string
- SMTPPassword string
- SMTPServer string
- UseTLS bool
- UseStartTLS bool
- FeedbackEmail string
- FeedbackName string
- ApplePushServer string
- ApplePushCertPublic string
- ApplePushCertPrivate string
-}
-
-type RateLimitSettings struct {
- UseRateLimiter bool
- PerSec int
- MemoryStoreSize int
- VaryByRemoteAddr bool
- VaryByHeader string
-}
-
-type PrivacySettings struct {
- ShowEmailAddress bool
- ShowPhoneNumber bool
- ShowSkypeId bool
- ShowFullName bool
-}
-
-type ClientSettings struct {
- SegmentDeveloperKey string
- GoogleDeveloperKey string
-}
-
-type TeamSettings struct {
- MaxUsersPerTeam int
- AllowPublicLink bool
- AllowValetDefault bool
- TourLink string
- DefaultThemeColor string
- DisableTeamCreation bool
- RestrictCreationToDomains string
-}
-
-type Config struct {
- LogSettings LogSettings
- ServiceSettings ServiceSettings
- SqlSettings SqlSettings
- AWSSettings AWSSettings
- ImageSettings ImageSettings
- EmailSettings EmailSettings
- RateLimitSettings RateLimitSettings
- PrivacySettings PrivacySettings
- ClientSettings ClientSettings
- TeamSettings TeamSettings
- SSOSettings map[string]SSOSetting
-}
-
-func (o *Config) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-var Cfg *Config = &Config{}
+var Cfg *model.Config = &model.Config{}
var CfgLastModified int64 = 0
+var CfgFileName string = ""
var ClientProperties map[string]string = map[string]string{}
var SanitizeOptions map[string]bool = map[string]bool{}
@@ -184,14 +57,14 @@ func FindDir(dir string) string {
}
func ConfigureCmdLineLog() {
- ls := LogSettings{}
+ ls := model.LogSettings{}
ls.ConsoleEnable = true
ls.ConsoleLevel = "ERROR"
ls.FileEnable = false
configureLog(&ls)
}
-func configureLog(s *LogSettings) {
+func configureLog(s *model.LogSettings) {
l4g.Close()
@@ -207,12 +80,11 @@ func configureLog(s *LogSettings) {
}
if s.FileEnable {
- if s.FileFormat == "" {
- s.FileFormat = "[%D %T] [%L] %M"
- }
- if s.FileLocation == "" {
- s.FileLocation = FindDir("logs") + "mattermost.log"
+ var fileFormat = s.FileFormat
+
+ if fileFormat == "" {
+ fileFormat = "[%D %T] [%L] %M"
}
level := l4g.DEBUG
@@ -222,14 +94,36 @@ func configureLog(s *LogSettings) {
level = l4g.ERROR
}
- flw := l4g.NewFileLogWriter(s.FileLocation, false)
- flw.SetFormat(s.FileFormat)
+ flw := l4g.NewFileLogWriter(GetLogFileLocation(s.FileLocation), false)
+ flw.SetFormat(fileFormat)
flw.SetRotate(true)
flw.SetRotateLines(LOG_ROTATE_SIZE)
l4g.AddFilter("file", level, flw)
}
}
+func GetLogFileLocation(fileLocation string) string {
+ if fileLocation == "" {
+ return FindDir("logs") + "mattermost.log"
+ } else {
+ return fileLocation
+ }
+}
+
+func SaveConfig(fileName string, config *model.Config) *model.AppError {
+ b, err := json.MarshalIndent(config, "", " ")
+ if err != nil {
+ return model.NewAppError("SaveConfig", "An error occurred while saving the file to "+fileName, err.Error())
+ }
+
+ err = ioutil.WriteFile(fileName, b, 0644)
+ if err != nil {
+ return model.NewAppError("SaveConfig", "An error occurred while saving the file to "+fileName, err.Error())
+ }
+
+ return nil
+}
+
// LoadConfig will try to search around for the corresponding config file.
// It will search /tmp/fileName then attempt ./config/fileName,
// then ../config/fileName and last it will look at fileName
@@ -243,7 +137,7 @@ func LoadConfig(fileName string) {
}
decoder := json.NewDecoder(file)
- config := Config{}
+ config := model.Config{}
err = decoder.Decode(&config)
if err != nil {
panic("Error decoding config file=" + fileName + ", err=" + err.Error())
@@ -253,6 +147,7 @@ func LoadConfig(fileName string) {
panic("Error getting config info file=" + fileName + ", err=" + err.Error())
} else {
CfgLastModified = info.ModTime().Unix()
+ CfgFileName = fileName
}
configureLog(&config.LogSettings)
@@ -262,7 +157,7 @@ func LoadConfig(fileName string) {
ClientProperties = getClientProperties(Cfg)
}
-func getSanitizeOptions(c *Config) map[string]bool {
+func getSanitizeOptions(c *model.Config) map[string]bool {
options := map[string]bool{}
options["fullname"] = c.PrivacySettings.ShowFullName
options["email"] = c.PrivacySettings.ShowEmailAddress
@@ -272,10 +167,14 @@ func getSanitizeOptions(c *Config) map[string]bool {
return options
}
-func getClientProperties(c *Config) map[string]string {
+func getClientProperties(c *model.Config) map[string]string {
props := make(map[string]string)
- props["Version"] = c.ServiceSettings.Version
+ props["Version"] = model.CurrentVersion
+ props["BuildNumber"] = model.BuildNumber
+ props["BuildDate"] = model.BuildDate
+ props["BuildHash"] = model.BuildHash
+
props["SiteName"] = c.ServiceSettings.SiteName
props["ByPassEmail"] = strconv.FormatBool(c.EmailSettings.ByPassEmail)
props["FeedbackEmail"] = c.EmailSettings.FeedbackEmail
diff --git a/web/react/components/admin_console/admin_controller.jsx b/web/react/components/admin_console/admin_controller.jsx
index 68984c9e0..e82fe1b76 100644
--- a/web/react/components/admin_console/admin_controller.jsx
+++ b/web/react/components/admin_console/admin_controller.jsx
@@ -2,35 +2,58 @@
// See License.txt for license information.
var AdminSidebar = require('./admin_sidebar.jsx');
-var EmailTab = require('./email_settings.jsx');
-var JobsTab = require('./jobs_settings.jsx');
+var AdminStore = require('../../stores/admin_store.jsx');
+var AsyncClient = require('../../utils/async_client.jsx');
+var LoadingScreen = require('../loading_screen.jsx');
+
+var EmailSettingsTab = require('./email_settings.jsx');
+var LogSettingsTab = require('./log_settings.jsx');
var LogsTab = require('./logs.jsx');
-var Navbar = require('../../components/navbar.jsx');
export default class AdminController extends React.Component {
constructor(props) {
super(props);
this.selectTab = this.selectTab.bind(this);
+ this.onConfigListenerChange = this.onConfigListenerChange.bind(this);
this.state = {
+ config: null,
selected: 'email_settings'
};
}
+ componentDidMount() {
+ AdminStore.addConfigChangeListener(this.onConfigListenerChange);
+ AsyncClient.getConfig();
+ }
+
+ componentWillUnmount() {
+ AdminStore.removeConfigChangeListener(this.onConfigListenerChange);
+ }
+
+ onConfigListenerChange() {
+ this.setState({
+ config: AdminStore.getConfig(),
+ selected: this.state.selected
+ });
+ }
+
selectTab(tab) {
this.setState({selected: tab});
}
render() {
- var tab = '';
-
- if (this.state.selected === 'email_settings') {
- tab = <EmailTab />;
- } else if (this.state.selected === 'job_settings') {
- tab = <JobsTab />;
- } else if (this.state.selected === 'logs') {
- tab = <LogsTab />;
+ var tab = <LoadingScreen />;
+
+ if (this.state.config != null) {
+ if (this.state.selected === 'email_settings') {
+ tab = <EmailSettingsTab config={this.state.config} />;
+ } else if (this.state.selected === 'log_settings') {
+ tab = <LogSettingsTab config={this.state.config} />;
+ } else if (this.state.selected === 'logs') {
+ tab = <LogsTab />;
+ }
}
return (
@@ -45,7 +68,6 @@ export default class AdminController extends React.Component {
/>
<div className='inner__wrap channel__wrap'>
<div className='row header'>
- <Navbar teamDisplayName='Admin Console' />
</div>
<div className='row main'>
<div
diff --git a/web/react/components/admin_console/admin_navbar_dropdown.jsx b/web/react/components/admin_console/admin_navbar_dropdown.jsx
new file mode 100644
index 000000000..a3ab81079
--- /dev/null
+++ b/web/react/components/admin_console/admin_navbar_dropdown.jsx
@@ -0,0 +1,102 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var Utils = require('../../utils/utils.jsx');
+var Client = require('../../utils/client.jsx');
+var TeamStore = require('../../stores/team_store.jsx');
+
+var Constants = require('../../utils/constants.jsx');
+
+function getStateFromStores() {
+ return {currentTeam: TeamStore.getCurrent()};
+}
+
+export default class AdminNavbarDropdown extends React.Component {
+ constructor(props) {
+ super(props);
+ this.blockToggle = false;
+
+ this.handleLogoutClick = this.handleLogoutClick.bind(this);
+
+ this.state = getStateFromStores();
+ }
+
+ handleLogoutClick(e) {
+ e.preventDefault();
+ Client.logout();
+ }
+
+ componentDidMount() {
+ $(React.findDOMNode(this.refs.dropdown)).on('hide.bs.dropdown', () => {
+ this.blockToggle = true;
+ setTimeout(() => {
+ this.blockToggle = false;
+ }, 100);
+ });
+ }
+
+ componentWillUnmount() {
+ $(React.findDOMNode(this.refs.dropdown)).off('hide.bs.dropdown');
+ }
+
+ render() {
+ return (
+ <ul className='nav navbar-nav navbar-right'>
+ <li
+ ref='dropdown'
+ className='dropdown'
+ >
+ <a
+ href='#'
+ className='dropdown-toggle'
+ data-toggle='dropdown'
+ role='button'
+ aria-expanded='false'
+ >
+ <span
+ className='dropdown__icon'
+ dangerouslySetInnerHTML={{__html: Constants.MENU_ICON}}
+ />
+ </a>
+ <ul
+ className='dropdown-menu'
+ role='menu'
+ >
+ <li>
+ <a
+ href={Utils.getWindowLocationOrigin() + '/' + this.state.currentTeam.name}
+ >
+ {'Switch to ' + this.state.currentTeam.display_name}
+ </a>
+ </li>
+ <li>
+ <a
+ href='#'
+ onClick={this.handleLogoutClick}
+ >
+ {'Logout'}
+ </a>
+ </li>
+ <li className='divider'></li>
+ <li>
+ <a
+ target='_blank'
+ href='/static/help/help.html'
+ >
+ {'Help'}
+ </a>
+ </li>
+ <li>
+ <a
+ target='_blank'
+ href='/static/help/report_problem.html'
+ >
+ {'Report a Problem'}
+ </a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ );
+ }
+} \ No newline at end of file
diff --git a/web/react/components/admin_console/admin_sidebar.jsx b/web/react/components/admin_console/admin_sidebar.jsx
index a04bceef5..a6e689490 100644
--- a/web/react/components/admin_console/admin_sidebar.jsx
+++ b/web/react/components/admin_console/admin_sidebar.jsx
@@ -1,7 +1,7 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
-var SidebarHeader = require('../sidebar_header.jsx');
+var AdminSidebarHeader = require('./admin_sidebar_header.jsx');
export default class AdminSidebar extends React.Component {
constructor(props) {
@@ -14,7 +14,8 @@ export default class AdminSidebar extends React.Component {
};
}
- handleClick(name) {
+ handleClick(name, e) {
+ e.preventDefault();
this.props.selectTab(name);
}
@@ -27,58 +28,21 @@ export default class AdminSidebar extends React.Component {
}
componentDidMount() {
- $('.nav__menu-item').on('click', function clickme(e) {
- e.preventDefault();
- $(this).closest('.sidebar--collapsable').find('.nav__menu-item').removeClass('active');
- $(this).addClass('active');
- $(this).closest('.sidebar--collapsable').find('.nav__sub-menu').addClass('hide');
- $(this).next('.nav__sub-menu').removeClass('hide');
- });
-
- $('.nav__sub-menu a').on('click', function clickme(e) {
- e.preventDefault();
- $(this).closest('.nav__sub-menu').find('a').removeClass('active');
- $(this).addClass('active');
- });
-
- $('.nav__sub-menu-item').on('click', function clickme(e) {
- e.preventDefault();
- $(this).closest('.sidebar--collapsable').find('.nav__inner-menu').addClass('hide');
- $(this).closest('li').next('li').find('.nav__inner-menu').removeClass('hide');
- $(this).closest('li').next('li').find('.nav__inner-menu li:first a').addClass('active');
- });
-
- $('.nav__inner-menu a').on('click', function clickme() {
- $(this).closest('.nav__inner-menu').closest('li').prev('li').find('a').addClass('active');
- });
-
- $('.nav__sub-menu .menu__close').on('click', function close() {
- var menuItem = $(this).closest('li');
- menuItem.next('li').remove();
- menuItem.remove();
- });
}
render() {
return (
<div className='sidebar--left sidebar--collapsable'>
<div>
- <SidebarHeader
- teamDisplayName='Admin Console'
- teamType='I'
- />
+ <AdminSidebarHeader />
<ul className='nav nav-pills nav-stacked'>
<li>
- <a href='#'
- className='nav__menu-item active'
- >
- <span className='icon fa fa-gear'></span> <span>{'Basic Settings'}</span></a>
<ul className='nav nav__sub-menu'>
<li>
<a
href='#'
className={this.isSelected('email_settings')}
- onClick={this.handleClick.bind(null, 'email_settings')}
+ onClick={this.handleClick.bind(this, 'email_settings')}
>
{'Email Settings'}
</a>
@@ -86,110 +50,21 @@ export default class AdminSidebar extends React.Component {
<li>
<a
href='#'
- className={this.isSelected('logs')}
- onClick={this.handleClick.bind(null, 'logs')}
- >
- {'Logs'}
- </a>
- </li>
- </ul>
- </li>
- <li>
- <a
- href='#'
- className='nav__menu-item'
- >
- <span className='icon fa fa-gear'></span> <span>{'Jobs'}</span>
- </a>
- <ul className='nav nav__sub-menu hide'>
- <li>
- <a
- href='#'
- className={this.isSelected('job_settings')}
- onClick={this.handleClick.bind(null, 'job_settings')}
+ className={this.isSelected('log_settings')}
+ onClick={this.handleClick.bind(this, 'log_settings')}
>
- {'Job Settings'}
+ {'Log Settings'}
</a>
</li>
- </ul>
- </li>
- <li>
- <a
- href='#'
- className='nav__menu-item'
- >
- <span className='icon fa fa-gear'></span>
- <span>{'Team Settings (306)'}</span>
- <span className='menu-icon--right'>
- <i className='fa fa-plus'></i>
- </span>
- </a>
- <ul className='nav nav__sub-menu hide'>
- <li>
- <a
- href='#'
- className='nav__sub-menu-item active'
- >
- {'Adal '}
- <span className='menu-icon--right menu__close'>{'x'}</span>
- </a>
- </li>
- <li>
- <ul className='nav nav__inner-menu'>
- <li>
- <a
- href='#'
- className='active'
- >
- {'- Users'}
- </a>
- </li>
- <li><a href='#'>{'- View Statistics'}</a></li>
- <li>
- <a href='#'>
- {'- View Audit Log'}
- <span className='badge pull-right small'>{'1'}</span>
- </a>
- </li>
- </ul>
- </li>
<li>
<a
href='#'
- className='nav__sub-menu-item'
+ className={this.isSelected('logs')}
+ onClick={this.handleClick.bind(this, 'logs')}
>
- {'Boole '}
- <span className='menu-icon--right menu__close'>{'x'}</span>
+ {'Logs'}
</a>
</li>
- <li>
- <ul className='nav nav__inner-menu hide'>
- <li>
- <a
- href='#'
- className='active'
- >
- {'- Users'}
- </a>
- </li>
- <li><a href='#'>{'- View Statistics'}</a></li>
- <li>
- <a href='#'>
- {'- View Audit Log'}
- <span className='badge pull-right small'>{'1'}</span>
- </a>
- </li>
- </ul>
- </li>
- <li>
- <span
- data-toggle='modal'
- data-target='#select-team'
- className='nav-more'
- >
- {'Select a team'}
- </span>
- </li>
</ul>
</li>
</ul>
diff --git a/web/react/components/admin_console/admin_sidebar_header.jsx b/web/react/components/admin_console/admin_sidebar_header.jsx
new file mode 100644
index 000000000..81798da45
--- /dev/null
+++ b/web/react/components/admin_console/admin_sidebar_header.jsx
@@ -0,0 +1,60 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var AdminNavbarDropdown = require('./admin_navbar_dropdown.jsx');
+var UserStore = require('../../stores/user_store.jsx');
+
+export default class SidebarHeader extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.toggleDropdown = this.toggleDropdown.bind(this);
+
+ this.state = {};
+ }
+
+ toggleDropdown(e) {
+ e.preventDefault();
+
+ if (this.refs.dropdown.blockToggle) {
+ this.refs.dropdown.blockToggle = false;
+ return;
+ }
+
+ $('.team__header').find('.dropdown-toggle').dropdown('toggle');
+ }
+
+ render() {
+ var me = UserStore.getCurrentUser();
+ var profilePicture = null;
+
+ if (!me) {
+ return null;
+ }
+
+ if (me.last_picture_update) {
+ profilePicture = (
+ <img
+ className='user__picture'
+ src={'/api/v1/users/' + me.id + '/image?time=' + me.update_at}
+ />
+ );
+ }
+
+ return (
+ <div className='team__header theme'>
+ <a
+ href='#'
+ onClick={this.toggleDropdown}
+ >
+ {profilePicture}
+ <div className='header__info'>
+ <div className='user__name'>{'@' + me.username}</div>
+ <div className='team__name'>{'System Console'}</div>
+ </div>
+ </a>
+ <AdminNavbarDropdown ref='dropdown' />
+ </div>
+ );
+ }
+} \ No newline at end of file
diff --git a/web/react/components/admin_console/jobs_settings.jsx b/web/react/components/admin_console/jobs_settings.jsx
deleted file mode 100644
index 0b4fc4185..000000000
--- a/web/react/components/admin_console/jobs_settings.jsx
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-export default class Jobs extends React.Component {
- constructor(props) {
- super(props);
-
- this.state = {
- };
- }
-
- render() {
- return (
- <div className='wrapper--fixed'>
- <h3>{' ************** JOB Settings'}</h3>
- <form
- className='form-horizontal'
- role='form'
- >
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='email'
- >
- {'Bypass Email: '}
- <a
- href='#'
- data-trigger='hover click'
- data-toggle='popover'
- data-position='bottom'
- data-content={'Here\'s some more help text inside a popover for the Bypass Email field just to show how popovers look.'}
- >
- {'(?)'}
- </a>
- </label>
- <div className='col-sm-8'>
- <label className='radio-inline'>
- <input
- type='radio'
- name='byPassEmail'
- value='option1'
- />
- {'True'}
- </label>
- <label className='radio-inline'>
- <input
- type='radio'
- name='byPassEmail'
- value='option2'
- />
- {'False'}
- </label>
- <p className='help-text'>{'This is some sample help text for the Bypass Email field'}</p>
- </div>
- </div>
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='smtpUsername'
- >
- {'SMTP Username:'}
- </label>
- <div className='col-sm-8'>
- <input
- type='email'
- className='form-control'
- id='smtpUsername'
- placeholder='Enter your SMTP username'
- value=''
- />
- <div className='help-text'>
- <div className='alert alert-warning'><i className='fa fa-warning'></i>{' This is some error text for the Bypass Email field'}</div>
- </div>
- <p className='help-text'>{'This is some sample help text for the SMTP username field'}</p>
- </div>
- </div>
- <div
- className='panel-group'
- id='accordion'
- role='tablist'
- aria-multiselectable='true'
- >
- <div className='panel panel-default'>
- <div
- className='panel-heading'
- role='tab'
- id='headingOne'
- >
- <h3 className='panel-title'>
- <a
- className='collapsed'
- role='button'
- data-toggle='collapse'
- data-parent='#accordion'
- href='#collapseOne'
- aria-expanded='true'
- aria-controls='collapseOne'
- >
- {'Advanced Settings '}
- <i className='fa fa-plus'></i>
- <i className='fa fa-minus'></i>
- </a>
- </h3>
- </div>
- <div
- id='collapseOne'
- className='panel-collapse collapse'
- role='tabpanel'
- aria-labelledby='headingOne'
- >
- <div className='panel-body'>
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='feedbackUsername'
- >
- {'Apple push server:'}
- </label>
- <div className='col-sm-8'>
- <input
- type='text'
- className='form-control'
- id='feedbackUsername'
- placeholder='Enter your Apple push server'
- value=''
- />
- <p className='help-text'>{'This is some sample help text for the Apple push server field'}</p>
- </div>
- </div>
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='feedbackUsername'
- >
- {'Apple push certificate public:'}
- </label>
- <div className='col-sm-8'>
- <input
- type='text'
- className='form-control'
- id='feedbackUsername'
- placeholder='Enter your public apple push certificate'
- value=''
- />
- </div>
- </div>
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='feedbackUsername'
- >
- {'Apple push certificate private:'}
- </label>
- <div className='col-sm-8'>
- <input
- type='text'
- className='form-control'
- id='feedbackUsername'
- placeholder='Enter your private apple push certificate'
- value=''
- />
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div className='form-group'>
- <div className='col-sm-12'>
- <button
- type='submit'
- className='btn btn-primary'
- >
- {'Save'}
- </button>
- </div>
- </div>
- </form>
- </div>
- );
- }
-} \ No newline at end of file
diff --git a/web/react/components/admin_console/log_settings.jsx b/web/react/components/admin_console/log_settings.jsx
new file mode 100644
index 000000000..4e3db8f68
--- /dev/null
+++ b/web/react/components/admin_console/log_settings.jsx
@@ -0,0 +1,261 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var Client = require('../../utils/client.jsx');
+var AsyncClient = require('../../utils/async_client.jsx');
+
+export default class LogSettings extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.handleChange = this.handleChange.bind(this);
+ this.handleSubmit = this.handleSubmit.bind(this);
+
+ this.state = {
+ saveNeeded: false,
+ serverError: null
+ };
+ }
+
+ handleChange() {
+ this.setState({saveNeeded: true, serverError: this.state.serverError});
+ }
+
+ handleSubmit(e) {
+ e.preventDefault();
+ $('#save-button').button('loading');
+
+ var config = this.props.config;
+ config.LogSettings.ConsoleEnable = React.findDOMNode(this.refs.consoleEnable).checked;
+ config.LogSettings.ConsoleLevel = React.findDOMNode(this.refs.consoleLevel).value;
+ config.LogSettings.FileEnable = React.findDOMNode(this.refs.fileEnable).checked;
+ config.LogSettings.FileLevel = React.findDOMNode(this.refs.fileLevel).value;
+ config.LogSettings.FileLocation = React.findDOMNode(this.refs.fileLocation).value.trim();
+ config.LogSettings.FileFormat = React.findDOMNode(this.refs.fileFormat).value.trim();
+
+ Client.saveConfig(
+ config,
+ () => {
+ AsyncClient.getConfig();
+ this.setState({serverError: null, saveNeeded: false});
+ $('#save-button').button('reset');
+ },
+ (err) => {
+ this.setState({serverError: err.message, saveNeeded: true});
+ $('#save-button').button('reset');
+ }
+ );
+ }
+
+ render() {
+ var serverError = '';
+ if (this.state.serverError) {
+ serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
+ }
+
+ var saveClass = 'btn';
+ if (this.state.saveNeeded) {
+ saveClass = 'btn btn-primary';
+ }
+
+ return (
+ <div className='wrapper--fixed'>
+ <h3>{'Log Settings'}</h3>
+ <form
+ className='form-horizontal'
+ role='form'
+ >
+
+ <div className='form-group'>
+ <label
+ className='control-label col-sm-4'
+ htmlFor='consoleEnable'
+ >
+ {'Log To the Console: '}
+ </label>
+ <div className='col-sm-8'>
+ <label className='radio-inline'>
+ <input
+ type='radio'
+ name='consoleEnable'
+ value='true'
+ ref='consoleEnable'
+ defaultChecked={this.props.config.LogSettings.ConsoleEnable}
+ onChange={this.handleChange}
+ />
+ {'true'}
+ </label>
+ <label className='radio-inline'>
+ <input
+ type='radio'
+ name='consoleEnable'
+ value='false'
+ defaultChecked={!this.props.config.LogSettings.ConsoleEnable}
+ onChange={this.handleChange}
+ />
+ {'false'}
+ </label>
+ <p className='help-text'>{'Typically set to false in production. Developers may set this field to true to output log messages to console based on the console level option. If true then the server will output messages to the standard output stream (stdout).'}</p>
+ </div>
+ </div>
+
+ <div className='form-group'>
+ <label
+ className='control-label col-sm-4'
+ htmlFor='consoleLevel'
+ >
+ {'Console Log Level:'}
+ </label>
+ <div className='col-sm-8'>
+ <select
+ className='form-control'
+ id='consoleLevel'
+ ref='consoleLevel'
+ defaultValue={this.props.config.LogSettings.consoleLevel}
+ onChange={this.handleChange}
+ >
+ <option value='DEBUG'>{'DEBUG'}</option>
+ <option value='INFO'>{'INFO'}</option>
+ <option value='ERROR'>{'ERROR'}</option>
+ </select>
+ <p className='help-text'>{'This setting determines the level of detail at which log events are written to the console. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers debugging issues working on debugging issues.'}</p>
+ </div>
+ </div>
+
+ <div className='form-group'>
+ <label
+ className='control-label col-sm-4'
+ >
+ {'Log To File: '}
+ </label>
+ <div className='col-sm-8'>
+ <label className='radio-inline'>
+ <input
+ type='radio'
+ name='fileEnable'
+ ref='fileEnable'
+ value='true'
+ defaultChecked={this.props.config.LogSettings.FileEnable}
+ onChange={this.handleChange}
+ />
+ {'true'}
+ </label>
+ <label className='radio-inline'>
+ <input
+ type='radio'
+ name='fileEnable'
+ value='false'
+ defaultChecked={!this.props.config.LogSettings.FileEnable}
+ onChange={this.handleChange}
+ />
+ {'false'}
+ </label>
+ <p className='help-text'>{'Typically set to true in production. When true log files are written to the file specified in file location field below.'}</p>
+ </div>
+ </div>
+
+ <div className='form-group'>
+ <label
+ className='control-label col-sm-4'
+ htmlFor='fileLevel'
+ >
+ {'File Log Level:'}
+ </label>
+ <div className='col-sm-8'>
+ <select
+ className='form-control'
+ id='fileLevel'
+ ref='fileLevel'
+ defaultValue={this.props.config.LogSettings.FileLevel}
+ onChange={this.handleChange}
+ >
+ <option value='DEBUG'>{'DEBUG'}</option>
+ <option value='INFO'>{'INFO'}</option>
+ <option value='ERROR'>{'ERROR'}</option>
+ </select>
+ <p className='help-text'>{'This setting determines the level of detail at which log events are written to the file. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers debugging issues working on debugging issues.'}</p>
+ </div>
+ </div>
+
+ <div className='form-group'>
+ <label
+ className='control-label col-sm-4'
+ htmlFor='fileLocation'
+ >
+ {'File Location:'}
+ </label>
+ <div className='col-sm-8'>
+ <input
+ type='text'
+ className='form-control'
+ id='fileLocation'
+ ref='fileLocation'
+ placeholder='Enter your file location'
+ defaultValue={this.props.config.LogSettings.FileLocation}
+ onChange={this.handleChange}
+ />
+ <p className='help-text'>{'File to which log files are written. If blank, will be set to ./logs/mattermost.log. Log rotation is enabled and new files may be created in the same directory.'}</p>
+ </div>
+ </div>
+
+ <div className='form-group'>
+ <label
+ className='control-label col-sm-4'
+ htmlFor='fileFormat'
+ >
+ {'File Format:'}
+ </label>
+ <div className='col-sm-8'>
+ <input
+ type='text'
+ className='form-control'
+ id='fileFormat'
+ ref='fileFormat'
+ placeholder='Enter your file format'
+ defaultValue={this.props.config.LogSettings.FileFormat}
+ onChange={this.handleChange}
+ />
+ <p className='help-text'>
+ {'Format of log message output. If blank will be set to "[%D %T] [%L] %M", where:'}
+ <div className='help-text'>
+ <table
+ className='table-bordered'
+ cellPadding='5'
+ >
+ <tr><td className='help-text'>{'%T'}</td><td className='help-text'>{'Time (15:04:05 MST)'}</td></tr>
+ <tr><td className='help-text'>{'%D'}</td><td className='help-text'>{'Date (2006/01/02)'}</td></tr>
+ <tr><td className='help-text'>{'%d'}</td><td className='help-text'>{'Date (01/02/06)'}</td></tr>
+ <tr><td className='help-text'>{'%L'}</td><td className='help-text'>{'Level (DEBG, INFO, EROR)'}</td></tr>
+ <tr><td className='help-text'>{'%S'}</td><td className='help-text'>{'Source'}</td></tr>
+ <tr><td className='help-text'>{'%M'}</td><td className='help-text'>{'Message'}</td></tr>
+ </table>
+ </div>
+ </p>
+ </div>
+ </div>
+
+ <div className='form-group'>
+ <div className='col-sm-12'>
+ {serverError}
+ <button
+ disabled={!this.state.saveNeeded}
+ type='submit'
+ className={saveClass}
+ onClick={this.handleSubmit}
+ id='save-button'
+ data-loading-text={'<span class=\'glyphicon glyphicon-refresh glyphicon-refresh-animate\'></span> Saving Config...'}
+ >
+ {'Save'}
+ </button>
+ </div>
+ </div>
+
+ </form>
+ </div>
+ );
+ }
+}
+
+LogSettings.propTypes = {
+ config: React.PropTypes.object
+};
diff --git a/web/react/components/admin_console/logs.jsx b/web/react/components/admin_console/logs.jsx
index d7de76a94..0bb749bbd 100644
--- a/web/react/components/admin_console/logs.jsx
+++ b/web/react/components/admin_console/logs.jsx
@@ -21,9 +21,11 @@ export default class Logs extends React.Component {
AdminStore.addLogChangeListener(this.onLogListenerChange);
AsyncClient.getLogs();
}
+
componentWillUnmount() {
AdminStore.removeLogChangeListener(this.onLogListenerChange);
}
+
onLogListenerChange() {
this.setState({
logs: AdminStore.getLogs()
diff --git a/web/react/components/channel_header.jsx b/web/react/components/channel_header.jsx
index 0dbbc20d4..8d23ec646 100644
--- a/web/react/components/channel_header.jsx
+++ b/web/react/components/channel_header.jsx
@@ -111,7 +111,7 @@ export default class ChannelHeader extends React.Component {
const popoverContent = React.renderToString(<MessageWrapper message={channel.description}/>);
let channelTitle = channel.display_name;
const currentId = UserStore.getCurrentId();
- const isAdmin = this.state.memberChannel.roles.indexOf('admin') > -1 || this.state.memberTeam.roles.indexOf('admin') > -1;
+ const isAdmin = Utils.isAdmin(this.state.memberChannel.roles) || Utils.isAdmin(this.state.memberTeam.roles);
const isDirect = (this.state.channel.type === 'D');
if (isDirect) {
diff --git a/web/react/components/channel_invite_modal.jsx b/web/react/components/channel_invite_modal.jsx
index 5feeb4e88..82fc51184 100644
--- a/web/react/components/channel_invite_modal.jsx
+++ b/web/react/components/channel_invite_modal.jsx
@@ -121,7 +121,7 @@ export default class ChannelInviteModal extends React.Component {
var currentMember = ChannelStore.getCurrentMember();
var isAdmin = false;
if (currentMember) {
- isAdmin = currentMember.roles.indexOf('admin') > -1 || UserStore.getCurrentUser().roles.indexOf('admin') > -1;
+ isAdmin = utils.isAdmin(currentMember.roles) || utils.isAdmin(UserStore.getCurrentUser().roles);
}
var content;
diff --git a/web/react/components/channel_members.jsx b/web/react/components/channel_members.jsx
index 04fa2c7a2..1eda6a104 100644
--- a/web/react/components/channel_members.jsx
+++ b/web/react/components/channel_members.jsx
@@ -130,7 +130,7 @@ export default class ChannelMembers extends React.Component {
const currentMember = ChannelStore.getCurrentMember();
let isAdmin = false;
if (currentMember) {
- isAdmin = currentMember.roles.indexOf('admin') > -1 || UserStore.getCurrentUser().roles.indexOf('admin') > -1;
+ isAdmin = Utils.isAdmin(currentMember.roles) || Utils.isAdmin(UserStore.getCurrentUser().roles);
}
var memberList = null;
diff --git a/web/react/components/member_list_item.jsx b/web/react/components/member_list_item.jsx
index 9a31a2e30..158ff65be 100644
--- a/web/react/components/member_list_item.jsx
+++ b/web/react/components/member_list_item.jsx
@@ -2,6 +2,7 @@
// See License.txt for license information.
var UserStore = require('../stores/user_store.jsx');
+const Utils = require('../utils/utils.jsx');
export default class MemberListItem extends React.Component {
constructor(props) {
@@ -26,7 +27,7 @@ export default class MemberListItem extends React.Component {
render() {
var member = this.props.member;
var isAdmin = this.props.isAdmin;
- var isMemberAdmin = member.roles.indexOf('admin') > -1;
+ var isMemberAdmin = Utils.isAdmin(member.roles);
var timestamp = UserStore.getCurrentUser().update_at;
var invite;
diff --git a/web/react/components/navbar.jsx b/web/react/components/navbar.jsx
index cae9f12e4..da9874b0b 100644
--- a/web/react/components/navbar.jsx
+++ b/web/react/components/navbar.jsx
@@ -8,6 +8,7 @@ var ChannelStore = require('../stores/channel_store.jsx');
var TeamStore = require('../stores/team_store.jsx');
var MessageWrapper = require('./message_wrapper.jsx');
var NotifyCounts = require('./notify_counts.jsx');
+const Utils = require('../utils/utils.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
@@ -335,7 +336,7 @@ export default class Navbar extends React.Component {
options={{singleline: true, mentionHighlight: false}}
/>
);
- isAdmin = this.state.member.roles.indexOf('admin') > -1;
+ isAdmin = Utils.isAdmin(this.state.member.roles);
if (channel.type === 'O') {
channelTitle = channel.display_name;
diff --git a/web/react/components/navbar_dropdown.jsx b/web/react/components/navbar_dropdown.jsx
index b7566cfb9..4c01d2c43 100644
--- a/web/react/components/navbar_dropdown.jsx
+++ b/web/react/components/navbar_dropdown.jsx
@@ -30,12 +30,12 @@ export default class NavbarDropdown extends React.Component {
UserStore.addTeamsChangeListener(this.onListenerChange);
TeamStore.addChangeListener(this.onListenerChange);
- $(React.findDOMNode(this.refs.dropdown)).on('hide.bs.dropdown', function resetDropdown() {
+ $(React.findDOMNode(this.refs.dropdown)).on('hide.bs.dropdown', () => {
this.blockToggle = true;
- setTimeout(function blockTimeout() {
+ setTimeout(() => {
this.blockToggle = false;
- }.bind(this), 100);
- }.bind(this));
+ }, 100);
+ });
}
componentWillUnmount() {
UserStore.removeTeamsChangeListener(this.onListenerChange);
@@ -53,12 +53,16 @@ export default class NavbarDropdown extends React.Component {
var teamLink = '';
var inviteLink = '';
var manageLink = '';
+ var sysAdminLink = '';
+ var adminDivider = '';
var currentUser = UserStore.getCurrentUser();
var isAdmin = false;
+ var isSystemAdmin = false;
var teamSettings = null;
if (currentUser != null) {
- isAdmin = currentUser.roles.indexOf('admin') > -1;
+ isAdmin = Utils.isAdmin(currentUser.roles);
+ isSystemAdmin = Utils.isInRole(currentUser.roles, 'system_admin');
inviteLink = (
<li>
@@ -67,7 +71,7 @@ export default class NavbarDropdown extends React.Component {
data-toggle='modal'
data-target='#invite_member'
>
- Invite New Member
+ {'Invite New Member'}
</a>
</li>
);
@@ -82,7 +86,7 @@ export default class NavbarDropdown extends React.Component {
data-title='Team Invite'
data-value={Utils.getWindowLocationOrigin() + '/signup_user_complete/?id=' + currentUser.team_id}
>
- Get Team Invite Link
+ {'Get Team Invite Link'}
</a>
</li>
);
@@ -97,19 +101,36 @@ export default class NavbarDropdown extends React.Component {
data-toggle='modal'
data-target='#team_members'
>
- Manage Team
+ {'Manage Team'}
+ </a>
+ </li>
+ );
+
+ adminDivider = (<li className='divider'></li>);
+
+ teamSettings = (
+ <li>
+ <a
+ href='#'
+ data-toggle='modal'
+ data-target='#team_settings'
+ >
+ {'Team Settings'}
+ </a>
+ </li>
+ );
+ }
+
+ if (isSystemAdmin) {
+ sysAdminLink = (
+ <li>
+ <a
+ href='/admin_console'
+ >
+ {'System Console'}
</a>
</li>
);
- teamSettings = (<li>
- <a
- href='#'
- data-toggle='modal'
- data-target='#team_settings'
- >
- Team Settings
- </a>
- </li>);
}
var teams = [];
@@ -123,9 +144,9 @@ export default class NavbarDropdown extends React.Component {
);
if (this.state.teams.length > 1 && this.state.currentTeam) {
var curTeamName = this.state.currentTeam.name;
- this.state.teams.forEach(function listTeams(teamName) {
+ this.state.teams.forEach((teamName) => {
if (teamName !== curTeamName) {
- teams.push(<li key={teamName}><a href={Utils.getWindowLocationOrigin() + '/' + teamName}>Switch to {teamName}</a></li>);
+ teams.push(<li key={teamName}><a href={Utils.getWindowLocationOrigin() + '/' + teamName}>{'Switch to ' + teamName}</a></li>);
}
});
}
@@ -135,7 +156,7 @@ export default class NavbarDropdown extends React.Component {
target='_blank'
href={Utils.getWindowLocationOrigin() + '/signup_team'}
>
- Create a New Team
+ {'Create a New Team'}
</a>
</li>);
@@ -167,21 +188,23 @@ export default class NavbarDropdown extends React.Component {
data-toggle='modal'
data-target='#user_settings'
>
- Account Settings
+ {'Account Settings'}
</a>
</li>
- {teamSettings}
{inviteLink}
{teamLink}
- {manageLink}
<li>
<a
href='#'
onClick={this.handleLogoutClick}
>
- Logout
+ {'Logout'}
</a>
</li>
+ {adminDivider}
+ {teamSettings}
+ {manageLink}
+ {sysAdminLink}
{teams}
<li className='divider'></li>
<li>
@@ -189,7 +212,7 @@ export default class NavbarDropdown extends React.Component {
target='_blank'
href='/static/help/help.html'
>
- Help
+ {'Help'}
</a>
</li>
<li>
@@ -197,7 +220,7 @@ export default class NavbarDropdown extends React.Component {
target='_blank'
href='/static/help/report_problem.html'
>
- Report a Problem
+ {'Report a Problem'}
</a>
</li>
</ul>
diff --git a/web/react/components/new_channel_modal.jsx b/web/react/components/new_channel_modal.jsx
index fc7b8c183..1488a1431 100644
--- a/web/react/components/new_channel_modal.jsx
+++ b/web/react/components/new_channel_modal.jsx
@@ -107,8 +107,8 @@ export default class NewChannelModal extends React.Component {
{channelSwitchText}
</div>
<div className={displayNameClass}>
- <label className='col-sm-2 form__label control-label'>{'Name'}</label>
- <div className='col-sm-10'>
+ <label className='col-sm-3 form__label control-label'>{'Name'}</label>
+ <div className='col-sm-9'>
<input
onChange={this.handleChange}
type='text'
@@ -121,7 +121,7 @@ export default class NewChannelModal extends React.Component {
tabIndex='1'
/>
{displayNameError}
- <p className='input__help'>
+ <p className='input__help dark'>
{'Channel URL: ' + prettyTeamURL + this.props.channelData.name + ' ('}
<a
href='#'
@@ -134,11 +134,11 @@ export default class NewChannelModal extends React.Component {
</div>
</div>
<div className='form-group less'>
- <div className='col-sm-2'>
+ <div className='col-sm-3'>
<label className='form__label control-label'>{'Description'}</label>
<label className='form__label light'>{'(optional)'}</label>
</div>
- <div className='col-sm-10'>
+ <div className='col-sm-9'>
<textarea
className='form-control no-resize'
ref='channel_desc'
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index 3be615bb9..8020714cd 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -154,7 +154,7 @@ export default class PostBody extends React.Component {
return (
<div className='post-body'>
{comment}
- <p
+ <div
key={`${post.id}_message`}
id={`${post.id}_message`}
className={postClass}
@@ -164,7 +164,7 @@ export default class PostBody extends React.Component {
onClick={TextFormatting.handleClick}
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.state.message)}}
/>
- </p>
+ </div>
{fileAttachmentHolder}
{embed}
</div>
diff --git a/web/react/components/post_info.jsx b/web/react/components/post_info.jsx
index c80b287a3..d2a0a4035 100644
--- a/web/react/components/post_info.jsx
+++ b/web/react/components/post_info.jsx
@@ -20,7 +20,7 @@ export default class PostInfo extends React.Component {
createDropdown() {
var post = this.props.post;
var isOwner = UserStore.getCurrentId() === post.user_id;
- var isAdmin = UserStore.getCurrentUser().roles.indexOf('admin') > -1;
+ var isAdmin = utils.isAdmin(UserStore.getCurrentUser().roles);
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || post.state === Constants.POST_DELETED) {
return '';
@@ -151,7 +151,10 @@ export default class PostInfo extends React.Component {
return (
<ul className='post-header post-info'>
<li className='post-header-col'>
- <time className='post-profile-time'>
+ <time
+ className='post-profile-time'
+ title={new Date(post.create_at).toString()}
+ >
{utils.displayDateTime(post.create_at)}
</time>
</li>
diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx
index faa5e5f0b..94cccaac3 100644
--- a/web/react/components/post_list.jsx
+++ b/web/react/components/post_list.jsx
@@ -419,7 +419,7 @@ export default class PostList extends React.Component {
var members = ChannelStore.getExtraInfo(channel.id).members;
for (var i = 0; i < members.length; i++) {
- if (members[i].roles.indexOf('admin') > -1) {
+ if (utils.isAdmin(members[i].roles)) {
return members[i].username;
}
}
diff --git a/web/react/components/rhs_comment.jsx b/web/react/components/rhs_comment.jsx
index ed136c01f..73623179f 100644
--- a/web/react/components/rhs_comment.jsx
+++ b/web/react/components/rhs_comment.jsx
@@ -193,7 +193,10 @@ export default class RhsComment extends React.Component {
<strong><UserProfile userId={post.user_id} /></strong>
</li>
<li className='post-header-col'>
- <time className='post-right-comment-time'>
+ <time
+ className='post-profile-time'
+ title={new Date(post.create_at).toString()}
+ >
{Utils.displayCommentDateTime(post.create_at)}
</time>
</li>
diff --git a/web/react/components/rhs_root_post.jsx b/web/react/components/rhs_root_post.jsx
index 85755a85c..4ed97d00a 100644
--- a/web/react/components/rhs_root_post.jsx
+++ b/web/react/components/rhs_root_post.jsx
@@ -132,7 +132,14 @@ export default class RhsRootPost extends React.Component {
<div className='post__content'>
<ul className='post-header'>
<li className='post-header-col'><strong><UserProfile userId={post.user_id} /></strong></li>
- <li className='post-header-col'><time className='post-right-root-time'>{utils.displayCommentDateTime(post.create_at)}</time></li>
+ <li className='post-header-col'>
+ <time
+ className='post-profile-time'
+ title={new Date(post.create_at).toString()}
+ >
+ {utils.displayCommentDateTime(post.create_at)}
+ </time>
+ </li>
<li className='post-header-col post-header__reply'>
<div className='dropdown'>
{ownerOptions}
diff --git a/web/react/components/sidebar_header.jsx b/web/react/components/sidebar_header.jsx
index 959411f1e..072c14e0a 100644
--- a/web/react/components/sidebar_header.jsx
+++ b/web/react/components/sidebar_header.jsx
@@ -12,7 +12,8 @@ export default class SidebarHeader extends React.Component {
this.state = {};
}
- toggleDropdown() {
+ toggleDropdown(e) {
+ e.preventDefault();
if (this.refs.dropdown.blockToggle) {
this.refs.dropdown.blockToggle = false;
return;
diff --git a/web/react/components/sidebar_right_menu.jsx b/web/react/components/sidebar_right_menu.jsx
index 5ecd502ba..2671d560b 100644
--- a/web/react/components/sidebar_right_menu.jsx
+++ b/web/react/components/sidebar_right_menu.jsx
@@ -26,7 +26,7 @@ export default class SidebarRightMenu extends React.Component {
var isAdmin = false;
if (currentUser != null) {
- isAdmin = currentUser.roles.indexOf('admin') > -1;
+ isAdmin = utils.isAdmin(currentUser.roles);
inviteLink = (
<li>
diff --git a/web/react/components/user_settings_security.jsx b/web/react/components/user_settings_security.jsx
index 6ccd09cb1..c10d790ae 100644
--- a/web/react/components/user_settings_security.jsx
+++ b/web/react/components/user_settings_security.jsx
@@ -251,6 +251,17 @@ export default class SecurityTab extends React.Component {
<div className='divider-dark first'/>
{passwordSection}
<div className='divider-dark'/>
+ <ul
+ className='section-min'
+ >
+ <li className='col-sm-10 section-title'>{'Version ' + global.window.config.Version}</li>
+ <li className='col-sm-7 section-describe'>
+ <div className='text-nowrap'>{'Build Number: ' + global.window.config.BuildNumber}</div>
+ <div className='text-nowrap'>{'Build Date: ' + global.window.config.BuildDate}</div>
+ <div className='text-nowrap'>{'Build Hash: ' + global.window.config.BuildHash}</div>
+ </li>
+ </ul>
+ <div className='divider-dark'/>
<br></br>
<a
data-toggle='modal'
diff --git a/web/react/package.json b/web/react/package.json
index 04e0f6bab..dd7d45f8a 100644
--- a/web/react/package.json
+++ b/web/react/package.json
@@ -9,7 +9,8 @@
"object-assign": "3.0.0",
"react-zeroclipboard-mixin": "0.1.0",
"twemoji": "1.4.1",
- "babel-runtime": "5.8.24"
+ "babel-runtime": "5.8.24",
+ "marked": "0.3.5"
},
"devDependencies": {
"browserify": "11.0.1",
diff --git a/web/react/stores/admin_store.jsx b/web/react/stores/admin_store.jsx
index 591b52d05..dd5b60a24 100644
--- a/web/react/stores/admin_store.jsx
+++ b/web/react/stores/admin_store.jsx
@@ -8,16 +8,22 @@ var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
var LOG_CHANGE_EVENT = 'log_change';
+var CONFIG_CHANGE_EVENT = 'config_change';
class AdminStoreClass extends EventEmitter {
constructor() {
super();
this.logs = null;
+ this.config = null;
this.emitLogChange = this.emitLogChange.bind(this);
this.addLogChangeListener = this.addLogChangeListener.bind(this);
this.removeLogChangeListener = this.removeLogChangeListener.bind(this);
+
+ this.emitConfigChange = this.emitConfigChange.bind(this);
+ this.addConfigChangeListener = this.addConfigChangeListener.bind(this);
+ this.removeConfigChangeListener = this.removeConfigChangeListener.bind(this);
}
emitLogChange() {
@@ -32,6 +38,18 @@ class AdminStoreClass extends EventEmitter {
this.removeListener(LOG_CHANGE_EVENT, callback);
}
+ emitConfigChange() {
+ this.emit(CONFIG_CHANGE_EVENT);
+ }
+
+ addConfigChangeListener(callback) {
+ this.on(CONFIG_CHANGE_EVENT, callback);
+ }
+
+ removeConfigChangeListener(callback) {
+ this.removeListener(CONFIG_CHANGE_EVENT, callback);
+ }
+
getLogs() {
return this.logs;
}
@@ -39,6 +57,14 @@ class AdminStoreClass extends EventEmitter {
saveLogs(logs) {
this.logs = logs;
}
+
+ getConfig() {
+ return this.config;
+ }
+
+ saveConfig(config) {
+ this.config = config;
+ }
}
var AdminStore = new AdminStoreClass();
@@ -51,6 +77,10 @@ AdminStoreClass.dispatchToken = AppDispatcher.register((payload) => {
AdminStore.saveLogs(action.logs);
AdminStore.emitLogChange();
break;
+ case ActionTypes.RECIEVED_CONFIG:
+ AdminStore.saveConfig(action.config);
+ AdminStore.emitConfigChange();
+ break;
default:
}
});
diff --git a/web/react/stores/browser_store.jsx b/web/react/stores/browser_store.jsx
index e1ca52746..d2dedb271 100644
--- a/web/react/stores/browser_store.jsx
+++ b/web/react/stores/browser_store.jsx
@@ -9,9 +9,6 @@ function getPrefix() {
return UserStore.getCurrentId() + '_';
}
-// Also change model/utils.go ETAG_ROOT_VERSION
-var BROWSER_STORE_VERSION = '.5';
-
class BrowserStoreClass {
constructor() {
this.getItem = this.getItem.bind(this);
@@ -25,9 +22,9 @@ class BrowserStoreClass {
this.isLocalStorageSupported = this.isLocalStorageSupported.bind(this);
var currentVersion = localStorage.getItem('local_storage_version');
- if (currentVersion !== BROWSER_STORE_VERSION) {
+ if (currentVersion !== global.window.config.Version) {
this.clear();
- localStorage.setItem('local_storage_version', BROWSER_STORE_VERSION);
+ localStorage.setItem('local_storage_version', global.window.config.Version);
}
}
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 3e23e5c33..ed228f6c4 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -345,6 +345,32 @@ export function getLogs() {
);
}
+export function getConfig() {
+ if (isCallInProgress('getConfig')) {
+ return;
+ }
+
+ callTracker.getConfig = utils.getTimestamp();
+ client.getConfig(
+ (data, textStatus, xhr) => {
+ callTracker.getConfig = 0;
+
+ if (xhr.status === 304 || !data) {
+ return;
+ }
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_CONFIG,
+ config: data
+ });
+ },
+ (err) => {
+ callTracker.getConfig = 0;
+ dispatchError(err, 'getConfig');
+ }
+ );
+}
+
export function findTeams(email) {
if (isCallInProgress('findTeams_' + email)) {
return;
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index ba3042d78..c9eb09c00 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -297,7 +297,7 @@ export function getLogs(success, error) {
dataType: 'json',
contentType: 'application/json',
type: 'GET',
- success: success,
+ success,
error: function onError(xhr, status, err) {
var e = handleError('getLogs', xhr, status, err);
error(e);
@@ -305,6 +305,35 @@ export function getLogs(success, error) {
});
}
+export function getConfig(success, error) {
+ $.ajax({
+ url: '/api/v1/admin/config',
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'GET',
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('getConfig', xhr, status, err);
+ error(e);
+ }
+ });
+}
+
+export function saveConfig(config, success, error) {
+ $.ajax({
+ url: '/api/v1/admin/save_config',
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'POST',
+ data: JSON.stringify(config),
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('saveConfig', xhr, status, err);
+ error(e);
+ }
+ });
+}
+
export function getMeSynchronous(success, error) {
var currentUser = null;
$.ajax({
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
new file mode 100644
index 000000000..8c63810cd
--- /dev/null
+++ b/web/react/utils/markdown.jsx
@@ -0,0 +1,16 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+const marked = require('marked');
+
+export class MattermostMarkdownRenderer extends marked.Renderer {
+ link(href, title, text) {
+ let outHref = href;
+
+ if (outHref.lastIndexOf('http', 0) !== 0) {
+ outHref = `http://${outHref}`;
+ }
+
+ return super.link(outHref, title, text);
+ }
+}
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index 2025e16da..4e390f708 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -3,21 +3,38 @@
const Autolinker = require('autolinker');
const Constants = require('./constants.jsx');
+const Markdown = require('./markdown.jsx');
const UserStore = require('../stores/user_store.jsx');
const Utils = require('./utils.jsx');
+const marked = require('marked');
+
+const markdownRenderer = new Markdown.MattermostMarkdownRenderer();
+
// Performs formatting of user posts including highlighting mentions and search terms and converting urls, hashtags, and
// @mentions to links by taking a user's message and returning a string of formatted html. Also takes a number of options
// as part of the second parameter:
// - searchTerm - If specified, this word is highlighted in the resulting html. Defaults to nothing.
// - mentionHighlight - Specifies whether or not to highlight mentions of the current user. Defaults to true.
// - singleline - Specifies whether or not to remove newlines. Defaults to false.
+// - markdown - Enables markdown parsing. Defaults to true.
export function formatText(text, options = {}) {
- let output = sanitizeHtml(text);
+ if (!('markdown' in options)) {
+ options.markdown = true;
+ }
+
+ // wait until marked can sanitize the html so that we don't break markdown block quotes
+ let output;
+ if (!options.markdown) {
+ output = sanitizeHtml(text);
+ } else {
+ output = text;
+ }
+
const tokens = new Map();
// replace important words and phrases with tokens
- output = autolinkUrls(output, tokens);
+ output = autolinkUrls(output, tokens, !!options.markdown);
output = autolinkAtMentions(output, tokens);
output = autolinkHashtags(output, tokens);
@@ -29,11 +46,21 @@ export function formatText(text, options = {}) {
output = highlightCurrentMentions(output, tokens);
}
+ // perform markdown parsing while we have an html-free input string
+ if (options.markdown) {
+ output = marked(output, {
+ renderer: markdownRenderer,
+ sanitize: true
+ });
+ }
+
// reinsert tokens with formatted versions of the important words and phrases
output = replaceTokens(output, tokens);
// replace newlines with html line breaks
- output = replaceNewlines(output, options.singleline);
+ if (options.singleline) {
+ output = replaceNewlines(output);
+ }
return output;
}
@@ -51,17 +78,17 @@ export function sanitizeHtml(text) {
return output;
}
-function autolinkUrls(text, tokens) {
+function autolinkUrls(text, tokens, markdown) {
function replaceUrlWithToken(autolinker, match) {
const linkText = match.getMatchedText();
let url = linkText;
- if (!url.lastIndexOf('http', 0) === 0) {
+ if (url.lastIndexOf('http', 0) !== 0) {
url = `http://${linkText}`;
}
const index = tokens.size;
- const alias = `__MM_LINK${index}__`;
+ const alias = `MM_LINK${index}`;
tokens.set(alias, {
value: `<a class='theme' target='_blank' href='${url}'>${linkText}</a>`,
@@ -81,7 +108,30 @@ function autolinkUrls(text, tokens) {
replaceFn: replaceUrlWithToken
});
- return autolinker.link(text);
+ let output = text;
+
+ // temporarily replace markdown links if markdown is enabled so that we don't accidentally parse them twice
+ const markdownLinkTokens = new Map();
+ if (markdown) {
+ function replaceMarkdownLinkWithToken(markdownLink) {
+ const index = markdownLinkTokens.size;
+ const alias = `MM_MARKDOWNLINK${index}`;
+
+ markdownLinkTokens.set(alias, {value: markdownLink});
+
+ return alias;
+ }
+
+ output = output.replace(/\]\([^\)]*\)/g, replaceMarkdownLinkWithToken);
+ }
+
+ output = autolinker.link(output);
+
+ if (markdown) {
+ output = replaceTokens(output, markdownLinkTokens);
+ }
+
+ return output;
}
function autolinkAtMentions(text, tokens) {
@@ -91,7 +141,7 @@ function autolinkAtMentions(text, tokens) {
const usernameLower = username.toLowerCase();
if (Constants.SPECIAL_MENTIONS.indexOf(usernameLower) !== -1 || UserStore.getProfileByUsername(usernameLower)) {
const index = tokens.size;
- const alias = `__MM_ATMENTION${index}__`;
+ const alias = `MM_ATMENTION${index}`;
tokens.set(alias, {
value: `<a class='mention-link' href='#' data-mention='${usernameLower}'>${mention}</a>`,
@@ -119,7 +169,7 @@ function highlightCurrentMentions(text, tokens) {
for (const [alias, token] of tokens) {
if (mentionKeys.indexOf(token.originalText) !== -1) {
const index = tokens.size + newTokens.size;
- const newAlias = `__MM_SELFMENTION${index}__`;
+ const newAlias = `MM_SELFMENTION${index}`;
newTokens.set(newAlias, {
value: `<span class='mention-highlight'>${alias}</span>`,
@@ -138,7 +188,7 @@ function highlightCurrentMentions(text, tokens) {
// look for self mentions in the text
function replaceCurrentMentionWithToken(fullMatch, prefix, mention) {
const index = tokens.size;
- const alias = `__MM_SELFMENTION${index}__`;
+ const alias = `MM_SELFMENTION${index}`;
tokens.set(alias, {
value: `<span class='mention-highlight'>${mention}</span>`,
@@ -162,7 +212,7 @@ function autolinkHashtags(text, tokens) {
for (const [alias, token] of tokens) {
if (token.originalText.lastIndexOf('#', 0) === 0) {
const index = tokens.size + newTokens.size;
- const newAlias = `__MM_HASHTAG${index}__`;
+ const newAlias = `MM_HASHTAG${index}`;
newTokens.set(newAlias, {
value: `<a class='mention-link' href='#' data-hashtag='${token.originalText}'>${token.originalText}</a>`,
@@ -181,7 +231,7 @@ function autolinkHashtags(text, tokens) {
// look for hashtags in the text
function replaceHashtagWithToken(fullMatch, prefix, hashtag) {
const index = tokens.size;
- const alias = `__MM_HASHTAG${index}__`;
+ const alias = `MM_HASHTAG${index}`;
tokens.set(alias, {
value: `<a class='mention-link' href='#' data-hashtag='${hashtag}'>${hashtag}</a>`,
@@ -201,7 +251,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
for (const [alias, token] of tokens) {
if (token.originalText === searchTerm) {
const index = tokens.size + newTokens.size;
- const newAlias = `__MM_SEARCHTERM${index}__`;
+ const newAlias = `MM_SEARCHTERM${index}`;
newTokens.set(newAlias, {
value: `<span class='search-highlight'>${alias}</span>`,
@@ -219,7 +269,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
function replaceSearchTermWithToken(fullMatch, prefix, word) {
const index = tokens.size;
- const alias = `__MM_SEARCHTERM${index}__`;
+ const alias = `MM_SEARCHTERM${index}`;
tokens.set(alias, {
value: `<span class='search-highlight'>${word}</span>`,
@@ -246,11 +296,7 @@ function replaceTokens(text, tokens) {
return output;
}
-function replaceNewlines(text, singleline) {
- if (!singleline) {
- return text.replace(/\n/g, '<br />');
- }
-
+function replaceNewlines(text) {
return text.replace(/\n/g, ' ');
}
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 032cf4ff4..074591489 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -54,6 +54,29 @@ export function isTestDomain() {
return false;
}
+export function isInRole(roles, inRole) {
+ var parts = roles.split(' ');
+ for (var i = 0; i < parts.length; i++) {
+ if (parts[i] === inRole) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+export function isAdmin(roles) {
+ if (isInRole(roles, 'admin')) {
+ return true;
+ }
+
+ if (isInRole(roles, 'system_admin')) {
+ return true;
+ }
+
+ return false;
+}
+
export function getDomainWithOutSub() {
var parts = window.location.host.split('.');
diff --git a/web/sass-files/sass/partials/_forms.scss b/web/sass-files/sass/partials/_forms.scss
index 268576a98..c8b08f44d 100644
--- a/web/sass-files/sass/partials/_forms.scss
+++ b/web/sass-files/sass/partials/_forms.scss
@@ -5,9 +5,10 @@
.form__label {
text-align: left;
padding-right: 3px;
- font-weight: bold;
+ font-weight: 600;
font-size: 1.1em;
&.light {
+ font-weight: normal;
color: #999;
font-size: 1.05em;
font-style: italic;
@@ -17,6 +18,9 @@
.input__help {
color: #777;
margin: 10px 0 0 10px;
+ &.dark {
+ color: #222;
+ }
&.error {
color: #a94442;
}
diff --git a/web/sass-files/sass/partials/_sidebar--left.scss b/web/sass-files/sass/partials/_sidebar--left.scss
index f714a23f8..94583b153 100644
--- a/web/sass-files/sass/partials/_sidebar--left.scss
+++ b/web/sass-files/sass/partials/_sidebar--left.scss
@@ -11,7 +11,7 @@
padding-top: 44px;
}
.dropdown-menu {
- max-height: 300px;
+ max-height: 400px;
overflow-x: hidden;
overflow-y: auto;
max-width: 200px;