diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/models/release_highlight.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/models/release_highlight.rb')
-rw-r--r-- | app/models/release_highlight.rb | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/app/models/release_highlight.rb b/app/models/release_highlight.rb index 98d9899a349..9c30d0611e6 100644 --- a/app/models/release_highlight.rb +++ b/app/models/release_highlight.rb @@ -4,6 +4,10 @@ class ReleaseHighlight CACHE_DURATION = 1.hour FILES_PATH = Rails.root.join('data', 'whats_new', '*.yml') + FREE_PACKAGE = 'Free' + PREMIUM_PACKAGE = 'Premium' + ULTIMATE_PACKAGE = 'Ultimate' + def self.paginated(page: 1) key = self.cache_key("items:page-#{page}") @@ -25,14 +29,12 @@ class ReleaseHighlight file = File.read(file_path) items = YAML.safe_load(file, permitted_classes: [Date]) - platform = Gitlab.com? ? 'gitlab-com' : 'self-managed' - items&.map! do |item| - next unless item[platform] + next unless include_item?(item) begin item.tap {|i| i['body'] = Kramdown::Document.new(i['body']).to_html } - rescue => e + rescue StandardError => e Gitlab::ErrorTracking.track_exception(e, file_path: file_path) next @@ -53,7 +55,8 @@ class ReleaseHighlight end def self.cache_key(key) - ['release_highlight', key, Gitlab.revision].join(':') + variant = Gitlab::CurrentSettings.current_application_settings.whats_new_variant + ['release_highlight', variant, key, Gitlab.revision].join(':') end def self.next_page(current_page: 1) @@ -88,4 +91,27 @@ class ReleaseHighlight delegate :each, to: :items end + + def self.current_package + return FREE_PACKAGE unless defined?(License) + + case License.current&.plan&.downcase + when License::PREMIUM_PLAN + PREMIUM_PACKAGE + when License::ULTIMATE_PLAN + ULTIMATE_PACKAGE + else + FREE_PACKAGE + end + end + + def self.include_item?(item) + platform = Gitlab.com? ? 'gitlab-com' : 'self-managed' + + return false unless item[platform] + + return true unless Gitlab::CurrentSettings.current_application_settings.whats_new_variant_current_tier? + + item['packages']&.include?(current_package) + end end |