diff options
author | Mike Greiling <mgreiling@gitlab.com> | 2017-09-07 18:07:40 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-09-07 18:07:40 +0000 |
commit | 03b14b48a07e3bcab53b273bbeccdba1ef921ac2 (patch) | |
tree | f41b966fa0ea4e2b279be894ba9c59578e94e1fc /app/helpers | |
parent | 21b16c5a168ebd79c6a5bcb9633752ecf4958089 (diff) | |
download | gitlab-ce-03b14b48a07e3bcab53b273bbeccdba1ef921ac2.tar.gz |
Resolve "Make project and features visibility settings less confusing"
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/projects_helper.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 51c625ede4b..c0114dd0256 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -545,6 +545,43 @@ module ProjectsHelper current_application_settings.restricted_visibility_levels || [] end + def project_permissions_settings(project) + feature = project.project_feature + { + visibilityLevel: project.visibility_level, + requestAccessEnabled: !!project.request_access_enabled, + issuesAccessLevel: feature.issues_access_level, + repositoryAccessLevel: feature.repository_access_level, + mergeRequestsAccessLevel: feature.merge_requests_access_level, + buildsAccessLevel: feature.builds_access_level, + wikiAccessLevel: feature.wiki_access_level, + snippetsAccessLevel: feature.snippets_access_level, + containerRegistryEnabled: !!project.container_registry_enabled, + lfsEnabled: !!project.lfs_enabled + } + end + + def project_permissions_panel_data(project) + data = { + currentSettings: project_permissions_settings(project), + canChangeVisibilityLevel: can_change_visibility_level?(project, current_user), + allowedVisibilityOptions: project_allowed_visibility_levels(project), + visibilityHelpPath: help_page_path('public_access/public_access'), + registryAvailable: Gitlab.config.registry.enabled, + registryHelpPath: help_page_path('user/project/container_registry'), + lfsAvailable: Gitlab.config.lfs.enabled && current_user.admin?, + lfsHelpPath: help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs') + } + + data.to_json.html_safe + end + + def project_allowed_visibility_levels(project) + Gitlab::VisibilityLevel.values.select do |level| + project.visibility_level_allowed?(level) && !restricted_levels.include?(level) + end + end + def find_file_path return unless @project && !@project.empty_repo? |