diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-09-01 15:28:14 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-09-01 15:28:14 +0000 |
commit | d308a3f4335845d88cbb4fbfbea9d72fa2473769 (patch) | |
tree | d9b53fc90b0db5416b2eb78b56766aec646a2095 /app/helpers/projects_helper.rb | |
parent | ae439a62cca06fdc719d53dd32e7235cf219c3c7 (diff) | |
parent | 892dea67717c0efbd6a28f7639f34535ec0a8747 (diff) | |
download | gitlab-ce-d308a3f4335845d88cbb4fbfbea9d72fa2473769.tar.gz |
Merge branch 'issue_19734' into 'master'
Project tools visibility level
## part of #19734
![project_features_access_level](/uploads/81ec7185d4e61d7578652020209af925/project_features_access_level.png)
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5606
Diffstat (limited to 'app/helpers/projects_helper.rb')
-rw-r--r-- | app/helpers/projects_helper.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index f07077bd133..79a1eba9714 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -412,4 +412,23 @@ module ProjectsHelper message.strip.gsub(project.repository_storage_path.chomp('/'), "[REPOS PATH]") end + + def project_feature_options + { + 'Disabled' => ProjectFeature::DISABLED, + 'Only team members' => ProjectFeature::PRIVATE, + 'Everyone with access' => ProjectFeature::ENABLED + } + end + + def project_feature_access_select(field) + # Don't show option "everyone with access" if project is private + options = project_feature_options + level = @project.project_feature.public_send(field) + + options.delete('Everyone with access') if @project.private? && level != ProjectFeature::ENABLED + + options = options_for_select(options, selected: @project.project_feature.public_send(field) || ProjectFeature::ENABLED) + content_tag(:select, options, name: "project[project_feature_attributes][#{field.to_s}]", id: "project_project_feature_attributes_#{field.to_s}", class: "pull-right form-control").html_safe + end end |