Module: ForemanPatch::PatchingHelper
- Defined in:
- app/helpers/foreman_patch/patching_helper.rb
Instance Method Summary collapse
- #invocation_task_buttons(task, invocation) ⇒ Object
- #patch_invocation_actions(round, invocation) ⇒ Object
- #round_hosts_authorizer ⇒ Object
- #round_invocation_hosts(round) ⇒ Object
- #round_task_buttons(task) ⇒ Object
Instance Method Details
#invocation_task_buttons(task, invocation) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/helpers/foreman_patch/patching_helper.rb', line 89 def (task, invocation) = [] if task.present? && (permission: :view_foreman_tasks, auth_object: task) << link_to(_('Task Details'), main_app.foreman_tasks_task_path(task), class: 'btn btn-default', title: _('See the task details')) end #if authorized_for... eventually if task.present? << link_to(_('Cancel Patch'), main_app.cancel_foreman_tasks_task_path(task), class: 'btn btn-danger', title: _('Try to cancel the patch of the host'), disabled: !task.cancellable?, method: :post) << link_to(_('Abort Patch'), main_app.abort_foreman_tasks_task_path(task), class: 'btn btn-danger', title: _('Try to abort the patching of the host without waiting for its result'), disabled: !task.cancellable?, method: :post) end #end end |
#patch_invocation_actions(round, invocation) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/foreman_patch/patching_helper.rb', line 8 def patch_invocation_actions(round, invocation) host = invocation.host task = invocation.task links = [] if (main_app.hash_for_host_path(host).merge(auth_object: host, permission: :view_hosts, authorizer: )) links << { title: _('Host Detail'), action: { href: main_app.host_path(host), 'data-method': 'get', id: "#{host.name}-actions-detail" } } end if task.present? && (main_app.hash_for_foreman_tasks_task_path(task).merge(auth_object: task, permission: :view_foreman_tasks)) links << { title: _('Task Detail'), action: { href: main_app.foreman_tasks_task_path(task), 'data-method': 'get', id: "#{host.name}-actions-task" } } end unless task.present? links << { title: _('Cancel'), action: { href: invocation_path(invocation), 'data-method': 'delete', id: "#{host.name}-actions-cancel" } } end if task.present? and task.pending? links << { title: _('Cancel'), action: { href: main_app.cancel_foreman_tasks_task_path(task), 'data-method': 'post', id: "#{host.name}-actions-cancel" } } links << { title: _('Abort'), action: { href: main_app.abort_foreman_tasks_task_path(task), 'data-method': 'post', id: "#{host.name}-actions-abort" } } end links end |
#round_hosts_authorizer ⇒ Object
4 5 6 |
# File 'app/helpers/foreman_patch/patching_helper.rb', line 4 def @round_hosts_authorizer ||= Authorizer.new(User.current, collection: @hosts) end |
#round_invocation_hosts(round) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/foreman_patch/patching_helper.rb', line 52 def round_invocation_hosts(round) round.invocations.map do |invocation| { name: invocation.host.name, link: invocation_path(invocation), state: invocation.state, result: invocation.result, actions: patch_invocation_actions(round, invocation) } end end |
#round_task_buttons(task) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/foreman_patch/patching_helper.rb', line 64 def (task) = [] if (permission: :view_foreman_tasks, auth_object: task, authorizer: Authorizer.new(User.current, collection: [task])) << link_to(_('Task Details'), main_app.foreman_tasks_task_path(task), class: 'btn btn-default', title: _('See the task details')) end # if authorized << link_to(_('Cancel'), main_app.cancel_foreman_tasks_task_path(task), class: 'btn btn-danger', title: _('Try to cancel the patching round'), disabled: !task.cancellable?, method: :post) << link_to(_('Abort'), main_app.abort_foreman_tasks_task_path(task), class: 'btn btn-danger', title: _('Try to abort the patching round without waiting for its result'), disabled: !task.cancellable?, method: :post) # end end |