metaps/genova

View on GitHub
app/views/deploy_jobs/index.html.erb

Summary

Maintainability
Test Coverage
<div class="container">
  <h2 class="title">Deploy jobs</h2>
  <form>
    <div class="columns">
      <div class="column is-7">
        <div class="control has-icons-left">
          <input class="input" type="text" name="keywords" placeholder="Example: cluster:production,status:success" value="<%= params[:keywords] %>">
          <span class="icon is-left">
            <i class="fa-solid fa-magnifying-glass"></i>
          </span>
        </div>
      </div>
      <div class="column is-4">
        <input type="date" name="dates">
      </div>
      <div class="column is-1">
        <input type="submit" value="Search" class="button">
      </div>
    </div>
  </form>
  <% if @deploy_jobs.size > 0 %>
    <table class="table is-fullwidth is-hoverable is-striped has-text-centered">
      <thead>
        <th>ID</th>
        <th>Status</th>
        <th>Repository</th>
        <th>Branch/Tag</th>
        <th>Commit</th>
        <th>Mode</th>
        <th>Type</th>
        <th>Cluster</th>
        <th>Created at</th>
      </thead>
      <tbody>
        <% @deploy_jobs.each do |deploy_job| %>
          <tr>
            <td><%= link_to(deploy_job.id, deploy_job_path(deploy_job.id)) %></td>
            <td>
              <% if deploy_job.status == 'success' %>
                <i class="fa fa-check-circle"></i>
              <% elsif ['initial', 'provisioning', 'deploying', 'reserved_cancel'].include?(deploy_job.status) %>
                <i class="fa fa-spinner fa-spin"></i>
              <% elsif deploy_job.status == 'failure' %>
                <i class="fa fa-exclamation-triangle"></i>
              <% elsif deploy_job.status == 'cancel' %>
                <i class="fa fa-times-circle"></i>
              <% end %>
              <%= deploy_job.status %>
            </td>
            <td><%= deploy_job.repository %></td>
            <td>
              <% if deploy_job.branch.present? %>
                <%= deploy_job.branch.truncate(20) %>
              <% else %>
                refs/tags/<%= deploy_job.tag.truncate(20) %>
              <% end %>
            </td>
            <td>
              <% if deploy_job.commit_id.present? %>
                <i class="fab fa-github"></i>
                <%= link_to(deploy_job.commit_id[0, 7], Genova::Github::Client.new(deploy_job.repository).build_commit_uri(deploy_job.commit_id)) %>
              <% end %>
            </td>
            <td><%= deploy_job.mode %></td>
            <td><%= type_tag(deploy_job.type).html_safe %></td>
            <td><%= deploy_job.cluster %></td>
            <td><%= deploy_job.created_at %></td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <nav class="pagination is-right" role="navigation">
      <ul class="pagination-list">
        <%= paginate @deploy_jobs %>
      </ul>
    </div>
  <% else %>
    <p>No data found.</p>
  <% end %>
</div>