Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple actions #94

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading