Add review workflows, tree-shaped workflows and a workflow editor
This commit is contained in:
@@ -5,7 +5,9 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"g.fc.run/ai/byre/internal/api"
|
||||
"g.fc.run/ai/byre/internal/workflow"
|
||||
)
|
||||
|
||||
@@ -21,6 +23,16 @@ func (s *Server) ListWorkflows(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (s *Server) GetWorkflow(w http.ResponseWriter, r *http.Request, name string) {
|
||||
accept := r.Header.Get("Accept")
|
||||
if strings.Contains(accept, "application/json") && !strings.Contains(accept, "yaml") {
|
||||
def, err := s.store.GetWorkflow(r.Context(), name)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, def)
|
||||
return
|
||||
}
|
||||
file, err := s.agents.WorkflowFile(r.Context(), name)
|
||||
if err != nil {
|
||||
writeAgentError(w, err)
|
||||
@@ -46,6 +58,19 @@ func (s *Server) PutWorkflow(w http.ResponseWriter, r *http.Request, name string
|
||||
writeJSON(w, http.StatusOK, summary)
|
||||
}
|
||||
|
||||
func (s *Server) SetReviewWorkflow(w http.ResponseWriter, r *http.Request, projectID string) {
|
||||
req := api.ReviewWorkflow{}
|
||||
if !readJSON(w, r, &req) {
|
||||
return
|
||||
}
|
||||
p, err := s.agents.SetReviewWorkflow(r.Context(), projectID, req.Workflow, actor(r))
|
||||
if err != nil {
|
||||
writeAgentError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, p)
|
||||
}
|
||||
|
||||
func (s *Server) DeleteWorkflow(w http.ResponseWriter, r *http.Request, name string) {
|
||||
err := s.store.DeleteWorkflow(r.Context(), name, actor(r))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user