mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-01 18:00:48 +02:00
adjustment
This commit is contained in:
parent
ba326099b3
commit
0cc0615926
@ -854,7 +854,7 @@ func buildCreateCommentMetaData(opts *CreateCommentOptions) (commentMetaData *Co
|
||||
makeCommentMetaData()
|
||||
commentMetaData.SpecialDoerName = opts.SpecialDoerName
|
||||
}
|
||||
if extDoer, ok := opts.Doer.ExtDoerData.(projectWorkflowDoer); ok {
|
||||
if extDoer, ok := opts.Doer.ExtDoerData.(*projectWorkflowDoer); ok {
|
||||
makeCommentMetaData()
|
||||
commentMetaData.SpecialDoerName = SpecialDoerNameProjectWorkflow
|
||||
commentMetaData.ProjectWorkflowID = extDoer.projectWorkflowID
|
||||
|
||||
@ -114,7 +114,7 @@ type WorkflowEventCapabilities struct {
|
||||
}
|
||||
|
||||
// GetWorkflowEventCapabilities returns the capabilities for each workflow event
|
||||
var GetWorkflowEventCapabilities = sync.OnceValue(func () map[WorkflowEvent]WorkflowEventCapabilities {
|
||||
var GetWorkflowEventCapabilities = sync.OnceValue(func() map[WorkflowEvent]WorkflowEventCapabilities {
|
||||
return map[WorkflowEvent]WorkflowEventCapabilities{
|
||||
WorkflowEventItemOpened: {
|
||||
AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels},
|
||||
|
||||
@ -361,9 +361,9 @@ func Workflows(ctx *context.Context) {
|
||||
ctx.Data["ProjectLink"] = project_model.ProjectLinkForRepo(ctx.Repo.Repository, projectID)
|
||||
|
||||
if p.Type == project_model.TypeRepository {
|
||||
ctx.HTML(200, tmplRepoWorkflows)
|
||||
ctx.HTML(http.StatusOK, tmplRepoWorkflows)
|
||||
} else {
|
||||
ctx.HTML(200, tmplOrgWorkflows)
|
||||
ctx.HTML(http.StatusOK, tmplOrgWorkflows)
|
||||
}
|
||||
}
|
||||
|
||||
@ -590,7 +590,5 @@ func WorkflowsDelete(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"success": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
@ -462,6 +462,14 @@ func registerWebRoutes(m *web.Router) {
|
||||
})
|
||||
}
|
||||
|
||||
addProjectWorkflowsRouters := func() {
|
||||
m.Get("", projects.Workflows)
|
||||
m.Get("/{workflow_id}", projects.Workflows)
|
||||
m.Post("/{workflow_id}", projects.WorkflowsPost)
|
||||
m.Post("/{workflow_id}/status", projects.WorkflowsStatus)
|
||||
m.Post("/{workflow_id}/delete", projects.WorkflowsDelete)
|
||||
}
|
||||
|
||||
// FIXME: not all routes need go through same middleware.
|
||||
// Especially some AJAX requests, we can reduce middleware number to improve performance.
|
||||
|
||||
@ -1034,13 +1042,7 @@ func registerWebRoutes(m *web.Router) {
|
||||
m.Get("", org.Projects)
|
||||
m.Get("/{id}", org.ViewProject)
|
||||
}, reqUnitAccess(unit.TypeProjects, perm.AccessModeRead, true))
|
||||
m.Group("/{id}/workflows", func() {
|
||||
m.Get("", projects.Workflows)
|
||||
m.Get("/{workflow_id}", projects.Workflows)
|
||||
m.Post("/{workflow_id}", projects.WorkflowsPost)
|
||||
m.Post("/{workflow_id}/status", projects.WorkflowsStatus)
|
||||
m.Post("/{workflow_id}/delete", projects.WorkflowsDelete)
|
||||
}, reqUnitAccess(unit.TypeProjects, perm.AccessModeWrite, true))
|
||||
m.Group("/{id}/workflows", addProjectWorkflowsRouters, reqUnitAccess(unit.TypeProjects, perm.AccessModeWrite, true))
|
||||
m.Group("", func() {
|
||||
m.Get("/new", org.RenderNewProject)
|
||||
m.Post("/new", web.Bind(forms.CreateProjectForm{}), org.NewProjectPost)
|
||||
@ -1459,13 +1461,7 @@ func registerWebRoutes(m *web.Router) {
|
||||
m.Post("/move", repo.MoveIssues)
|
||||
})
|
||||
|
||||
m.Group("/workflows", func() {
|
||||
m.Get("", projects.Workflows)
|
||||
m.Get("/{workflow_id}", projects.Workflows)
|
||||
m.Post("/{workflow_id}", projects.WorkflowsPost)
|
||||
m.Post("/{workflow_id}/status", projects.WorkflowsStatus)
|
||||
m.Post("/{workflow_id}/delete", projects.WorkflowsDelete)
|
||||
})
|
||||
m.Group("/workflows", addProjectWorkflowsRouters)
|
||||
})
|
||||
}, reqRepoProjectsWriter, context.RepoMustNotBeArchived())
|
||||
}, optSignIn, context.RepoAssignment, reqRepoProjectsReader, repo.MustEnableRepoProjects)
|
||||
|
||||
@ -409,15 +409,10 @@ export function createWorkflowStore(props: any): WorkflowStoreState {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
// Remove workflow from the list
|
||||
const existingIndex = store.workflowEvents.findIndex((e: WorkflowEvent) => e.eventId === selected.eventId);
|
||||
if (existingIndex >= 0) {
|
||||
store.workflowEvents.splice(existingIndex, 1);
|
||||
}
|
||||
} else {
|
||||
showErrorToast(`${props.locale.failedToDeleteWorkflow}: Unexpected error`);
|
||||
// Remove workflow from the list
|
||||
const existingIndex = store.workflowEvents.findIndex((e: WorkflowEvent) => e.eventId === selected.eventId);
|
||||
if (existingIndex >= 0) {
|
||||
store.workflowEvents.splice(existingIndex, 1);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error deleting workflow:', error);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user