{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: MPL-2.0
~}}

<div
  class="allocation-status-block {{unless this.countToShow "rest-only"}}"
  style={{html-safe (concat "width: " @width "px")}}
>
  {{#if this.countToShow}}
    <div class="ungrouped-allocs">
      {{#each (range 0 this.countToShow) as |i|}}
        <JobStatus::IndividualAllocation
          @allocation={{get @allocs i}}
          @status={{@status}}
          @health={{@health}}
          @canary={{@canary}}
          @steady={{@steady}}
        />
      {{/each}}
    </div>
  {{/if}}
  {{#if this.remaining}}

    <ConditionalLinkTo
      @condition={{not (eq @status "unplaced")}}
      @route="jobs.job.allocations"
      @model={{@allocs.0.job}}
      @query={{hash status=(concat '["' @status '"]') version=(concat '[' @allocs.0.jobVersion ']')}}
      @class="represented-allocation rest {{@status}} {{@health}} {{@canary}}"
      @label="View all {{@status}} allocations"
    >
      <span class="rest-count">{{#if this.countToShow}}+{{/if}}{{this.remaining}}</span>
      {{#unless @steady}}
        {{#if (eq @canary "canary")}}
          <span class="alloc-canary-indicator" />
        {{/if}}
        {{#if (eq @status "running")}}
          <span class="alloc-health-indicator">
            {{#if (eq @health "healthy")}}
              <FlightIcon @name="check" @color="#25ba81" />
            {{else if (eq @health "unhealthy")}}
              <FlightIcon @name="x" @color="#c84034" />
            {{else}}
              <FlightIcon @name="running" @color="black" />
            {{/if}}
          </span>
        {{/if}}
      {{/unless}}
    </ConditionalLinkTo>
  {{/if}}
</div>