From 8dc49dc1149fccda2b4da63fa63d23f2b6260466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Boulanouar?= Date: Fri, 4 Nov 2016 09:06:54 +0100 Subject: [PATCH] Implementation of the feature to redirect to an external issue tracker --- conf/locale/locale_en-US.ini | 2 ++ models/repo.go | 1 + modules/auth/repo_form.go | 1 + routers/repo/issue.go | 7 ++++++- routers/repo/setting.go | 1 + templates/repo/header.tmpl | 4 ++-- templates/repo/settings/options.tmpl | 5 +++++ 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 90f6c60e783..fa1b3874a89 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -648,6 +648,8 @@ settings.external_wiki_url_desc = Visitors will be redirected to URL when they c settings.issues_desc = Enable issue tracker settings.use_internal_issue_tracker = Use builtin lightweight issue tracker settings.use_external_issue_tracker = Use external issue tracker +settings.external_tracker_url = External Issue Tracker URL +settings.external_tracker_url_desc = Visitors will be redirected to URL when they click on the tab. settings.tracker_url_format = External Issue Tracker URL Format settings.tracker_issue_style = External Issue Tracker Naming Style: settings.tracker_issue_style.numeric = Numeric diff --git a/models/repo.go b/models/repo.go index 7c4e475ddad..990670940f0 100644 --- a/models/repo.go +++ b/models/repo.go @@ -186,6 +186,7 @@ type Repository struct { ExternalWikiURL string EnableIssues bool `xorm:"NOT NULL DEFAULT true"` EnableExternalTracker bool + ExternalTrackerURL string ExternalTrackerFormat string ExternalTrackerStyle string ExternalMetas map[string]string `xorm:"-"` diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 589997f1517..238a10852cb 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -96,6 +96,7 @@ type RepoSettingForm struct { ExternalWikiURL string EnableIssues bool EnableExternalTracker bool + ExternalTrackerURL string TrackerURLFormat string TrackerIssueStyle string EnablePulls bool diff --git a/routers/repo/issue.go b/routers/repo/issue.go index f638b6f51f9..8e8328c7e49 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -52,10 +52,15 @@ var ( ) func MustEnableIssues(ctx *context.Context) { - if !ctx.Repo.Repository.EnableIssues || ctx.Repo.Repository.EnableExternalTracker { + if !ctx.Repo.Repository.EnableIssues { ctx.Handle(404, "MustEnableIssues", nil) return } + + if ctx.Repo.Repository.EnableExternalTracker { + ctx.Redirect(ctx.Repo.Repository.ExternalTrackerURL) + return + } } func MustAllowPulls(ctx *context.Context) { diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 4bcc470e99e..869b98897c5 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -146,6 +146,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { repo.ExternalWikiURL = form.ExternalWikiURL repo.EnableIssues = form.EnableIssues repo.EnableExternalTracker = form.EnableExternalTracker + repo.ExternalTrackerURL = form.ExternalTrackerURL repo.ExternalTrackerFormat = form.TrackerURLFormat repo.ExternalTrackerStyle = form.TrackerIssueStyle repo.EnablePulls = form.EnablePulls diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 10bfb80e11e..a0e7bd15428 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -52,9 +52,9 @@ {{.i18n.Tr "repo.code"}} - {{if and .Repository.EnableIssues (not .Repository.EnableExternalTracker)}} + {{if .Repository.EnableIssues}} - {{.i18n.Tr "repo.issues"}} {{.Repository.NumOpenIssues}} + {{.i18n.Tr "repo.issues"}} {{if not .Repository.EnableExternalTracker}}{{.Repository.NumOpenIssues}}{{end}} {{end}} {{if .Repository.AllowsPulls}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 6b61cb7f8e8..2588966c9dc 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -161,6 +161,11 @@
+
+ + +

{{.i18n.Tr "repo.settings.external_tracker_url_desc"}}

+