summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-11-19 16:17:35 +0000
committerNick Thomas <nick@gitlab.com>2019-11-25 11:44:16 +0000
commitb1dad8b2525b81f473bafbe69a3e2dfe24d90f49 (patch)
tree782bf18f1fc8b942c38655fafe49bd1c766444b2 /app/helpers
parentdbd50b6e203994cdb393494faa8fc1b2fb406487 (diff)
downloadgitlab-ce-b1dad8b2525b81f473bafbe69a3e2dfe24d90f49.tar.gz
Check permissions before showing a forked project's source
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/projects_helper.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 64d61bba71a..466c782fc77 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -110,19 +110,26 @@ module ProjectsHelper
{ project_full_name: project.full_name }
end
- def remove_fork_project_message(project)
- _("You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?") %
- { forked_from_project: fork_source_name(project) }
- end
+ def remove_fork_project_description_message(project)
+ source = visible_fork_source(project)
- def fork_source_name(project)
- if @project.fork_source
- @project.fork_source.full_name
+ if source
+ _('This will remove the fork relationship between this project and %{fork_source}.') %
+ { fork_source: link_to(source.full_name, project_path(source)) }
else
- @project.fork_network&.deleted_root_project_name
+ _('This will remove the fork relationship between this project and other projects in the fork network.')
end
end
+ def remove_fork_project_warning_message(project)
+ _("You are going to remove the fork relationship from %{project_full_name}. Are you ABSOLUTELY sure?") %
+ { project_full_name: project.full_name }
+ end
+
+ def visible_fork_source(project)
+ project.fork_source if project.fork_source && can?(current_user, :read_project, project.fork_source)
+ end
+
def project_nav_tabs
@nav_tabs ||= get_project_nav_tabs(@project, current_user)
end