feat: Add icon to templates (#3561)

This commit is contained in:
Bruno Quaresma
2022-08-19 13:17:35 +00:00
committed by GitHub
parent 57f3410009
commit 80f042f01b
17 changed files with 66 additions and 12 deletions
+7
View File
@@ -411,6 +411,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
if req.Name == template.Name &&
req.Description == template.Description &&
req.Icon == template.Icon &&
req.MaxTTLMillis == time.Duration(template.MaxTtl).Milliseconds() &&
req.MinAutostartIntervalMillis == time.Duration(template.MinAutostartInterval).Milliseconds() {
return nil
@@ -419,6 +420,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
// Update template metadata -- empty fields are not overwritten.
name := req.Name
desc := req.Description
icon := req.Icon
maxTTL := time.Duration(req.MaxTTLMillis) * time.Millisecond
minAutostartInterval := time.Duration(req.MinAutostartIntervalMillis) * time.Millisecond
@@ -428,6 +430,9 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
if desc == "" {
desc = template.Description
}
if icon == "" {
name = template.Icon
}
if maxTTL == 0 {
maxTTL = time.Duration(template.MaxTtl)
}
@@ -440,6 +445,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
UpdatedAt: database.Now(),
Name: name,
Description: desc,
Icon: icon,
MaxTtl: int64(maxTTL),
MinAutostartInterval: int64(minAutostartInterval),
}); err != nil {
@@ -519,6 +525,7 @@ func convertTemplate(template database.Template, workspaceOwnerCount uint32, cre
ActiveVersionID: template.ActiveVersionID,
WorkspaceOwnerCount: workspaceOwnerCount,
Description: template.Description,
Icon: template.Icon,
MaxTTLMillis: time.Duration(template.MaxTtl).Milliseconds(),
MinAutostartIntervalMillis: time.Duration(template.MinAutostartInterval).Milliseconds(),
CreatedByID: template.CreatedBy,