feat(issues): make status_id, priority_id, type_id required on create (#598) #613
@@ -114,10 +114,10 @@ type CreateIssueOption struct {
|
||||
Closed bool `json:"closed"`
|
||||
// custom field values keyed by field name
|
||||
CustomFields map[string]string `json:"custom_fields,omitempty"`
|
||||
// org-level issue metadata IDs
|
||||
StatusID *int64 `json:"status_id,omitempty"`
|
||||
PriorityID *int64 `json:"priority_id,omitempty"`
|
||||
TypeID *int64 `json:"type_id,omitempty"`
|
||||
// org-level issue metadata IDs (auto-assigned from org defaults when 0)
|
||||
StatusID int64 `json:"status_id"`
|
||||
PriorityID int64 `json:"priority_id"`
|
||||
TypeID int64 `json:"type_id"`
|
||||
}
|
||||
|
||||
// EditIssueOption options for editing an issue
|
||||
|
||||
@@ -757,11 +757,10 @@ func CreateIssue(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
// Set org-level issue metadata (status/priority/type).
|
||||
// If not provided, auto-assign the org default.
|
||||
if form.StatusID != nil && *form.StatusID > 0 {
|
||||
_ = issues_model.SetIssueStatusID(ctx, issue.ID, *form.StatusID)
|
||||
// Use provided value if > 0, otherwise auto-assign org default.
|
||||
if form.StatusID > 0 {
|
||||
_ = issues_model.SetIssueStatusID(ctx, issue.ID, form.StatusID)
|
||||
} else {
|
||||
// Auto-assign first non-closing status.
|
||||
if defs, err := issues_model.GetIssueStatusDefsByOrg(ctx, ctx.Repo.Repository.OwnerID); err == nil {
|
||||
for _, d := range defs {
|
||||
if !d.ClosesIssue {
|
||||
@@ -771,8 +770,8 @@ func CreateIssue(ctx *context.APIContext) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if form.PriorityID != nil && *form.PriorityID > 0 {
|
||||
_ = issues_model.SetIssuePriorityID(ctx, issue.ID, *form.PriorityID)
|
||||
if form.PriorityID > 0 {
|
||||
_ = issues_model.SetIssuePriorityID(ctx, issue.ID, form.PriorityID)
|
||||
} else {
|
||||
if defs, err := issues_model.GetIssuePriorityDefsByOrg(ctx, ctx.Repo.Repository.OwnerID); err == nil {
|
||||
for _, d := range defs {
|
||||
@@ -783,8 +782,8 @@ func CreateIssue(ctx *context.APIContext) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if form.TypeID != nil && *form.TypeID > 0 {
|
||||
_ = issues_model.SetIssueTypeID(ctx, issue.ID, *form.TypeID)
|
||||
if form.TypeID > 0 {
|
||||
_ = issues_model.SetIssueTypeID(ctx, issue.ID, form.TypeID)
|
||||
} else {
|
||||
if defs, err := issues_model.GetIssueTypeDefsByOrg(ctx, ctx.Repo.Repository.OwnerID); err == nil {
|
||||
for _, d := range defs {
|
||||
|
||||
Reference in New Issue
Block a user