Module: ForemanDlm::DlmlockHelper

Defined in:
app/helpers/foreman_dlm/dlmlock_helper.rb

Instance Method Summary collapse

Instance Method Details

#dlmlock_actions(lock, authorizer) ⇒ Object



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
# File 'app/helpers/foreman_dlm/dlmlock_helper.rb', line 15

def dlmlock_actions(lock, authorizer)
  actions = []

  if lock.enabled?
    actions << display_link_if_authorized(
      _('Disable'),
      hash_for_disable_foreman_dlm_dlmlock_path(:id => lock.to_param).merge(auth_object: lock, authorizer: authorizer),
      method: :put
    )
  end

  if lock.disabled?
    actions << display_link_if_authorized(
      _('Enable'),
      hash_for_enable_foreman_dlm_dlmlock_path(:id => lock.to_param).merge(auth_object: lock, authorizer: authorizer),
      method: :put
    )
  end

  if lock.taken?
    actions << display_link_if_authorized(
      _('Release'),
      hash_for_release_foreman_dlm_dlmlock_path(:id => lock.to_param).merge(auth_object: lock, authorizer: authorizer),
      method: :put
    )
  end

  actions << display_delete_if_authorized(hash_for_foreman_dlm_dlmlock_path(:id => lock.to_param).merge(auth_object: lock, authorizer: authorizer), class: 'delete')
  actions
end

#dlmlock_status_icon_class(lock) ⇒ Object



3
4
5
6
7
# File 'app/helpers/foreman_dlm/dlmlock_helper.rb', line 3

def dlmlock_status_icon_class(lock)
  return 'ban' if lock.disabled?
  return 'lock' if lock.taken?
  'unlock'
end

#dlmlock_status_icon_color_class(lock) ⇒ Object



9
10
11
12
13
# File 'app/helpers/foreman_dlm/dlmlock_helper.rb', line 9

def dlmlock_status_icon_color_class(lock)
  return 'text-danger' if lock.disabled?
  return 'text-success' if lock.taken?
  'text-info'
end