From e11be4810037ec5411ebf1843aed06cd8e7680a2 Mon Sep 17 00:00:00 2001 From: KMY Date: Thu, 21 Sep 2023 13:22:10 +0900 Subject: [PATCH] Show major or patch version update on menu --- app/models/software_update.rb | 8 ++++++++ app/views/settings/preferences/reaching/show.html.haml | 2 +- config/locales/en.yml | 3 +++ config/locales/ja.yml | 3 +++ config/navigation.rb | 6 +++++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/models/software_update.rb b/app/models/software_update.rb index cb3a6df2aeb96e..4aeb7e665b7f84 100644 --- a/app/models/software_update.rb +++ b/app/models/software_update.rb @@ -36,5 +36,13 @@ def pending_to_a def urgent_pending? pending_to_a.any?(&:urgent?) end + + def major_pending? + pending_to_a.any?(&:major_type?) + end + + def patch_pending? + pending_to_a.any?(&:patch_type?) + end end end diff --git a/app/views/settings/preferences/reaching/show.html.haml b/app/views/settings/preferences/reaching/show.html.haml index b3d22e805200c5..cfeaeff68e295c 100644 --- a/app/views/settings/preferences/reaching/show.html.haml +++ b/app/views/settings/preferences/reaching/show.html.haml @@ -31,7 +31,7 @@ .fields-row .fields-group.fields-row__column.fields-row__column-12 - = ff.input :default_searchability, collection: Status.selectable_searchabilities, wrapper: :with_label, kmyblue: true, include_blank: false, label_method: lambda { |searchability| safe_join([I18n.t("statuses.searchabilities.#{searchability}"), I18n.t("statuses.searchabilities.#{searchability}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_searchability') + = ff.input :default_searchability, collection: Status.selectable_searchabilities, wrapper: :with_label, kmyblue: true, include_blank: false, label_method: lambda { |searchability| safe_join([I18n.t("statuses.searchabilities.#{searchability}"), I18n.t("statuses.searchabilities.#{searchability}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_searchability'), hint: I18n.t('simple_form.hints.defaults.setting_default_searchability') .fields-group = ff.input :disallow_unlisted_public_searchability, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_disallow_unlisted_public_searchability'), hint: I18n.t('simple_form.hints.defaults.setting_disallow_unlisted_public_searchability') diff --git a/config/locales/en.yml b/config/locales/en.yml index d9d0bb084a350d..4e477ba1467538 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -997,6 +997,9 @@ en: other: Used by %{count} people over the last week title: Trends trending: Trending + update-pendings: + major: Major update pending + patch: Patch update pending warning_presets: add_new: Add new delete: Delete diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 286e19d42f9dc9..4d6d4e4c6ab53f 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -991,6 +991,9 @@ ja: other: 週間%{count}人に使用されました title: トレンド trending: トレンド + update_pendings: + major: メジャーアップデートあり + patch: パッチアップデートあり warning_presets: add_new: 追加 delete: 削除 diff --git a/config/navigation.rb b/config/navigation.rb index ce8c44d5423d56..bdb86f06a7007c 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -4,7 +4,11 @@ navigation.items do |n| n.item :web, safe_join([fa_icon('chevron-left fw'), t('settings.back')]), root_path - n.item :software_updates, safe_join([fa_icon('exclamation-circle fw'), t('admin.critical_update_pending')]), admin_software_updates_path, if: -> { ENV['UPDATE_CHECK_URL'] != '' && current_user.can?(:view_devops) && SoftwareUpdate.urgent_pending? }, html: { class: 'warning' } + if ENV['UPDATE_CHECK_URL'] != '' && current_user.can?(:view_devops) + n.item :software_updates, safe_join([fa_icon('exclamation-circle fw'), t('admin.critical_update_pending')]), admin_software_updates_path, if: -> { SoftwareUpdate.urgent_pending? }, html: { class: 'warning' } + n.item :software_updates, safe_join([fa_icon('exclamation-circle fw'), t('admin.update_pendings.major')]), admin_software_updates_path, if: -> { !SoftwareUpdate.urgent_pending? && SoftwareUpdate.major_pending? }, html: { class: 'warning' } + n.item :software_updates, safe_join([fa_icon('exclamation-circle fw'), t('admin.update_pendings.patch')]), admin_software_updates_path, if: -> { !SoftwareUpdate.urgent_pending? && SoftwareUpdate.patch_pending? }, html: { class: 'warning' } + end n.item :profile, safe_join([fa_icon('user fw'), t('settings.profile')]), settings_profile_path, if: -> { current_user.functional? }, highlights_on: %r{/settings/profile|/settings/featured_tags|/settings/verification|/settings/privacy}