1
0
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:
Scott Bishel 2022-11-08 09:40:30 -07:00 committed by GitHub
parent e83b05b661
commit cf97e300c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.