Add “Update available” navigation item at top of navbar when new Mastodon versions are available (#39705)

This commit is contained in:
Claire 2026-07-03 13:37:02 +02:00
parent 7db2a99504
commit f4cdbb9015
5 changed files with 12 additions and 3 deletions

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h200v80H160v480h640v-480H600v-80h200q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm320-184L280-544l56-56 104 104v-304h80v304l104-104 56 56-200 200Z"/></svg>

After

Width:  |  Height:  |  Size: 321 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h200v80H160v480h640v-480H600v-80h200q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm320-184L280-544l56-56 104 104v-304h80v304l104-104 56 56-200 200Z"/></svg>

After

Width:  |  Height:  |  Size: 321 B

View File

@ -47,6 +47,10 @@ class SoftwareUpdate < ApplicationRecord
all.to_a.filter(&:pending?)
end
def pending?
pending_to_a.present?
end
def urgent_pending?
pending_to_a.any?(&:urgent?)
end

View File

@ -1226,6 +1226,7 @@ en:
other: Used by %{count} people over the last week
title: Recommendations & Trends
trending: Trending
update_available: Update available
username_blocks:
add_new: Add new
block_registrations: Block registrations

View File

@ -7,10 +7,12 @@ SimpleNavigation::Configuration.run do |navigation|
n.item :web, safe_join([material_symbol('chevron_left'), t('settings.back')]), root_path
n.item :software_updates,
safe_join([material_symbol('report'), t('admin.critical_update_pending')]),
safe_join(
SoftwareUpdate.urgent_pending? ? [material_symbol('report'), t('admin.critical_update_pending')] : [material_symbol('system_update_alt'), t('admin.update_available')]
),
admin_software_updates_path,
if: -> { Rails.configuration.x.mastodon.software_update_url.present? && current_user.can?(:view_devops) && SoftwareUpdate.urgent_pending? },
html: { class: 'warning' }
html: { class: SoftwareUpdate.urgent_pending? ? 'warning' : nil },
if: -> { Rails.configuration.x.mastodon.software_update_url.present? && current_user.can?(:view_devops) && SoftwareUpdate.pending? }
n.item :profile, safe_join([material_symbol('person'), t('settings.profile')]), settings_profile_path, if: -> { current_user.functional? && !self_destruct }, highlights_on: %r{/settings/profile|/settings/featured_tags|/settings/verification}
n.item :privacy, safe_join([material_symbol('globe'), t('privacy.title')]), settings_privacy_path, if: -> { current_user.functional? && !self_destruct }, highlights_on: %r{/settings/privacy}