Skip to content

Commit 875e512

Browse files
committed
added configuration to enable/disable the milestones dashboard endpoint (defaults to enabled)
1 parent 8e731a4 commit 875e512

File tree

7 files changed

+21
-6
lines changed

7 files changed

+21
-6
lines changed

custom/conf/app.ini.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME = true
507507
NO_REPLY_ADDRESS = noreply.example.org
508508
; Show Registration button
509509
SHOW_REGISTRATION_BUTTON = true
510+
; Show milestones dashboard page - a view of all the user's milestones
511+
SHOW_MILESTONES_DASHBOARD_PAGE = true
510512
; Default value for AutoWatchNewRepos
511513
; When adding a repo to a team or creating a new repo all team members will watch the
512514
; repo automatically if enabled

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ relation to port exhaustion.
307307
- `EMAIL_DOMAIN_WHITELIST`: **\<empty\>**: If non-empty, list of domain names that can only be used to register
308308
on this instance.
309309
- `SHOW_REGISTRATION_BUTTON`: **! DISABLE\_REGISTRATION**: Show Registration Button
310+
- `SHOW_MILESTONES_DASHBOARD_PAGE`: **true** Enable this to show the milestones dashboard page - a view of all the user's milestones
310311
- `AUTO_WATCH_NEW_REPOS`: **true**: Enable this to let all organisation users watch new repos when they are created
311312
- `AUTO_WATCH_ON_CHANGES`: **false**: Enable this to make users watch a repository after their first commit to it
312313
- `DEFAULT_ORG_VISIBILITY`: **public**: Set default visibility mode for organisations, either "public", "limited" or "private".

modules/context/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ func Contexter() macaron.Handler {
334334
ctx.Data["IsLandingPageOrganizations"] = setting.LandingPageURL == setting.LandingPageOrganizations
335335

336336
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
337+
ctx.Data["ShowMilestonesDashboardPage"] = setting.Service.ShowMilestonesDashboardPage
337338
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
338339
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
339340

modules/setting/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var Service struct {
2121
DisableRegistration bool
2222
AllowOnlyExternalRegistration bool
2323
ShowRegistrationButton bool
24+
ShowMilestonesDashboardPage bool
2425
RequireSignInView bool
2526
EnableNotifyMail bool
2627
EnableBasicAuth bool
@@ -62,6 +63,7 @@ func newService() {
6263
Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
6364
Service.EmailDomainWhitelist = sec.Key("EMAIL_DOMAIN_WHITELIST").Strings(",")
6465
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
66+
Service.ShowMilestonesDashboardPage = sec.Key("SHOW_MILESTONES_DASHBOARD_PAGE").MustBool(true)
6567
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
6668
Service.EnableBasicAuth = sec.Key("ENABLE_BASIC_AUTHENTICATION").MustBool(true)
6769
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()

routers/routes/routes.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ func RegisterRoutes(m *macaron.Macaron) {
254254
}
255255
}
256256

257+
reqMilestonesDashboardPageEnabled := func(ctx *context.Context) {
258+
if !setting.Service.ShowMilestonesDashboardPage {
259+
ctx.Error(403)
260+
return
261+
}
262+
}
263+
257264
m.Use(user.GetNotificationCount)
258265

259266
// FIXME: not all routes need go through same middlewares.
@@ -276,7 +283,7 @@ func RegisterRoutes(m *macaron.Macaron) {
276283
m.Combo("/install", routers.InstallInit).Get(routers.Install).
277284
Post(bindIgnErr(auth.InstallForm{}), routers.InstallPost)
278285
m.Get("/^:type(issues|pulls)$", reqSignIn, user.Issues)
279-
m.Get("/milestones", reqSignIn, user.Milestones)
286+
m.Get("/milestones", reqSignIn, reqMilestonesDashboardPageEnabled, user.Milestones)
280287

281288
// ***** START: User *****
282289
m.Group("/user", func() {
@@ -557,7 +564,7 @@ func RegisterRoutes(m *macaron.Macaron) {
557564
m.Group("/:org", func() {
558565
m.Get("/dashboard", user.Dashboard)
559566
m.Get("/^:type(issues|pulls)$", user.Issues)
560-
m.Get("/milestones", user.Milestones)
567+
m.Get("/milestones", reqMilestonesDashboardPageEnabled, user.Milestones)
561568
m.Get("/members", org.Members)
562569
m.Get("/members/action/:action", org.MembersAction)
563570

templates/base/head_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<a class="item {{if .PageIsDashboard}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "dashboard"}}</a>
1313
<a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a>
1414
<a class="item {{if .PageIsPulls}}active{{end}}" href="{{AppSubUrl}}/pulls">{{.i18n.Tr "pull_requests"}}</a>
15-
<a class="item {{if .PageIsMilestonesDashboard}}active{{end}}" href="{{AppSubUrl}}/milestones">{{.i18n.Tr "milestones"}}</a>
15+
{{if .ShowMilestonesDashboardPage}}<a class="item {{if .PageIsMilestonesDashboard}}active{{end}}" href="{{AppSubUrl}}/milestones">{{.i18n.Tr "milestones"}}</a>{{end}}
1616
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "explore"}}</a>
1717
{{else if .IsLandingPageHome}}
1818
<a class="item {{if .PageIsHome}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "home"}}</a>

templates/user/dashboard/navbar.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
<a class="{{if .PageIsPulls}}active{{end}} item" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/pulls">
4444
<i class="octicon octicon-git-pull-request"></i>&nbsp;{{.i18n.Tr "pull_requests"}}
4545
</a>
46-
<a class="{{if .PageIsMilestonesDashboard}}active{{end}} item" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/milestones">
47-
<i class="octicon octicon-milestone"></i>&nbsp;{{.i18n.Tr "milestones"}}
48-
</a>
46+
{{if .ShowMilestonesDashboardPage}}
47+
<a class="{{if .PageIsMilestonesDashboard}}active{{end}} item" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/milestones">
48+
<i class="octicon octicon-milestone"></i>&nbsp;{{.i18n.Tr "milestones"}}
49+
</a>
50+
{{end}}
4951
<div class="item">
5052
<a class="ui blue basic button" href="{{.ContextUser.HomeLink}}" title='{{.i18n.Tr "home.view_home" .ContextUser.Name}}'>
5153
{{.i18n.Tr "home.view_home" (.ContextUser.ShortName 10)}}

0 commit comments

Comments
 (0)