mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Add template display name (backend) (#4966)
* Rename to nameValidator * Refactor: NameValid * Fix: comment * Define new migration * Include display_name * Update typesGenerated.ts * Update meta * Adjust tests * CLI tests * Fix: audit * Fix: omitempty * site: display_name is optional * unit: TestUsernameValid * entities.ts: add display_name * site: TemplateSettingsPage.test.tsx * Fix: TemplateSettingsForm.tsx * Adjust tests * Add comment to display_name column * Fix: rename * Fix: make * Loosen regexp * Fix: err check * Fix: template name length * Allow for whitespaces * Update migration number
This commit is contained in:
@@ -472,6 +472,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if req.Name == template.Name &&
|
||||
req.Description == template.Description &&
|
||||
req.DisplayName == template.DisplayName &&
|
||||
req.Icon == template.Icon &&
|
||||
req.DefaultTTLMillis == time.Duration(template.DefaultTtl).Milliseconds() {
|
||||
return nil
|
||||
@@ -479,6 +480,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Update template metadata -- empty fields are not overwritten.
|
||||
name := req.Name
|
||||
displayName := req.DisplayName
|
||||
desc := req.Description
|
||||
icon := req.Icon
|
||||
maxTTL := time.Duration(req.DefaultTTLMillis) * time.Millisecond
|
||||
@@ -486,6 +488,9 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
|
||||
if name == "" {
|
||||
name = template.Name
|
||||
}
|
||||
if displayName == "" {
|
||||
displayName = template.DisplayName
|
||||
}
|
||||
if desc == "" {
|
||||
desc = template.Description
|
||||
}
|
||||
@@ -494,6 +499,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
|
||||
ID: template.ID,
|
||||
UpdatedAt: database.Now(),
|
||||
Name: name,
|
||||
DisplayName: displayName,
|
||||
Description: desc,
|
||||
Icon: icon,
|
||||
DefaultTtl: int64(maxTTL),
|
||||
@@ -738,6 +744,7 @@ func (api *API) convertTemplate(
|
||||
UpdatedAt: template.UpdatedAt,
|
||||
OrganizationID: template.OrganizationID,
|
||||
Name: template.Name,
|
||||
DisplayName: template.DisplayName,
|
||||
Provisioner: codersdk.ProvisionerType(template.Provisioner),
|
||||
ActiveVersionID: template.ActiveVersionID,
|
||||
WorkspaceOwnerCount: workspaceOwnerCount,
|
||||
|
||||
Reference in New Issue
Block a user