This repository was archived by the owner on Dec 4, 2023. It is now read-only.
forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add admin notifications for new Mastodon versions (mastodon#26582)
- Loading branch information
1 parent
be991f1
commit 16681e0
Showing
39 changed files
with
892 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class SoftwareUpdatesController < BaseController | ||
before_action :check_enabled! | ||
|
||
def index | ||
authorize :software_update, :index? | ||
@software_updates = SoftwareUpdate.all.sort_by(&:gem_version) | ||
end | ||
|
||
private | ||
|
||
def check_enabled! | ||
not_found unless SoftwareUpdate.check_enabled? | ||
end | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
app/javascript/mastodon/features/home_timeline/components/critical_update_banner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
export const CriticalUpdateBanner = () => ( | ||
<div className='warning-banner'> | ||
<div className='warning-banner__message'> | ||
<h1> | ||
<FormattedMessage | ||
id='home.pending_critical_update.title' | ||
defaultMessage='Critical security update available!' | ||
/> | ||
</h1> | ||
<p> | ||
<FormattedMessage | ||
id='home.pending_critical_update.body' | ||
defaultMessage='Please update your Mastodon server as soon as possible!' | ||
/>{' '} | ||
<a href='/admin/software_updates'> | ||
<FormattedMessage | ||
id='home.pending_critical_update.link' | ||
defaultMessage='See updates' | ||
/> | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class Admin::SystemCheck::SoftwareVersionCheck < Admin::SystemCheck::BaseCheck | ||
include RoutingHelper | ||
|
||
def skip? | ||
!current_user.can?(:view_devops) || !SoftwareUpdate.check_enabled? | ||
end | ||
|
||
def pass? | ||
software_updates.empty? | ||
end | ||
|
||
def message | ||
if software_updates.any?(&:urgent?) | ||
Admin::SystemCheck::Message.new(:software_version_critical_check, nil, admin_software_updates_path, true) | ||
else | ||
Admin::SystemCheck::Message.new(:software_version_patch_check, nil, admin_software_updates_path) | ||
end | ||
end | ||
|
||
private | ||
|
||
def software_updates | ||
@software_updates ||= SoftwareUpdate.pending_to_a.filter { |update| update.urgent? || update.patch_type? } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: software_updates | ||
# | ||
# id :bigint(8) not null, primary key | ||
# version :string not null | ||
# urgent :boolean default(FALSE), not null | ||
# type :integer default("patch"), not null | ||
# release_notes :string default(""), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class SoftwareUpdate < ApplicationRecord | ||
self.inheritance_column = nil | ||
|
||
enum type: { patch: 0, minor: 1, major: 2 }, _suffix: :type | ||
|
||
def gem_version | ||
Gem::Version.new(version) | ||
end | ||
|
||
class << self | ||
def check_enabled? | ||
ENV['UPDATE_CHECK_URL'] != '' | ||
end | ||
|
||
def pending_to_a | ||
return [] unless check_enabled? | ||
|
||
all.to_a.filter { |update| update.gem_version > Mastodon::Version.gem_version } | ||
end | ||
|
||
def urgent_pending? | ||
pending_to_a.any?(&:urgent?) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class SoftwareUpdatePolicy < ApplicationPolicy | ||
def index? | ||
role.can?(:view_devops) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.