[PLT-5864] Move teammate name display setting to the System Console (#6681)
* move teammate name display setting to the system console * update all the likes of TeammateNameDisplay names * fix gofmt error * rebase and fix conflict
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
fb57b3dd53
Коммит
eea64f8049
@@ -39,6 +39,10 @@ const (
|
||||
DIRECT_MESSAGE_ANY = "any"
|
||||
DIRECT_MESSAGE_TEAM = "team"
|
||||
|
||||
SHOW_USERNAME = "username"
|
||||
SHOW_NICKNAME_FULLNAME = "nickname_full_name"
|
||||
SHOW_FULLNAME = "full_name"
|
||||
|
||||
PERMISSIONS_ALL = "all"
|
||||
PERMISSIONS_CHANNEL_ADMIN = "channel_admin"
|
||||
PERMISSIONS_TEAM_ADMIN = "team_admin"
|
||||
@@ -322,6 +326,7 @@ type TeamSettings struct {
|
||||
UserStatusAwayTimeout *int64
|
||||
MaxChannelsPerTeam *int64
|
||||
MaxNotificationsPerChannel *int64
|
||||
TeammateNameDisplay *string
|
||||
}
|
||||
|
||||
type LdapSettings struct {
|
||||
@@ -702,6 +707,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.TeamSettings.MaxNotificationsPerChannel = 1000
|
||||
}
|
||||
|
||||
if o.TeamSettings.TeammateNameDisplay == nil {
|
||||
o.TeamSettings.TeammateNameDisplay = new(string)
|
||||
*o.TeamSettings.TeammateNameDisplay = SHOW_FULLNAME
|
||||
}
|
||||
|
||||
if o.EmailSettings.EnableSignInWithEmail == nil {
|
||||
o.EmailSettings.EnableSignInWithEmail = new(bool)
|
||||
|
||||
@@ -1394,6 +1404,10 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "")
|
||||
}
|
||||
|
||||
if !(*o.TeamSettings.TeammateNameDisplay == SHOW_FULLNAME || *o.TeamSettings.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *o.TeamSettings.TeammateNameDisplay == SHOW_USERNAME) {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.teammate_name_display.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(o.SqlSettings.AtRestEncryptKey) < 32 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.encrypt_sql.app_error", nil, "")
|
||||
}
|
||||
|
||||
@@ -17,13 +17,8 @@ const (
|
||||
PREFERENCE_CATEGORY_ADVANCED_SETTINGS = "advanced_settings"
|
||||
PREFERENCE_CATEGORY_FLAGGED_POST = "flagged_post"
|
||||
|
||||
PREFERENCE_CATEGORY_DISPLAY_SETTINGS = "display_settings"
|
||||
PREFERENCE_NAME_COLLAPSE_SETTING = "collapse_previews"
|
||||
PREFERENCE_NAME_DISPLAY_NAME_FORMAT = "name_format"
|
||||
PREFERENCE_VALUE_DISPLAY_NAME_NICKNAME = "nickname_full_name"
|
||||
PREFERENCE_VALUE_DISPLAY_NAME_FULL = "full_name"
|
||||
PREFERENCE_VALUE_DISPLAY_NAME_USERNAME = "username"
|
||||
PREFERENCE_DEFAULT_DISPLAY_NAME_FORMAT = PREFERENCE_VALUE_DISPLAY_NAME_USERNAME
|
||||
PREFERENCE_CATEGORY_DISPLAY_SETTINGS = "display_settings"
|
||||
PREFERENCE_NAME_COLLAPSE_SETTING = "collapse_previews"
|
||||
|
||||
PREFERENCE_CATEGORY_THEME = "theme"
|
||||
// the name for theme props is the team id
|
||||
|
||||
@@ -383,26 +383,16 @@ func (u *User) GetFullName() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (u *User) GetDisplayName() string {
|
||||
if u.Nickname != "" {
|
||||
return u.Nickname
|
||||
} else if fullName := u.GetFullName(); fullName != "" {
|
||||
return fullName
|
||||
} else {
|
||||
return u.Username
|
||||
}
|
||||
}
|
||||
|
||||
func (u *User) GetDisplayNameForPreference(nameFormat string) string {
|
||||
func (u *User) GetDisplayName(nameFormat string) string {
|
||||
displayName := u.Username
|
||||
|
||||
if nameFormat == PREFERENCE_VALUE_DISPLAY_NAME_NICKNAME {
|
||||
if nameFormat == SHOW_NICKNAME_FULLNAME {
|
||||
if u.Nickname != "" {
|
||||
displayName = u.Nickname
|
||||
} else if fullName := u.GetFullName(); fullName != "" {
|
||||
displayName = fullName
|
||||
}
|
||||
} else if nameFormat == PREFERENCE_VALUE_DISPLAY_NAME_FULL {
|
||||
} else if nameFormat == SHOW_FULLNAME {
|
||||
if fullName := u.GetFullName(); fullName != "" {
|
||||
displayName = fullName
|
||||
}
|
||||
|
||||
@@ -179,20 +179,37 @@ func TestUserGetFullName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserGetDisplayName(t *testing.T) {
|
||||
user := User{Username: "user"}
|
||||
user := User{Username: "username"}
|
||||
|
||||
if displayName := user.GetDisplayName(); displayName != "user" {
|
||||
if displayName := user.GetDisplayName(SHOW_FULLNAME); displayName != "username" {
|
||||
t.Fatal("Display name should be username")
|
||||
}
|
||||
|
||||
if displayName := user.GetDisplayName(SHOW_NICKNAME_FULLNAME); displayName != "username" {
|
||||
t.Fatal("Display name should be username")
|
||||
}
|
||||
|
||||
if displayName := user.GetDisplayName(SHOW_USERNAME); displayName != "username" {
|
||||
t.Fatal("Display name should be username")
|
||||
}
|
||||
|
||||
user.FirstName = "first"
|
||||
user.LastName = "last"
|
||||
if displayName := user.GetDisplayName(); displayName != "first last" {
|
||||
|
||||
if displayName := user.GetDisplayName(SHOW_FULLNAME); displayName != "first last" {
|
||||
t.Fatal("Display name should be full name")
|
||||
}
|
||||
|
||||
if displayName := user.GetDisplayName(SHOW_NICKNAME_FULLNAME); displayName != "first last" {
|
||||
t.Fatal("Display name should be full name since there is no nickname")
|
||||
}
|
||||
|
||||
if displayName := user.GetDisplayName(SHOW_USERNAME); displayName != "username" {
|
||||
t.Fatal("Display name should be username")
|
||||
}
|
||||
|
||||
user.Nickname = "nickname"
|
||||
if displayName := user.GetDisplayName(); displayName != "nickname" {
|
||||
if displayName := user.GetDisplayName(SHOW_NICKNAME_FULLNAME); displayName != "nickname" {
|
||||
t.Fatal("Display name should be nickname")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user