Skip to content

Commit

Permalink
add disabled filed in sprint workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zhao <[email protected]>
  • Loading branch information
PetrusZ committed Oct 31, 2024
1 parent 462f9a1 commit 0a92576
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type SprintWorkflow struct {
Name string `bson:"name" yaml:"name" json:"name"`
DisplayName string `bson:"display_name" yaml:"display_name" json:"display_name"`
IsDeleted bool `bson:"is_deleted" yaml:"is_deleted" json:"is_deleted"`
Disabled bool `bson:"disabled" yaml:"disabled" json:"disabled"`
}

func (SprintTemplate) TableName() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ func updateSprintWorklow(ctx *handler.Context, sprint *commonmodels.Sprint) erro
workflowMap[workflow.Name].DisplayName = workflow.DisplayName
changed = true
}
if workflowMap[workflow.Name].Disabled != workflow.Disabled {
workflowMap[workflow.Name].Disabled = workflow.Disabled
changed = true
}
delete(workflowMap, workflow.Name)
}
if len(workflowMap) > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func genSprintTemplate(ctx *handler.Context, sprintTemplate *commonmodels.Sprint
workflowMap[workflow.Name].DisplayName = workflow.DisplayName
changed = true
}
if workflowMap[workflow.Name].Disabled != workflow.Disabled {
workflowMap[workflow.Name].Disabled = workflow.Disabled
changed = true
}
delete(workflowMap, workflow.Name)
}
if len(workflowMap) > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,17 @@ func createSprintWorkItemActivity(ctx *handler.Context, session mongo.Session, s
}

func ExecSprintWorkItemWorkflow(ctx *handler.Context, id string, workitemIDs []string, workflowName string, workflowArgs *commonmodels.WorkflowV4) error {
workflow, err := mongodb.NewWorkflowV4Coll().Find(workflowName)
if err != nil {
return e.ErrExecSprintWorkItemTask.AddErr(errors.Wrapf(err, "Find workflow by name %s", workflowName))
}
if workflow == nil {
return e.ErrExecSprintWorkItemTask.AddErr(errors.New("Workflow not found"))
}
if workflow.Disabled {
return e.ErrExecSprintWorkItemTask.AddErr(errors.New("Workflow is disabled"))
}

idSet := sets.NewString(workitemIDs...)
idSet.Insert(id)
opt := mongodb.ListSprintWorkItemOption{
Expand Down

0 comments on commit 0a92576

Please sign in to comment.