mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-01 00:44:13 +02:00
update
This commit is contained in:
parent
cc11cdaf4e
commit
d2db150558
@ -13,6 +13,8 @@ type Label struct {
|
||||
Name string `json:"name"`
|
||||
// example: false
|
||||
Exclusive bool `json:"exclusive"`
|
||||
// example: 0
|
||||
ExclusiveOrder int `json:"exclusive_order"`
|
||||
// example: false
|
||||
IsArchived bool `json:"is_archived"`
|
||||
// example: 00aabb
|
||||
|
||||
@ -40,22 +40,11 @@ type ProjectWorkflowColumnOption struct {
|
||||
Color string `json:"color"`
|
||||
}
|
||||
|
||||
// ProjectWorkflowLabelOption represents a selectable project label.
|
||||
// swagger:model
|
||||
type ProjectWorkflowLabelOption struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
Description string `json:"description"`
|
||||
Exclusive bool `json:"exclusive"`
|
||||
ExclusiveOrder int `json:"exclusive_order"`
|
||||
}
|
||||
|
||||
// ProjectWorkflowOptions represents the project workflow configuration options.
|
||||
// swagger:model
|
||||
type ProjectWorkflowOptions struct {
|
||||
Columns []*ProjectWorkflowColumnOption `json:"columns"`
|
||||
Labels []*ProjectWorkflowLabelOption `json:"labels"`
|
||||
Labels []*Label `json:"labels"`
|
||||
}
|
||||
|
||||
// ProjectWorkflowFilterOptions represents editable workflow filters.
|
||||
|
||||
@ -334,13 +334,13 @@ func GetProjectWorkflowOptions(ctx *api_context.APIContext) {
|
||||
}
|
||||
options := &api.ProjectWorkflowOptions{
|
||||
Columns: make([]*api.ProjectWorkflowColumnOption, 0, len(columns)),
|
||||
Labels: make([]*api.ProjectWorkflowLabelOption, 0, len(labels)),
|
||||
Labels: make([]*api.Label, 0, len(labels)),
|
||||
}
|
||||
for _, column := range columns {
|
||||
options.Columns = append(options.Columns, &api.ProjectWorkflowColumnOption{ID: column.ID, Title: column.Title, Color: column.Color})
|
||||
}
|
||||
for _, label := range labels {
|
||||
options.Labels = append(options.Labels, &api.ProjectWorkflowLabelOption{
|
||||
options.Labels = append(options.Labels, &api.Label{
|
||||
ID: label.ID,
|
||||
Name: label.Name,
|
||||
Color: label.Color,
|
||||
|
||||
@ -15,6 +15,7 @@ import (
|
||||
project_model "code.gitea.io/gitea/models/project"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/templates"
|
||||
"code.gitea.io/gitea/services/context"
|
||||
project_service "code.gitea.io/gitea/services/projects"
|
||||
@ -241,14 +242,9 @@ func renderWorkflowsOptions(ctx *context.Context, project *project_model.Project
|
||||
return
|
||||
}
|
||||
|
||||
type Column struct {
|
||||
ID int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Color string `json:"color"`
|
||||
}
|
||||
outputColumns := make([]*Column, 0, len(columns))
|
||||
outputColumns := make([]*api.ProjectWorkflowColumnOption, 0, len(columns))
|
||||
for _, col := range columns {
|
||||
outputColumns = append(outputColumns, &Column{
|
||||
outputColumns = append(outputColumns, &api.ProjectWorkflowColumnOption{
|
||||
ID: col.ID,
|
||||
Title: col.Title,
|
||||
Color: col.Color,
|
||||
@ -261,17 +257,9 @@ func renderWorkflowsOptions(ctx *context.Context, project *project_model.Project
|
||||
return
|
||||
}
|
||||
|
||||
type Label struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
Description string `json:"description"`
|
||||
Exclusive bool `json:"exclusive"`
|
||||
ExclusiveOrder int `json:"exclusiveOrder"`
|
||||
}
|
||||
outputLabels := make([]*Label, 0, len(labels))
|
||||
outputLabels := make([]*api.Label, 0, len(labels))
|
||||
for _, label := range labels {
|
||||
outputLabels = append(outputLabels, &Label{
|
||||
outputLabels = append(outputLabels, &api.Label{
|
||||
ID: label.ID,
|
||||
Name: label.Name,
|
||||
Color: label.Color,
|
||||
@ -281,9 +269,9 @@ func renderWorkflowsOptions(ctx *context.Context, project *project_model.Project
|
||||
})
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"columns": outputColumns,
|
||||
"labels": outputLabels,
|
||||
ctx.JSON(http.StatusOK, api.ProjectWorkflowOptions{
|
||||
Columns: outputColumns,
|
||||
Labels: outputLabels,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
41
templates/swagger/v1_json.tmpl
generated
41
templates/swagger/v1_json.tmpl
generated
@ -27558,6 +27558,12 @@
|
||||
"x-go-name": "Exclusive",
|
||||
"example": false
|
||||
},
|
||||
"exclusive_order": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "ExclusiveOrder",
|
||||
"example": 0
|
||||
},
|
||||
"id": {
|
||||
"description": "ID is the unique identifier for the label",
|
||||
"type": "integer",
|
||||
@ -28812,39 +28818,6 @@
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"ProjectWorkflowLabelOption": {
|
||||
"type": "object",
|
||||
"title": "ProjectWorkflowLabelOption represents a selectable project label.",
|
||||
"properties": {
|
||||
"color": {
|
||||
"type": "string",
|
||||
"x-go-name": "Color"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"x-go-name": "Description"
|
||||
},
|
||||
"exclusive": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "Exclusive"
|
||||
},
|
||||
"exclusive_order": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "ExclusiveOrder"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "ID"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"ProjectWorkflowOptions": {
|
||||
"type": "object",
|
||||
"title": "ProjectWorkflowOptions represents the project workflow configuration options.",
|
||||
@ -28859,7 +28832,7 @@
|
||||
"labels": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ProjectWorkflowLabelOption"
|
||||
"$ref": "#/definitions/Label"
|
||||
},
|
||||
"x-go-name": "Labels"
|
||||
}
|
||||
|
||||
@ -7235,6 +7235,12 @@
|
||||
"type": "boolean",
|
||||
"x-go-name": "Exclusive"
|
||||
},
|
||||
"exclusive_order": {
|
||||
"example": 0,
|
||||
"format": "int64",
|
||||
"type": "integer",
|
||||
"x-go-name": "ExclusiveOrder"
|
||||
},
|
||||
"id": {
|
||||
"description": "ID is the unique identifier for the label",
|
||||
"format": "int64",
|
||||
@ -8507,39 +8513,6 @@
|
||||
"type": "object",
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"ProjectWorkflowLabelOption": {
|
||||
"properties": {
|
||||
"color": {
|
||||
"type": "string",
|
||||
"x-go-name": "Color"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"x-go-name": "Description"
|
||||
},
|
||||
"exclusive": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "Exclusive"
|
||||
},
|
||||
"exclusive_order": {
|
||||
"format": "int64",
|
||||
"type": "integer",
|
||||
"x-go-name": "ExclusiveOrder"
|
||||
},
|
||||
"id": {
|
||||
"format": "int64",
|
||||
"type": "integer",
|
||||
"x-go-name": "ID"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
}
|
||||
},
|
||||
"title": "ProjectWorkflowLabelOption represents a selectable project label.",
|
||||
"type": "object",
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"ProjectWorkflowOptions": {
|
||||
"properties": {
|
||||
"columns": {
|
||||
@ -8551,7 +8524,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ProjectWorkflowLabelOption"
|
||||
"$ref": "#/components/schemas/Label"
|
||||
},
|
||||
"type": "array",
|
||||
"x-go-name": "Labels"
|
||||
|
||||
@ -49,7 +49,7 @@ func TestAPIRepoProjectWorkflows(t *testing.T) {
|
||||
var options api.ProjectWorkflowOptions
|
||||
require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &options))
|
||||
assert.Contains(t, options.Columns, &api.ProjectWorkflowColumnOption{ID: column.ID, Title: column.Title, Color: column.Color})
|
||||
assert.Contains(t, options.Labels, &api.ProjectWorkflowLabelOption{ID: label.ID, Name: label.Name, Color: label.Color, Description: label.Description, Exclusive: label.Exclusive, ExclusiveOrder: label.ExclusiveOrder})
|
||||
assert.Contains(t, options.Labels, &api.Label{ID: label.ID, Name: label.Name, Color: label.Color, Description: label.Description, Exclusive: label.Exclusive, ExclusiveOrder: label.ExclusiveOrder})
|
||||
})
|
||||
|
||||
var workflow api.ProjectWorkflow
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user