Commit 2115836f authored by Rémy Coutable's avatar Rémy Coutable

Introduce a new Namespace#licensed_feature_available? method

This makes clear that this method is checking for licensed features,
for consistency with `Project#licensed_feature_available?`.
I believe in the end, `Namespace#licensed_feature_available?` should
replace `Namespace#feature_available?` since `Namespace` only checks
for licensed features.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 671982d6
...@@ -284,8 +284,13 @@ class Namespace < ApplicationRecord ...@@ -284,8 +284,13 @@ class Namespace < ApplicationRecord
false false
end end
# Deprecated, use #licensed_feature_available? instead. Remove once Namespace#feature_available? isn't used anymore.
def feature_available?(feature)
licensed_feature_available?(feature)
end
# Overridden in EE::Namespace # Overridden in EE::Namespace
def feature_available?(_feature) def licensed_feature_available?(_feature)
false false
end end
......
...@@ -2324,6 +2324,11 @@ class Project < ApplicationRecord ...@@ -2324,6 +2324,11 @@ class Project < ApplicationRecord
.external_authorization_service_default_label .external_authorization_service_default_label
end end
# Overridden in EE::Project
def licensed_feature_available?(_feature)
false
end
def licensed_features def licensed_features
[] []
end end
......
...@@ -146,8 +146,8 @@ module EE ...@@ -146,8 +146,8 @@ module EE
# Checks features (i.e. https://about.gitlab.com/pricing/) availabily # Checks features (i.e. https://about.gitlab.com/pricing/) availabily
# for a given Namespace plan. This method should consider ancestor groups # for a given Namespace plan. This method should consider ancestor groups
# being licensed. # being licensed.
override :feature_available? override :licensed_feature_available?
def feature_available?(feature) def licensed_feature_available?(feature)
available_features = strong_memoize(:feature_available) do available_features = strong_memoize(:feature_available) do
Hash.new do |h, f| Hash.new do |h, f|
h[f] = load_feature_available(f) h[f] = load_feature_available(f)
......
...@@ -804,6 +804,16 @@ module EE ...@@ -804,6 +804,16 @@ module EE
jira_issue_association_required_to_merge_enabled? && prevent_merge_without_jira_issue jira_issue_association_required_to_merge_enabled? && prevent_merge_without_jira_issue
end end
def licensed_feature_available?(feature, user = nil)
available_features = strong_memoize(:licensed_feature_available) do
Hash.new do |h, f|
h[f] = load_licensed_feature_available(f)
end
end
available_features[feature]
end
private private
def group_hooks def group_hooks
...@@ -819,16 +829,6 @@ module EE ...@@ -819,16 +829,6 @@ module EE
import_state.set_next_execution_to_now import_state.set_next_execution_to_now
end end
def licensed_feature_available?(feature, user = nil)
available_features = strong_memoize(:licensed_feature_available) do
Hash.new do |h, f|
h[f] = load_licensed_feature_available(f)
end
end
available_features[feature]
end
def load_licensed_feature_available(feature) def load_licensed_feature_available(feature)
globally_available = License.feature_available?(feature) globally_available = License.feature_available?(feature)
......
...@@ -23,8 +23,13 @@ module Gitlab ...@@ -23,8 +23,13 @@ module Gitlab
parent_id.present? || parent.present? parent_id.present? || parent.present?
end end
# Deprecated, use #licensed_feature_available? instead. Remove once Namespace#feature_available? isn't used anymore.
def feature_available?(feature)
licensed_feature_available?(feature)
end
# Overridden in EE::Namespace # Overridden in EE::Namespace
def feature_available?(_feature) def licensed_feature_available?(_feature)
false false
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment