@@ -16,6 +16,7 @@ import ( |
| 16 | 16 | |
| 17 | 17 | "github.com/tenseleyFlow/shithub/internal/actions/dispatch" |
| 18 | 18 | actionsevent "github.com/tenseleyFlow/shithub/internal/actions/event" |
| 19 | + actionsdb "github.com/tenseleyFlow/shithub/internal/actions/sqlc" |
| 19 | 20 | "github.com/tenseleyFlow/shithub/internal/actions/trigger" |
| 20 | 21 | "github.com/tenseleyFlow/shithub/internal/actions/workflow" |
| 21 | 22 | "github.com/tenseleyFlow/shithub/internal/auth/pat" |
@@ -105,9 +106,23 @@ func (h *Handlers) actionsWorkflowsList(w http.ResponseWriter, r *http.Request) |
| 105 | 106 | writeAPIError(w, http.StatusInternalServerError, "list failed") |
| 106 | 107 | return |
| 107 | 108 | } |
| 109 | + disabled, err := actionsdb.New().ListDisabledWorkflowsForRepo(r.Context(), h.d.Pool, repo.ID) |
| 110 | + if err != nil { |
| 111 | + h.d.Logger.ErrorContext(r.Context(), "api: list disabled workflows", "error", err) |
| 112 | + writeAPIError(w, http.StatusInternalServerError, "list failed") |
| 113 | + return |
| 114 | + } |
| 115 | + disabledSet := make(map[string]struct{}, len(disabled)) |
| 116 | + for _, f := range disabled { |
| 117 | + disabledSet[f] = struct{}{} |
| 118 | + } |
| 108 | 119 | out := make([]workflowResponse, 0, len(files)) |
| 109 | 120 | for _, f := range files { |
| 110 | | - out = append(out, presentWorkflow(f)) |
| 121 | + wr := presentWorkflow(f) |
| 122 | + if _, off := disabledSet[f.Path]; off { |
| 123 | + wr.State = "disabled" |
| 124 | + } |
| 125 | + out = append(out, wr) |
| 111 | 126 | } |
| 112 | 127 | sort.Slice(out, func(i, j int) bool { return out[i].Path < out[j].Path }) |
| 113 | 128 | writeJSON(w, http.StatusOK, out) |