Module: ForemanDlm::DlmlockHelper

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

Instance Method Summary collapse

Instance Method Details

#dlmlock_actions(lock, authorizer) ⇒ Object



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

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



5
6
7
8
9
10
# File 'app/helpers/foreman_dlm/dlmlock_helper.rb', line 5

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



12
13
14
15
16
17
# File 'app/helpers/foreman_dlm/dlmlock_helper.rb', line 12

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

  'text-info'
end