Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: milo/appengine/frontend/frontpage.go

Issue 2748073006: Milo Refactor: Remove theme support (Closed)
Patch Set: Fix builder.html pointer Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package frontend 5 package frontend
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 9
10 » "github.com/julienschmidt/httprouter" 10 » "github.com/luci/luci-go/server/router"
11 "github.com/luci/luci-go/server/templates" 11 "github.com/luci/luci-go/server/templates"
12 "golang.org/x/net/context"
13 12
14 log "github.com/luci/luci-go/common/logging"
15 "github.com/luci/luci-go/common/sync/parallel" 13 "github.com/luci/luci-go/common/sync/parallel"
16 "github.com/luci/luci-go/milo/api/resp" 14 "github.com/luci/luci-go/milo/api/resp"
17 "github.com/luci/luci-go/milo/appengine/buildbot" 15 "github.com/luci/luci-go/milo/appengine/buildbot"
18 "github.com/luci/luci-go/milo/appengine/buildbucket" 16 "github.com/luci/luci-go/milo/appengine/buildbucket"
19 » "github.com/luci/luci-go/milo/appengine/settings" 17 » "github.com/luci/luci-go/milo/appengine/common"
20 ) 18 )
21 19
22 type frontpage struct{} 20 func frontpageHandler(c *router.Context) {
23
24 func (f frontpage) GetTemplateName(t settings.Theme) string {
25 » return "frontpage.html"
26 }
27
28 func (f frontpage) Render(c context.Context, r *http.Request, p httprouter.Param s) (*templates.Args, error) {
29 fp := resp.FrontPage{} 21 fp := resp.FrontPage{}
30 var mBuildbot, mBuildbucket *resp.CIService 22 var mBuildbot, mBuildbucket *resp.CIService
31 23
32 err := parallel.FanOutIn(func(ch chan<- func() error) { 24 err := parallel.FanOutIn(func(ch chan<- func() error) {
33 ch <- func() (err error) { 25 ch <- func() (err error) {
34 » » » mBuildbot, err = buildbot.GetAllBuilders(c) 26 » » » mBuildbot, err = buildbot.GetAllBuilders(c.Context)
35 return err 27 return err
36 } 28 }
37 ch <- func() (err error) { 29 ch <- func() (err error) {
38 » » » mBuildbucket, err = buildbucket.GetAllBuilders(c) 30 » » » mBuildbucket, err = buildbucket.GetAllBuilders(c.Context )
39 return err 31 return err
40 } 32 }
41 }) 33 })
42 if err != nil { 34 if err != nil {
43 » » log.WithError(err).Errorf(c, "Encountered error while loading mo dules") 35 » » common.ErrorPage(c, http.StatusInternalServerError, err.Error())
44 » » return nil, err 36 » » return
45 } 37 }
46 38
47 fp.CIServices = append(fp.CIServices, *mBuildbucket) 39 fp.CIServices = append(fp.CIServices, *mBuildbucket)
48 fp.CIServices = append(fp.CIServices, *mBuildbot) 40 fp.CIServices = append(fp.CIServices, *mBuildbot)
49 » return &templates.Args{"frontpage": fp}, nil 41 » templates.MustRender(c.Context, c.Writer, "pages/frontpage.html", templa tes.Args{
42 » » "frontpage": fp,
43 » })
50 } 44 }
51 45
52 type testableFrontpage struct{ frontpage } 46 func frontpageTestData() []common.TestBundle {
53
54 func (l testableFrontpage) TestData() []settings.TestBundle {
55 data := &templates.Args{ 47 data := &templates.Args{
56 "frontpage": resp.FrontPage{ 48 "frontpage": resp.FrontPage{
57 CIServices: []resp.CIService{ 49 CIServices: []resp.CIService{
58 { 50 {
59 Name: "Module 1", 51 Name: "Module 1",
60 BuilderGroups: []resp.BuilderGroup{ 52 BuilderGroups: []resp.BuilderGroup{
61 { 53 {
62 Name: "Example master A" , 54 Name: "Example master A" ,
63 Builders: []resp.Link{ 55 Builders: []resp.Link{
64 { 56 {
65 Label: " Example builder", 57 Label: " Example builder",
66 URL: " /master1/buildera", 58 URL: " /master1/buildera",
67 }, 59 },
68 { 60 {
69 Label: " Example builder 2", 61 Label: " Example builder 2",
70 URL: " /master1/builderb", 62 URL: " /master1/builderb",
71 }, 63 },
72 }, 64 },
73 }, 65 },
74 }, 66 },
75 }, 67 },
76 }, 68 },
77 }, 69 },
78 } 70 }
79 » return []settings.TestBundle{ 71 » return []common.TestBundle{
80 { 72 {
81 Description: "Basic frontpage", 73 Description: "Basic frontpage",
82 Data: *data, 74 Data: *data,
83 }, 75 },
84 } 76 }
85 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698