diff options
author | 6543 <6543@obermui.de> | 2021-06-27 20:47:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-27 19:47:35 +0100 |
commit | 0b27b93728fd3cf2ecc82ac6a2b5859270543ef2 (patch) | |
tree | adbbc5eaec25e5e2c88068d45e3fa75435431dfe /templates | |
parent | 2a98ec1c3cd2f8396f3b5148fc8c796802f9c236 (diff) | |
download | gitea-0b27b93728fd3cf2ecc82ac6a2b5859270543ef2.tar.gz gitea-0b27b93728fd3cf2ecc82ac6a2b5859270543ef2.zip |
Make allowed Visiblity modes configurable for Users (#16271)
Now that #16069 is merged, some sites may wish to enforce that users are all public, limited or private, and/or disallow users from becoming private.
This PR adds functionality and settings to constrain a user's ability to change their visibility.
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/admin/user/edit.tmpl | 30 | ||||
-rw-r--r-- | templates/admin/user/new.tmpl | 18 | ||||
-rw-r--r-- | templates/user/settings/profile.tmpl | 30 |
3 files changed, 42 insertions, 36 deletions
diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index dba24d9837..5e5bc75c96 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -32,25 +32,25 @@ <div class="inline field {{if .Err_Visibility}}error{{end}}"> <span class="inline required field"><label for="visibility">{{.i18n.Tr "settings.visibility"}}</label></span> <div class="ui selection type dropdown"> - {{if .User.Visibility.IsPublic}} - <input type="hidden" id="visibility" name="visibility" value="0"> - {{end}} - {{if .User.Visibility.IsLimited}} - <input type="hidden" id="visibility" name="visibility" value="1"> - {{end}} - {{if .User.Visibility.IsPrivate}} - <input type="hidden" id="visibility" name="visibility" value="2"> - {{end}} + {{if .User.Visibility.IsPublic}}<input type="hidden" id="visibility" name="visibility" value="0">{{end}} + {{if .User.Visibility.IsLimited}}<input type="hidden" id="visibility" name="visibility" value="1">{{end}} + {{if .User.Visibility.IsPrivate}}<input type="hidden" id="visibility" name="visibility" value="2">{{end}} <div class="text"> - {{if .User.Visibility.IsPublic}}{{.i18n.Tr "settings.visibility.public"}}{{end}} - {{if .User.Visibility.IsLimited}}{{.i18n.Tr "settings.visibility.limited"}}{{end}} - {{if .User.Visibility.IsPrivate}}{{.i18n.Tr "settings.visibility.private"}}{{end}} + {{if .User.Visibility.IsPublic}}{{.i18n.Tr "settings.visibility.public"}}{{end}} + {{if .User.Visibility.IsLimited}}{{.i18n.Tr "settings.visibility.limited"}}{{end}} + {{if .User.Visibility.IsPrivate}}{{.i18n.Tr "settings.visibility.private"}}{{end}} </div> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.public_tooltip"}}" data-value="0">{{.i18n.Tr "settings.visibility.public"}}</div> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.limited_tooltip"}}" data-value="1">{{.i18n.Tr "settings.visibility.limited"}}</div> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.private_tooltip"}}" data-value="2">{{.i18n.Tr "settings.visibility.private"}}</div> + {{range $mode := .AllowedUserVisibilityModes}} + {{if $mode.IsPublic}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.public_tooltip"}}" data-value="0">{{$.i18n.Tr "settings.visibility.public"}}</div> + {{else if $mode.IsLimited}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.limited_tooltip"}}" data-value="1">{{$.i18n.Tr "settings.visibility.limited"}}</div> + {{else if $mode.IsPrivate}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.private_tooltip"}}" data-value="2">{{$.i18n.Tr "settings.visibility.private"}}</div> + {{end}} + {{end}} </div> </div> </div> diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index 2e39172535..a433c5a7cc 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -30,15 +30,21 @@ <div class="ui selection type dropdown"> <input type="hidden" id="visibility" name="visibility" value="{{.visibility}}"> <div class="text"> - {{if .DefaultUserVisibilityMode.IsPublic}}{{.i18n.Tr "settings.visibility.public"}}{{end}} - {{if .DefaultUserVisibilityMode.IsLimited}}{{.i18n.Tr "settings.visibility.limited"}}{{end}} - {{if .DefaultUserVisibilityMode.IsPrivate}}{{.i18n.Tr "settings.visibility.private"}}{{end}} + {{if .DefaultUserVisibilityMode.IsPublic}}{{.i18n.Tr "settings.visibility.public"}}{{end}} + {{if .DefaultUserVisibilityMode.IsLimited}}{{.i18n.Tr "settings.visibility.limited"}}{{end}} + {{if .DefaultUserVisibilityMode.IsPrivate}}{{.i18n.Tr "settings.visibility.private"}}{{end}} </div> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.public_tooltip"}}" data-value="0">{{.i18n.Tr "settings.visibility.public"}}</div> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.limited_tooltip"}}" data-value="1">{{.i18n.Tr "settings.visibility.limited"}}</div> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.private_tooltip"}}" data-value="2">{{.i18n.Tr "settings.visibility.private"}}</div> + {{range $mode := .AllowedUserVisibilityModes}} + {{if $mode.IsPublic}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.public_tooltip"}}" data-value="0">{{$.i18n.Tr "settings.visibility.public"}}</div> + {{else if $mode.IsLimited}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.limited_tooltip"}}" data-value="1">{{$.i18n.Tr "settings.visibility.limited"}}</div> + {{else if $mode.IsPrivate}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.private_tooltip"}}" data-value="2">{{$.i18n.Tr "settings.visibility.private"}}</div> + {{end}} + {{end}} </div> </div> </div> diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 4b860049d8..1f1585a787 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -71,25 +71,25 @@ <div class="inline field {{if .Err_Visibility}}error{{end}}"> <span class="inline required field"><label for="visibility">{{.i18n.Tr "settings.visibility"}}</label></span> <div class="ui selection type dropdown"> - {{if .SignedUser.Visibility.IsPublic}} - <input type="hidden" id="visibility" name="visibility" value="0"> - {{end}} - {{if .SignedUser.Visibility.IsLimited}} - <input type="hidden" id="visibility" name="visibility" value="1"> - {{end}} - {{if .SignedUser.Visibility.IsPrivate}} - <input type="hidden" id="visibility" name="visibility" value="2"> - {{end}} + {{if .SignedUser.Visibility.IsPublic}}<input type="hidden" id="visibility" name="visibility" value="0">{{end}} + {{if .SignedUser.Visibility.IsLimited}}<input type="hidden" id="visibility" name="visibility" value="1">{{end}} + {{if .SignedUser.Visibility.IsPrivate}}<input type="hidden" id="visibility" name="visibility" value="2">{{end}} <div class="text"> - {{if .SignedUser.Visibility.IsPublic}}{{.i18n.Tr "settings.visibility.public"}}{{end}} - {{if .SignedUser.Visibility.IsLimited}}{{.i18n.Tr "settings.visibility.limited"}}{{end}} - {{if .SignedUser.Visibility.IsPrivate}}{{.i18n.Tr "settings.visibility.private"}}{{end}} + {{if .SignedUser.Visibility.IsPublic}}{{.i18n.Tr "settings.visibility.public"}}{{end}} + {{if .SignedUser.Visibility.IsLimited}}{{.i18n.Tr "settings.visibility.limited"}}{{end}} + {{if .SignedUser.Visibility.IsPrivate}}{{.i18n.Tr "settings.visibility.private"}}{{end}} </div> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.public_tooltip"}}" data-value="0">{{.i18n.Tr "settings.visibility.public"}}</div> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.limited_tooltip"}}" data-value="1">{{.i18n.Tr "settings.visibility.limited"}}</div> - <div class="item poping up" data-content="{{.i18n.Tr "settings.visibility.private_tooltip"}}" data-value="2">{{.i18n.Tr "settings.visibility.private"}}</div> + {{range $mode := .AllowedUserVisibilityModes}} + {{if $mode.IsPublic}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.public_tooltip"}}" data-value="0">{{$.i18n.Tr "settings.visibility.public"}}</div> + {{else if $mode.IsLimited}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.limited_tooltip"}}" data-value="1">{{$.i18n.Tr "settings.visibility.limited"}}</div> + {{else if $mode.IsPrivate}} + <div class="item poping up" data-content="{{$.i18n.Tr "settings.visibility.private_tooltip"}}" data-value="2">{{$.i18n.Tr "settings.visibility.private"}}</div> + {{end}} + {{end}} </div> </div> </div> |