Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-09-06 03:02:11 +0300
committerMichael Kozono <mkozono@gmail.com>2017-09-06 22:07:21 +0300
commitf25b5b7f8db05ec441574429e024c71893fa7c11 (patch)
tree8270555cadd697963bc7585b582e0e9c9d2ac2cc /app/helpers/groups_helper.rb
parentedf8dd44f7676d14fda5ce305c2c3e31b8c14c17 (diff)
Fix “Share lock” help text
Diffstat (limited to 'app/helpers/groups_helper.rb')
-rw-r--r--app/helpers/groups_helper.rb41
1 files changed, 27 insertions, 14 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index 62ad16314bf..f865cd133ad 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -69,12 +69,18 @@ module GroupsHelper
{ group_name: group.name }
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
+ def share_with_group_lock_help_text(group)
+ return default_help unless group.parent&.share_with_group_lock?
+
+ if group.share_with_group_lock?
+ if can?(current_user, :change_share_with_group_lock, group.parent)
+ ancestor_locked_but_you_can_override(group)
+ else
+ ancestor_locked_so_ask_the_owner(group)
+ end
+ else
+ ancestor_locked_and_has_been_overridden(group)
+ end
end
private
@@ -93,23 +99,30 @@ module GroupsHelper
end
end
- def parent_group_link
- link_to @group.parent.name, group_path(@group.parent)
+ def ancestor_group_link(group)
+ ancestor = oldest_consecutively_locked_ancestor(group)
+ link_to ancestor.name, group_path(ancestor)
+ end
+
+ def oldest_consecutively_locked_ancestor(group)
+ group.ancestors.find do |group|
+ !group.has_parent? || !group.parent.share_with_group_lock?
+ end
end
def default_help
s_("GroupSettings|This setting will be applied to all subgroups unless overridden by a group owner.")
end
- def parent_locked_but_you_can_override
- s_("GroupSettings|This setting is applied on %{parent_group}. You can override the setting or remove the share lock from the parent group.") % { parent_group: parent_group_link }
+ def ancestor_locked_but_you_can_override(group)
+ s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or remove the share lock from %{ancestor_group}.") % { ancestor_group: ancestor_group_link(group) }
end
- def parent_locked_so_ask_the_owner
- s_("GroupSettings|This setting is applied on %{parent_group}. To share this group with another group, ask the owner to override the setting or remove the share lock from the parent group.") % { parent_group: parent_group_link }
+ def ancestor_locked_so_ask_the_owner(group)
+ s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or remove the share lock from %{ancestor_group}.") % { ancestor_group: ancestor_group_link(group) }
end
- def parent_locked_and_has_been_overridden
- s_("GroupSettings|This setting is applied on %{parent_group} and has been overridden on this subgroup.") % { parent_group: parent_group_link }
+ def ancestor_locked_and_has_been_overridden(group)
+ s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.") % { ancestor_group: ancestor_group_link(group) }
end
end