PLT-2992 Added the ability to use different themes for each team (#3411)
* Cleaned up user_settings_theme.jsx and import_theme_modal.jsx * Made ImportThemeModal use a callback to return the theme to the user settings modal instead of saving it directly * Moved user theme from model to preferences * Added serverside API to delete preferences TODO update package with client stuff * Changed constants.jsx so that Preferences and ActionTypes can be imported on their own * Updated ThemeProps migration code to properly rename solarized code themes * Fixed warnings thrown by AppDispatcher * Added clientside UI to support team-specific themes * Removed debugging code from test * Fixed setting a user's theme when they haven't set their theme before
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
8e810bc2eb
Коммит
caabfbcdd5
@@ -4,6 +4,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -31,7 +32,7 @@ func TestPreferenceIsValid(t *testing.T) {
|
||||
|
||||
preference.Category = PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW
|
||||
if err := preference.IsValid(); err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
preference.Name = strings.Repeat("01234567890", 20)
|
||||
@@ -41,16 +42,48 @@ func TestPreferenceIsValid(t *testing.T) {
|
||||
|
||||
preference.Name = NewId()
|
||||
if err := preference.IsValid(); err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
preference.Value = strings.Repeat("01234567890", 20)
|
||||
preference.Value = strings.Repeat("01234567890", 201)
|
||||
if err := preference.IsValid(); err == nil {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
preference.Value = "1234garbage"
|
||||
if err := preference.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
preference.Category = PREFERENCE_CATEGORY_THEME
|
||||
if err := preference.IsValid(); err == nil {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
preference.Value = `{"color": "#ff0000", "color2": "#faf"}`
|
||||
if err := preference.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreferencePreUpdate(t *testing.T) {
|
||||
preference := Preference{
|
||||
Category: PREFERENCE_CATEGORY_THEME,
|
||||
Value: `{"color": "#ff0000", "color2": "#faf", "codeTheme": "github", "invalid": "invalid"}`,
|
||||
}
|
||||
|
||||
preference.PreUpdate()
|
||||
|
||||
var props map[string]string
|
||||
if err := json.NewDecoder(strings.NewReader(preference.Value)).Decode(&props); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if props["color"] != "#ff0000" || props["color2"] != "#faf" || props["codeTheme"] != "github" {
|
||||
t.Fatal("shouldn't have changed valid props")
|
||||
}
|
||||
|
||||
if props["invalid"] == "invalid" {
|
||||
t.Fatal("should have changed invalid prop")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user