Skip to content

Commit

Permalink
Merge pull request #22 from opf/13.1-changes
Browse files Browse the repository at this point in the history
Changes to make the plugin compatible with 13.1
  • Loading branch information
oliverguenther authored Dec 14, 2023
2 parents cf37ee9 + c612eff commit cc663f3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/views/homescreen/blocks/_homescreen_block.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ul>

<div class="widget-box--blocks--buttons">
<% if User.current.allowed_to?(:manage_kittens, nil, global: true) %>
<% if User.current.allowed_in_any_project?(:manage_kittens) %>
<%= link_to new_kitten_plugin_project_kitten_path(project_id: Project.first.identifier), {
class: 'button -alt-highlight',
aria: {label: t(:label_kitten_new)},
Expand Down
2 changes: 1 addition & 1 deletion app/views/kittens/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= toolbar(title: t(:label_kittens)) do %>
<% if current_user.allowed_to?(:manage_kittens, @project, global: @project.nil?) %>
<% if (@project.present? && current_user.allowed_in_project?(:manage_kittens, @project)) || (@project.nil? && current_user.allowed_in_any_project?(:manage_kittens)) %>
<li class="toolbar-item">
<%= link_to(new_kitten_plugin_project_kitten_path, class: 'button') do %>
<span class="button--text"><%= t(:label_kitten_new) %></span>
Expand Down
16 changes: 11 additions & 5 deletions lib/open_project/proto_plugin/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Engine < ::Rails::Engine
register(
'openproject-proto_plugin',
:author_url => 'https://openproject.org',
:requires_openproject => '>= 6.0.0'
:requires_openproject => '>= 13.1.0'
) do
# We define a new project module here for our controller including a permission.
# The permission is necessary for us to be able to add menu items to the project
Expand All @@ -23,12 +23,18 @@ class Engine < ::Rails::Engine
# settings before you can see the menu entry.
project_module :kittens_module do
permission :view_kittens,
kittens: %i[index],
angular_kittens: %i[show]
{
kittens: %i[index],
angular_kittens: %i[show]
},
permissible_on: [:project]

permission :manage_kittens,
kittens: %i[new create edit destroy],
angular_kittens: %i[show]
{
kittens: %i[new create edit destroy],
angular_kittens: %i[show]
},
permissible_on: [:project]
end

menu :project_menu,
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/kittens_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

require 'spec_helper'

describe KittensController, type: :controller do
RSpec.describe KittensController, type: :controller do
let(:user) { FactoryBot.create :admin }
let(:project) { FactoryBot.create :project }

Expand Down
5 changes: 2 additions & 3 deletions spec/features/project_kittens_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
# js:true will enable a JS-compatible browser (Chrome by default)
#
# Testing is done with Capybara and Selenium
describe 'Project kittens', type: :feature, js: true do
RSpec.describe 'Project kittens', type: :feature, js: true do
let(:permissions) { %w[view_kittens manage_kittens] }
let(:project) { FactoryBot.create :project, enabled_module_names: %w[kittens_module] }
let(:user) do
FactoryBot.create :user,
member_in_project: project,
member_with_permissions: permissions
member_with_permissions: { project => permissions }
end

before do
Expand Down

0 comments on commit cc663f3

Please sign in to comment.