Add API for Label templates (#24602)
This adds API that allows getting the Label templates of the Gitea Instance
This commit is contained in:
parent
abcf5a7b5e
commit
25dc1556cd
7 changed files with 258 additions and 0 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/label"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
@ -238,3 +239,24 @@ func ToAPIMilestone(m *issues_model.Milestone) *api.Milestone {
|
|||
}
|
||||
return apiMilestone
|
||||
}
|
||||
|
||||
// ToLabelTemplate converts Label to API format
|
||||
func ToLabelTemplate(label *label.Label) *api.LabelTemplate {
|
||||
result := &api.LabelTemplate{
|
||||
Name: label.Name,
|
||||
Exclusive: label.Exclusive,
|
||||
Color: strings.TrimLeft(label.Color, "#"),
|
||||
Description: label.Description,
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// ToLabelTemplateList converts list of Label to API format
|
||||
func ToLabelTemplateList(labels []*label.Label) []*api.LabelTemplate {
|
||||
result := make([]*api.LabelTemplate, len(labels))
|
||||
for i := range labels {
|
||||
result[i] = ToLabelTemplate(labels[i])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue