feat: dialog to change template metadata in editor

This commit is contained in:
2024-12-03 18:34:23 +00:00
parent 4e34570792
commit e5bbd15837
10 changed files with 369 additions and 72 deletions

View File

@@ -19,6 +19,7 @@ type createTemplateRequestBody struct {
}
type postTemplateRequestBody struct {
Name *string `json:"name"`
Description *string `json:"description"`
Files []templateFile `json:"files"`
@@ -114,13 +115,22 @@ func updateTemplate(c echo.Context, body postTemplateRequestBody) error {
mgr := templateManagerFrom(c)
ctx := c.Request().Context()
updatedTemplate, err := mgr.updateTemplate(ctx, name, updateTemplateOptions{
description: *body.Description,
})
var opts updateTemplateOptions
if body.Name != nil {
opts.name = *body.Name
}
if body.Description != nil {
opts.description = *body.Description
}
updatedTemplate, err := mgr.updateTemplate(ctx, name, opts)
if err != nil {
if errors.Is(err, errTemplateNotFound) {
return echo.NewHTTPError(http.StatusNotFound)
}
if errors.Is(err, errTemplateExists) {
return echo.NewHTTPError(http.StatusConflict)
}
return err
}