mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Add icon to templates (#3561)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user