Skip to content

Commit

Permalink
Merge pull request #94 from ATIX-AG/fix_multiple_actions
Browse files Browse the repository at this point in the history
Fix multiple actions
  • Loading branch information
sbernhard authored Dec 18, 2023
2 parents e6dcfbc + 41fcc7e commit 53ff5ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.

This file was deleted.

16 changes: 16 additions & 0 deletions app/helpers/foreman_snapshot_management/hosts_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module ForemanSnapshotManagement
module HostsHelper
def snapshot_multiple_actions
return [] unless can_create_snapshots?
[{ action: [_('Create Snapshot'), select_multiple_host_snapshots_path], priority: 1000 }]
end

private

def can_create_snapshots?
User.current.can?(:create_snapshots)
end
end
end
8 changes: 4 additions & 4 deletions lib/foreman_snapshot_management/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Engine < ::Rails::Engine

config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]

initializer 'foreman_snapshot_management.register_plugin', before: :finisher_hook do |_app|
Foreman::Plugin.register :foreman_snapshot_management do
Expand Down Expand Up @@ -65,6 +64,10 @@ class Engine < ::Rails::Engine
:partial => 'hosts/snapshots_tab',
:onlyif => proc { |host| host&.uuid.present? && host&.compute_resource&.capable?(:snapshots) }
end

describe_host do
multiple_actions_provider :snapshot_multiple_actions
end
end
end

Expand All @@ -86,9 +89,6 @@ class Engine < ::Rails::Engine

# Include concerns in this config.to_prepare block
config.to_prepare do
# Load Foreman extensions
::HostsHelper.prepend ForemanSnapshotManagement::HostsHelperExtension

begin
::ForemanFogProxmox::Proxmox.prepend ForemanSnapshotManagement::ProxmoxExtensions

Expand Down

0 comments on commit 53ff5ab

Please sign in to comment.