Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
add "Maintenance Mode" as a separate entry in admin menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Jul 26, 2017
1 parent e065373 commit e1f0dba
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
Binary file added assets/images/wrench_orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/stylesheets/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#admin-menu a.redmine-maintenance-mode {
background-image: url(../images/wrench_orange.png);
}
1 change: 1 addition & 0 deletions config/locales/cs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Czech strings go here for Rails i18n
cs:
maintenance_mode: Režim odstávky
maintenance_mode_active: Aktivovat režim odstávky?
maintenance_mode_message_label: Zpráva odstávky
maintenance_mode_message_default: "Tento web je nyní odstaven. Zkuste web navštívit později!"
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# German strings go here for Rails i18n
de:
maintenance_mode: Wartungsmodus
maintenance_mode_active: Wartungsmodus aktivieren?
maintenance_mode_message_label: Wartungshinweis
maintenance_mode_message_default: "Redmine ist für kurze Zeit nicht verfügbar, um eine regelmäßige Instandhaltung durchzuführen. Prüfe in einigen Minuten erneut!"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# English strings go here for Rails i18n
en:
maintenance_mode: Maintenance mode
maintenance_mode_active: Activate maintenance mode?
maintenance_mode_message_label: Maintenance message
maintenance_mode_message_default: "This site is currently under maintenance. Please check back later!"
Expand Down
10 changes: 8 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
version '2.0.1'
url 'https://github.com/tofi86/redmine_maintenance_mode'
author_url 'https://github.com/tofi86'

requires_redmine :version_or_higher => '2.4.0'
requires_redmine_plugin :redmine_base_deface, :version_or_higher => '0.0.1'


menu :admin_menu, :redmine_maintenance_mode,
{ :controller => 'settings', :action => 'plugin', :id => :redmine_maintenance_mode },
:caption => :maintenance_mode,
:after => :auth_sources,
html: { class: 'icon icon-maintenance_mode' }

settings :default => {
'maintenance_active' => false,
'maintenance_message' => '',
Expand Down
13 changes: 8 additions & 5 deletions lib/maintenance_mode_hooks.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
class MaintenanceModeHook < Redmine::Hook::ViewListener
require 'maintenance_mode_functions'

# add css and javascript if we're in the middle of a maintenance
def view_layouts_base_html_head(context = {})
tags = stylesheet_link_tag('admin', :plugin => 'redmine_maintenance_mode')

# read plugin settings
settings = MaintenanceModeFunctions.get_maintenance_plugin_settings

if settings[:maintenance_active] || settings[:maintenance_scheduled] || MaintenanceModeFunctions.is_now_scheduled_maintenance
tags = stylesheet_link_tag 'maintenance_mode', :plugin => 'redmine_maintenance_mode'
return tags
tags += stylesheet_link_tag 'maintenance_mode', :plugin => 'redmine_maintenance_mode'
end

tags
end

end

0 comments on commit e1f0dba

Please sign in to comment.