summaryrefslogtreecommitdiff
path: root/app/models/clusters/cluster.rb
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2018-11-26 22:01:18 +1300
committerThong Kuah <tkuah@gitlab.com>2018-12-05 10:16:44 +1300
commit8419b7dd2b85fbe9216a31ce84d5ecb234a8b90a (patch)
tree2d0ae5162d844dc9cf37005007e7e9a998e433a9 /app/models/clusters/cluster.rb
parent9c5977c821c1958709227a7a5976e1faedc53923 (diff)
downloadgitlab-ce-8419b7dd2b85fbe9216a31ce84d5ecb234a8b90a.tar.gz
Teach Cluster about #all_projects
For project level, it's the project directly associated. For group level, it's the projects under that group.
Diffstat (limited to 'app/models/clusters/cluster.rb')
-rw-r--r--app/models/clusters/cluster.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index e85e7a4e8be..54314f69c3d 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -133,6 +133,16 @@ module Clusters
!user?
end
+ def all_projects
+ if project_type?
+ projects
+ elsif group_type?
+ first_group.all_projects
+ else
+ Project.none
+ end
+ end
+
def first_project
strong_memoize(:first_project) do
projects.first