Skip to content

Commit

Permalink
Compatibility to Redmine 3.x and full refactoring;
Browse files Browse the repository at this point in the history
  • Loading branch information
nodecarter committed Dec 2, 2016
1 parent 1c66799 commit 1d20234
Show file tree
Hide file tree
Showing 38 changed files with 345 additions and 573 deletions.
39 changes: 15 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,23 @@ services:
- postgresql

rvm:
- 1.9.3
- 2.0.0
- 2.3.1

gemfile:
- $REDMINE_PATH/Gemfile

env:
- REDMINE_VER=2.1.6 DB=mysql
- REDMINE_VER=2.2.4 DB=mysql
- REDMINE_VER=2.3.3 DB=mysql
- REDMINE_VER=2.1.6 DB=postgresql
- REDMINE_VER=2.2.4 DB=postgresql
- REDMINE_VER=2.3.3 DB=postgresql

matrix:
exclude:
- rvm: 2.0.0
env: REDMINE_VER=2.1.6 DB=mysql
- rvm: 2.0.0
env: REDMINE_VER=2.2.4 DB=mysql
- rvm: 2.0.0
env: REDMINE_VER=2.1.6 DB=postgresql
- rvm: 2.0.0
env: REDMINE_VER=2.2.4 DB=postgresql
- REDMINE_VER=3.1.7 DB=mysql
- REDMINE_VER=3.2.4 DB=mysql
- REDMINE_VER=3.3.1 DB=mysql
- REDMINE_VER=3.1.7 DB=postgresql
- REDMINE_VER=3.2.4 DB=postgresql
- REDMINE_VER=3.3.1 DB=postgresql

before_install:
- export PLUGIN_NAME=redmine_stealth
- export REDMINE_PATH=$HOME/redmine
- git clone --depth=1 --branch=$REDMINE_VER https://github.com/redmine/redmine.git $REDMINE_PATH
- svn co http://svn.redmine.org/redmine/tags/$REDMINE_VER $REDMINE_PATH
- ln -s $TRAVIS_BUILD_DIR $REDMINE_PATH/plugins/$PLUGIN_NAME
- cp config/database-$DB-travis.yml $REDMINE_PATH/config/database.yml
- cd $REDMINE_PATH
Expand All @@ -39,10 +30,10 @@ install:
- bundle install

before_script:
- rake db:create
- rake db:migrate
- rake redmine:plugins:migrate
- bundle exec rake db:create
- bundle exec rake db:migrate
- bundle exec rake redmine:plugins:migrate

script:
- rake redmine:plugins:test NAME=$PLUGIN_NAME
- bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0"

File renamed without changes.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Redmine Stealth Plugin

[![Build Status](https://travis-ci.org/Undev/redmine_stealth_modified.svg?branch=master)](https://travis-ci.org/Undev/redmine_stealth_modified)
[![Code Climate](https://codeclimate.com/github/Undev/redmine_stealth.png)](https://codeclimate.com/github/Undev/redmine_stealth)
[![Build Status](https://travis-ci.org/Restream/redmine_stealth.svg?branch=master)](https://travis-ci.org/Restream/redmine_stealth)

This plugin allows the Redmine administrator to temporarily disable sending email messages when the Redmine content is added or changed, for example, when updating issues or wiki pages. The plugin is intended to allow the administrator to make bulk changes or minor corrections without flooding the inboxes of other users.

Initially, any Redmine user with the corresponding permission could temporarily turn off sending email notifications. This feature has been deliberately disabled in this fork.

The initial author of the plugin is [Riley Lynch](https://github.com/teleological/redmine_stealth).

## Copmatibility

This plugin si compatible with Redmine 3.x and later. Detailed information here: [travis](https://travis-ci.org/Restream/redmine_stealth)

## Installation

*These installation instructions are based on Redmine 2.6.0. For instructions for previous versions, see [Redmine wiki](http://www.redmine.org/projects/redmine/wiki/Plugins).*
Expand All @@ -24,11 +27,10 @@ The initial author of the plugin is [Riley Lynch](https://github.com/teleologica

Copy the plugin from GitHub using the following command:

git clone https://github.com/Undev/redmine_stealth.git plugins/redmine_stealth
git clone https://github.com/Restream/redmine_stealth.git plugins/redmine_stealth

2. Update the Gemfile.lock file by running the following commands:

rm Gemfile.lock
bundle install
3. This plugin requires a migration. Run the following command to upgrade your database (make a database backup before):
Expand All @@ -42,22 +44,22 @@ Now you should be able to see the plugin in **Administration > Plugins**.
## Usage

To activate the stealth mode feature, click **My account** and then select the **Allow toggling stealth mode** check box in the **Redmine Stealth** section.
![allow stealth](stealth_1.PNG)
![allow stealth](doc/stealth_1.png)

This will add the **Enable Stealth Mode** / **Disable Stealth Mode** link to the right top menu, next to **My account**.

To enable the stealth mode and prevent Redmine from sending email messages, click **Enable Stealth Mode**.
![enable stealth](stealth_2.PNG)
![enable stealth](doc/stealth_2.png)

Redmine will not send email notifications about your actions while the stealth mode is enabled. However, it will continue to send email messages about other users' actions.

After you finish, click **Disable Stealth Mode** to return to normal mode.
![disable stealth](stealth_3.PNG)
![disable stealth](doc/stealth_3.png)

*Note that the following feature has been disabled in this fork*

Other Redmine users can also enable or disable the stealth mode by clicking the **Enable Stealth Mode** / **Disable Stealth Mode** link, if they have the corresponding permissions.
![stealth permissions](stealth_4.PNG)
![stealth permissions](doc/stealth_4.png)

## Maintainers

Expand Down
12 changes: 0 additions & 12 deletions Rakefile

This file was deleted.

24 changes: 12 additions & 12 deletions app/controllers/stealth_controller.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@

class StealthController < ApplicationController
unloadable

before_filter :check_can_stealth

def toggle
is_cloaked = toggle_for_params
render :js => RedmineStealth.javascript_toggle_statement(is_cloaked)
toggle_by_params
render js: RedmineStealth.javascript_toggle_statement(User.current.stealth_mode_active?)
end

private

def toggle_for_params
if params[:toggle] == 'true'
RedmineStealth.cloak!
elsif params[:toggle] == 'false'
RedmineStealth.decloak!
else
RedmineStealth.toggle_stealth_mode!
def toggle_by_params
case params[:toggle]
when 'true'
User.current.activate_stealth_mode
when 'false'
User.current.deactivate_stealth_mode
else
User.current.toggle_stealth_mode
end
end

def check_can_stealth
render_403 unless User.current.stealth_allowed
render_403 unless User.current.stealth_allowed?
end

end

16 changes: 8 additions & 8 deletions app/views/hooks/_stealth_settings.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<fieldset class="box tabular">
<legend><%=l(:stealth)%></legend>
<p>
<%= form.check_box(:stealth_allowed,
:disabled => (true unless User.current.admin?))
%>
</p>
</fieldset>
<% if User.current.admin? %>
<fieldset class="box tabular">
<legend><%= l(:stealth) %></legend>
<p>
<%= form.check_box(:stealth_allowed) %>
</p>
</fieldset>
<% end %>
25 changes: 0 additions & 25 deletions assets/javascripts/prototype-stealth.js

This file was deleted.

25 changes: 9 additions & 16 deletions assets/javascripts/stealth.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@

jQuery(function($) {

window.RedmineStealth = {

cloak: function(label) {
$('#stealth_toggle').text(label).
data({ params : { toggle : 'false' } });
$('body').removeClass('stealth_off').
addClass('stealth_on');
activate: function(label) {
$('#stealth_toggle').text(label).data({params: {toggle: 'false'}});
$('body').removeClass('stealth_off').addClass('stealth_on');
},

decloak: function(label) {
$('#stealth_toggle').text(label).
data({ params : { toggle : 'true' } });
$('body').removeClass('stealth_on').
addClass('stealth_off');
deactivate: function(label) {
$('#stealth_toggle').text(label).data({ params : { toggle : 'true' } });
$('body').removeClass('stealth_on').addClass('stealth_off');
},

notifyFailure: function() {
alert($('#stealth_toggle').data('failure-message'));
}
alert(RedmineStealth.failureMessage);
},

failureMessage: "Failed to toggle stealth mode."
};

$('#stealth_toggle').bind('ajax:error', RedmineStealth.notifyFailure);

});

2 changes: 0 additions & 2 deletions assets/stylesheets/stealth.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

body.stealth_on #top-menu { background: #000; }
body.stealth_on #header { background: #2C4056; }

18 changes: 2 additions & 16 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@

if Rails::VERSION::MAJOR >= 3

RedmineApp::Application.routes.draw do
post '/stealth/toggle', :to => 'stealth#toggle'
end

else

ActionController::Routing::Routes.draw do |map|
map.connect '/stealth/toggle',
:controller => 'stealth', :action => 'toggle',
:conditions => { :method => :post }
end

RedmineApp::Application.routes.draw do
post '/stealth/toggle', to: 'stealth#toggle'
end

17 changes: 1 addition & 16 deletions db/migrate/20121218194801_add_stealth_allowed_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class AddStealthAllowedToUsers < ActiveRecord::Migration

# Rails 3
def up
unless column_exists? :users, :stealth_allowed
add_column :users, :stealth_allowed, :boolean, :default => false
add_column :users, :stealth_allowed, :boolean, default: false
end
end

Expand All @@ -12,17 +10,4 @@ def down
remove_column :users, :stealth_allowed
end
end

class << self

# Rails 2
def up
add_column :users, :stealth_allowed, :boolean, :default => false
end

def down
remove_column :users, :stealth_allowed
end

end
end
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 1d20234

Please sign in to comment.