63 lines
3.5 KiB
Plaintext
63 lines
3.5 KiB
Plaintext
<div class="card text-white bg-dark p-2 m-4 rounded-2 <%= key.css_class %>" style="min-width: 20rem; max-width: 75rem;" data-apikey-id="<%= key.id %>">
|
|
<div class="card-body">
|
|
<% if CurrentUser.is_manager? %>
|
|
<div class="owner mb-2">
|
|
<% if key.owner.avatar.attached? %>
|
|
<%= image_tag(key.owner.avatar, width: 30, height: 30, class: "rounded-4") %>
|
|
<% end %>
|
|
<span><%= key.owner.name %></span>
|
|
</div>
|
|
<% end %>
|
|
<h5 class="card-title apikey-application"><%= key.application_name %></h5>
|
|
<p class="card-text apikey-usage"><%= key.usage %></p>
|
|
|
|
<h5>Services</h5>
|
|
<p class="card-text apikey-services" title="Ask a developer to gain access to bulk images, or have your limits raised."><%= key.access_string %></p>
|
|
<% if key.disabled? %>
|
|
<h5>Disabled</h5>
|
|
<p><%= key.disabled_reason || "No Reason Provided" %></p>
|
|
<% end %>
|
|
<% unless key.active? %>
|
|
<h5>Inactive</h5>
|
|
<% end %>
|
|
|
|
<div class="btn-group dropend">
|
|
<% if key.can_view?(CurrentUser) %>
|
|
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#apikeyViewModal<%= key.id %>">View</button>
|
|
<% end %>
|
|
<% if key.can_edit?(CurrentUser) %>
|
|
<% if CurrentUser.is_admin? %>
|
|
<%= link_to "Edit", edit_yiff_rest_apikey_path(key), class: "btn btn-success" %>
|
|
<% else %>
|
|
<button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#apikeyEditModal<%= key.id %>">Edit</button>
|
|
<% end %>
|
|
<% end %>
|
|
<% if key.can_delete?(CurrentUser) %>
|
|
<button class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#apikeyDeleteModal<%= key.id %>">Delete</button>
|
|
<% end %>
|
|
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<span class="visually-hidden">Toggle Dropright</span>
|
|
</button>
|
|
<ul class="dropdown-menu dropdown-menu-dark" id="more-dropdown-">
|
|
<% if key.can_disable?(CurrentUser) %>
|
|
<% if key.disabled? %>
|
|
<li><%= link_to "Enable", enable_yiff_rest_apikey_path(key), method: :put, data: { confirm: "Are you sure?" }, class: "dropdown-item" %></li>
|
|
<% else %>
|
|
<li><%= link_to "Disable", disable_yiff_rest_apikey_path(key), data: { "bs-toggle": "modal", "bs-target": "#apikeyDisableModal#{key.id}" }, class: "dropdown-item" %></li>
|
|
<% end %>
|
|
<% end %>
|
|
<% if key.can_deactivate?(CurrentUser) %>
|
|
<% if key.active? %>
|
|
<li><%= link_to "Deactivate", deactivate_yiff_rest_apikey_path(key), method: :put, data: { confirm: "Are you sure? This will cause any requests using this key to be rejected." }, class: "dropdown-item" %></li>
|
|
<% else %>
|
|
<li><%= link_to "Reactivate", reactivate_yiff_rest_apikey_path(key), method: :put, data: { confirm: "Are you sure?" }, class: "dropdown-item" %></li>
|
|
<% end %>
|
|
<% end %>
|
|
<% if key.can_regenerate?(CurrentUser) %>
|
|
<li><%= link_to "Regenerate", regenerate_yiff_rest_apikey_path(key), method: :put, data: { confirm: "Are you sure? This will make the old key invalid." }, class: "dropdown-item" %></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|