_trigger.html.haml 2.3 KB
Newer Older
D
Douwe Maan 已提交
1 2
%tr
  %td
K
Kamil Trzciński 已提交
3 4
    - if can?(current_user, :admin_trigger, trigger)
      %span= trigger.token
D
Douwe Maan 已提交
5
      = clipboard_button(text: trigger.token, title: "Copy trigger token to clipboard")
K
Kamil Trzciński 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    - else
      %span= trigger.short_token

    .label-container
      - if trigger.legacy?
        %span.label.label-primary.has-tooltip{ title: "Trigger makes use of deprecated functionality" } legacy
      - if !trigger.can_access_project?
        %span.label.label-danger.has-tooltip{ title: "Trigger user has insufficient permissions to project" } invalid

  %td
    - if trigger.description? && trigger.description.length > 15
      %span.has-tooltip{ title: trigger.description }= truncate(trigger.description, length: 15)
    - else
      = trigger.description

  %td
    - if trigger.owner
      .trigger-owner.sr-only= trigger.owner.name
      = user_avatar(user: trigger.owner, size: 20)
D
Douwe Maan 已提交
25 26

  %td
K
Kamil Trzciński 已提交
27 28
    - if trigger.last_used
      #{time_ago_in_words(trigger.last_used)} ago
D
Douwe Maan 已提交
29 30 31
    - else
      Never

S
Shinya Maeda 已提交
32
  %td
K
Kamil Trzcinski 已提交
33
    - if trigger.trigger_schedule&.active?
S
Shinya Maeda 已提交
34 35
      = trigger.trigger_schedule.real_next_run
    - else
K
Kamil Trzcinski 已提交
36
      None
S
Shinya Maeda 已提交
37

K
Kamil Trzciński 已提交
38 39 40 41 42 43 44 45 46 47 48
  %td.text-right.trigger-actions
    - take_ownership_confirmation = "By taking ownership you will bind this trigger to your user account. With this the trigger will have access to all your projects as if it was you. Are you sure?"
    - revoke_trigger_confirmation = "By revoking a trigger you will break any processes making use of it. Are you sure?"
    - if trigger.owner != current_user && can?(current_user, :manage_trigger, trigger)
      = link_to 'Take ownership', take_ownership_namespace_project_trigger_path(@project.namespace, @project, trigger), data: { confirm: take_ownership_confirmation }, method: :post, class: "btn btn-default btn-sm btn-trigger-take-ownership"
    - if can?(current_user, :admin_trigger, trigger)
      = link_to edit_namespace_project_trigger_path(@project.namespace, @project, trigger), method: :get, title: "Edit", class: "btn btn-default btn-sm" do
        %i.fa.fa-pencil
    - if can?(current_user, :manage_trigger, trigger)
      = link_to namespace_project_trigger_path(@project.namespace, @project, trigger), data: { confirm: revoke_trigger_confirmation }, method: :delete, title: "Revoke", class: "btn btn-default btn-warning btn-sm btn-trigger-revoke" do
        %i.fa.fa-trash