Skip to content

Commit

Permalink
removed required [storage] from config to hide it from ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehor Datsenko committed Sep 28, 2023
1 parent 0d06080 commit b02943a
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,15 @@ func (a *App) convertUpdateConfigMessageToModel(in *proto.UpdateConfigRequest, d
Description: *model.NewNullString(in.GetDescription()),
}
a.calculateNextPeriod(config)
storageId, err := model.NewNullInt(in.GetStorage().GetId())
if err != nil {
return nil, errors.NewInternalError("app.config.convert_update_config_message.convert_storage_id.fail", err.Error())

if v := in.GetStorage().GetId(); v != 0 {
storageId, err := model.NewNullInt(in.GetStorage().GetId())
if err != nil {
return nil, errors.NewInternalError("app.config.convert_update_config_message.convert_storage_id.fail", err.Error())
}
config.Storage.Id = storageId
}
config.Storage.Id = storageId

return config, nil
}

Expand All @@ -323,15 +327,23 @@ func (a *App) convertPatchConfigMessageToModel(in *proto.PatchConfigRequest, dom
Description: *model.NewNullString(in.GetDescription()),
}
a.calculateNextPeriod(config)
storageId, err := model.NewNullInt(in.GetStorage().GetId())
if err != nil {
return nil, errors.NewInternalError("app.config.convert_patch_config_message.convert_storage_id.fail", err.Error())

if v := in.GetStorage().GetId(); v != 0 {
storageId, err := model.NewNullInt(in.GetStorage().GetId())
if err != nil {
return nil, errors.NewInternalError("app.config.convert_patch_config_message.convert_storage_id.fail", err.Error())
}
config.Storage.Id = storageId
}
config.Storage.Id = storageId

return config, nil
}

func (a *App) convertCreateConfigMessageToModel(in *proto.CreateConfigRequest, domainId int) (*model.Config, errors.AppError) {

if in.GetDaysToStore() <= 0 {
return nil, errors.NewBadRequestError("app.config.convert_create_config_message.bad_args", "days to store should be greater than one")
}
config := &model.Config{

Enabled: in.GetEnabled(),
Expand All @@ -348,15 +360,19 @@ func (a *App) convertCreateConfigMessageToModel(in *proto.CreateConfigRequest, d
}
config.Object.Id = objectId

storageId, err := model.NewNullInt(in.GetStorage().GetId())
if err != nil {
return nil, errors.NewInternalError("app.config.convert_create_config_message.convert_storage_id.fail", err.Error())
if v := in.GetStorage().GetId(); v != 0 {
storageId, err := model.NewNullInt(in.GetStorage().GetId())
if err != nil {
return nil, errors.NewInternalError("app.config.convert_create_config_message.convert_storage_id.fail", err.Error())
}
config.Storage.Id = storageId
}
config.Storage.Id = storageId

return config, nil
}

func (a *App) convertConfigModelToMessage(in *model.Config) (*proto.Config, errors.AppError) {

conf := &proto.Config{
Id: int32(in.Id),
Enabled: in.Enabled,
Expand Down

0 comments on commit b02943a

Please sign in to comment.