mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
Fix for category not being set by UI, set to existing Category. (#4161)
* remove valid check and set category type to retrieved category type * lint fix * fix test * update code for testing to continue to work. * update comments
This commit is contained in:
parent
e83b05b661
commit
cf97e300c1
@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/focalboard/server/model"
|
||||
"github.com/mattermost/focalboard/server/utils"
|
||||
@ -33,6 +34,10 @@ func (a *App) CreateCategory(category *model.Category) (*model.Category, error)
|
||||
}
|
||||
|
||||
func (a *App) UpdateCategory(category *model.Category) (*model.Category, error) {
|
||||
// set to default category, UI doesn't create with Type
|
||||
if strings.TrimSpace(category.Type) == "" {
|
||||
category.Type = model.CategoryTypeCustom
|
||||
}
|
||||
if err := category.IsValid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -55,6 +60,8 @@ func (a *App) UpdateCategory(category *model.Category) (*model.Category, error)
|
||||
return nil, model.ErrCategoryPermissionDenied
|
||||
}
|
||||
|
||||
// in case type was defaulted above, set to existingCategory.Type
|
||||
category.Type = existingCategory.Type
|
||||
if existingCategory.Type == model.CategoryTypeSystem {
|
||||
// You cannot rename or delete a system category,
|
||||
// So restoring its name and undeleting it if set so.
|
||||
|
Loading…
Reference in New Issue
Block a user