| @@ -82,6 +82,10 @@ func (s *Server) settingsRedirect(w http.ResponseWriter, r *http.Request, msg st |
| 82 | 82 | // settingsSubmit routes one form to its command. Keeping the mapping in |
| 83 | 83 | // one place makes what the page can reach obvious. |
| 84 | 84 | func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store.User) { |
| 85 | row, ok := s.repoForUser(w, r, u, policyCanAdmin) |
| 86 | if !ok { |
| 87 | return |
| 88 | } |
| 85 | 89 | repo := r.PathValue("owner") + "/" + r.PathValue("repo") |
| 86 | 90 | v := func(k string) string { return strings.TrimSpace(r.FormValue(k)) } |
| 87 | 91 | field := r.FormValue("field") |
| @@ -131,11 +135,6 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store. |
| 131 | 135 | } |
| 132 | 136 | argv = []string{"repo", verb, repo} |
| 133 | 137 | case "topics": |
| 134 | | row, err := s.st.RepoByPath(repo) |
| 135 | | if err != nil { |
| 136 | | http.NotFound(w, r) |
| 137 | | return |
| 138 | | } |
| 139 | 138 | want := map[string]bool{} |
| 140 | 139 | var order []string |
| 141 | 140 | for _, t := range strings.Split(v("topics"), ",") { |
| @@ -160,11 +159,13 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store. |
| 160 | 159 | remove = append(remove, t) |
| 161 | 160 | } |
| 162 | 161 | } |
| 162 | removed := false |
| 163 | 163 | if len(remove) > 0 { |
| 164 | 164 | if _, msg, ok := s.runControl(u, append([]string{"repo", "topics", "remove", repo}, remove...)); !ok { |
| 165 | 165 | s.settingsFormWith(w, r, u, msg, r.Form) |
| 166 | 166 | return |
| 167 | 167 | } |
| 168 | removed = true |
| 168 | 169 | } |
| 169 | 170 | if len(add) > 0 { |
| 170 | 171 | argv = append([]string{"repo", "topics", "add", repo}, add...) |
| @@ -172,6 +173,14 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store. |
| 172 | 173 | s.settingsRedirect(w, r, "Saved the topics.") |
| 173 | 174 | return |
| 174 | 175 | } |
| 176 | if removed { |
| 177 | if _, msg, ok := s.runControl(u, argv); !ok { |
| 178 | s.settingsFormWith(w, r, u, "Removed "+strings.Join(remove, ", ")+"; "+msg, r.Form) |
| 179 | return |
| 180 | } |
| 181 | s.settingsRedirect(w, r, "Saved the "+fieldLabel(field)+".") |
| 182 | return |
| 183 | } |
| 175 | 184 | case "runner-add": |
| 176 | 185 | body := v("key") |
| 177 | 186 | if body == "" { |
| @@ -223,7 +232,7 @@ func fieldLabel(field string) string { |
| 223 | 232 | case "require-codeowners": |
| 224 | 233 | return "CODEOWNERS" |
| 225 | 234 | case "require-mr": |
| 226 | | return "require-MR" |
| 235 | return "merge request requirement" |
| 227 | 236 | case "require-signed": |
| 228 | 237 | return "signed commits" |
| 229 | 238 | case "protect", "unprotect": |
| @@ -233,7 +242,7 @@ func fieldLabel(field string) string { |
| 233 | 242 | case "deps": |
| 234 | 243 | return "dependency scanning" |
| 235 | 244 | case "archive": |
| 236 | | return "archive" |
| 245 | return "archived state" |
| 237 | 246 | case "topics": |
| 238 | 247 | return "topics" |
| 239 | 248 | case "runner-add", "runner-remove": |