Skip to content

Commit

Permalink
DEVPROD-15240: Redirect to new waterfall from legacy waterfall (#8782)
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt authored Mar 8, 2025
1 parent 5a1631e commit 48bd8ed
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions service/waterfall.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func (uis *UIServer) waterfallPage(w http.ResponseWriter, r *http.Request) {

newUILink := ""
if len(uis.Settings.Ui.UIv2Url) > 0 {
newUILink = fmt.Sprintf("%s/commits/%s", uis.Settings.Ui.UIv2Url, project.Identifier)
newUILink = fmt.Sprintf("%s/project/%s/waterfall", uis.Settings.Ui.UIv2Url, project.Identifier)
}

if RedirectSpruceUsers(w, r, newUILink) {
Expand All @@ -635,15 +635,23 @@ func (uis *UIServer) waterfallPage(w http.ResponseWriter, r *http.Request) {
}{newUILink, uis.Settings.Jira.Host, uis.GetCommonViewData(w, r, false, true)}, "base", "waterfall.html", "base_angular.html", "menu.html")
}

// Create and return a redirect to the spruce mainline commits page if the user is opted in to the new UI.
// Create and return a redirect to the Spruce waterfall page if the user is opted in to the new UI.
func (uis *UIServer) mainlineCommitsRedirect(w http.ResponseWriter, r *http.Request) {
projCtx := MustHaveProjectContext(r)
project, err := projCtx.GetProject()

if err != nil || project == nil {
uis.LoggedError(w, r, http.StatusNotFound, errors.New("project not found"))
return
}

u := gimlet.GetUser(r.Context())
if u != nil {
usr, ok := u.(*user.DBUser)
if ok {
// If the user is opted in to the new UI, redirect to the new UI.
if usr.Settings.UseSpruceOptions.SpruceV1 {
http.Redirect(w, r, fmt.Sprintf("%s/commits/", uis.Settings.Ui.UIv2Url), http.StatusSeeOther)
http.Redirect(w, r, fmt.Sprintf("%s/project/%s/waterfall", uis.Settings.Ui.UIv2Url, project.Identifier), http.StatusSeeOther)
}
}
}
Expand Down

0 comments on commit 48bd8ed

Please sign in to comment.