Преглед на файлове

Allow admin users to set a repositoires visibility to public, even if FORCE_PRIVATE is to true (#6541) (#6572)

Signed-off-by: Matthias Beckert <beckert.matthias@googlemail.com>
tags/v1.9.0-rc1
Matthias Beckert преди 5 години
родител
ревизия
5348573fdf
променени са 2 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 2
    2
      routers/repo/setting.go
  2. 4
    0
      templates/repo/settings/options.tmpl

+ 2
- 2
routers/repo/setting.go Целия файл

@@ -95,8 +95,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
}

visibilityChanged := repo.IsPrivate != form.Private
// when ForcePrivate enabled, you could change public repo to private, but could not change private to public
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private {
// when ForcePrivate enabled, you could change public repo to private, but only admin users can change private to public
if visibilityChanged && setting.Repository.ForcePrivate && !form.Private && !ctx.User.IsAdmin {
ctx.ServerError("Force Private enabled", errors.New("cannot change private repository to public"))
return
}

+ 4
- 0
templates/repo/settings/options.tmpl Целия файл

@@ -19,7 +19,11 @@
<div class="inline field">
<label>{{.i18n.Tr "repo.visibility"}}</label>
<div class="ui checkbox">
{{if .IsAdmin}}
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}>
{{else}}
<input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}{{if and $.ForcePrivate .Repository.IsPrivate}} readonly{{end}}>
{{end}}
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visibility_fork_helper"}}</span>{{end}}</label>
</div>
</div>

Loading…
Отказ
Запис