diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/groups_helper.rb | 32 | ||||
-rw-r--r-- | app/views/groups/edit.html.haml | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index eab1feb8a1f..1ced92e0828 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -65,6 +65,22 @@ module GroupsHelper { group_name: group.name } end + def share_with_group_lock_disabled + return false unless @group.has_parent? + return false unless @group.parent.share_with_group_lock? + return false unless @group.share_with_group_lock? + return false if @group.has_owner?(current_user) + return true + end + + def share_with_group_lock_help_text + return default_help unless @group.has_parent? + return default_help unless @group.parent.share_with_group_lock? + return parent_locked_and_has_been_overridden unless @group.share_with_group_lock? + return parent_locked_but_you_can_override if @group.has_owner?(current_user) + return parent_locked_so_ask_the_owner + end + private def group_title_link(group, hidable: false, show_avatar: false) @@ -80,4 +96,20 @@ module GroupsHelper output.html_safe end end + + def default_help + "This setting will be applied to all subgroups unless overridden by a group owner." + end + + def parent_locked_but_you_can_override + "This setting is applied on #{@group.parent.name}. You can override the setting or remove the share lock from the parent group." + end + + def parent_locked_so_ask_the_owner + "This setting is applied on #{@group.parent.name}. To share this group with another group, ask the owner to override the setting or remove the share lock from the parent group." + end + + def parent_locked_and_has_been_overridden + "This setting is applied on #{@group.parent.name} and has been overridden on this subgroup." + end end diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index b53f0b90b9c..fb7825b82fc 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -33,13 +33,13 @@ .col-sm-10 .checkbox = f.label :share_with_group_lock do - = f.check_box :share_with_group_lock + = f.check_box :share_with_group_lock, disabled: share_with_group_lock_disabled %strong Prevent sharing a project within = @group.name with other groups %br/ - %span.descr This setting will be applied to all subgroups unless overridden by a group owner + %span.descr= share_with_group_lock_help_text = render 'group_admin_settings', f: f |