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

<h1 class="title with-flex">
  <div data-test-job-name>
    {{or this.title this.job.name}}
    {{#if @job.meta.structured.pack}}
      <span data-test-pack-tag class="tag is-hollow">
        {{x-icon "box" class= "test"}}
        <span>Pack</span>
      </span>
    {{/if}}
    {{yield}}
  </div>
  <div>
    {{#if (not (eq this.job.status "dead"))}}
      <div class="two-step-button">
        <Exec::OpenButton @job={{this.job}} />
      </div>
      <TwoStepButton
        data-test-stop
        @alignRight={{true}}
        @idleText="Stop Job"
        @cancelText="Cancel"
        @confirmText="Yes, Stop Job"
        @confirmationMessage="Are you sure you want to stop this job?"
        @awaitingConfirmation={{this.stopJob.isRunning}}
        @onConfirm={{perform this.stopJob}}
        {{keyboard-shortcut 
          label="Stop"
          pattern=(array "s" "t" "o" "p")
          action=(perform this.stopJob true)
        }} />
    {{else}}
      <TwoStepButton
        data-test-purge
        @alignRight={{true}}
        @idleText="Purge Job"
        @cancelText="Cancel"
        @confirmText="Yes, Purge Job"
        @confirmationMessage="Are you sure? You cannot undo this action."
        @awaitingConfirmation={{this.purgeJob.isRunning}}
        @onConfirm={{perform this.purgeJob}}
        {{keyboard-shortcut 
          label="Purge"
          pattern=(array "p" "u" "r" "g" "e")
          action=(perform this.purgeJob)
        }}
        />
      <TwoStepButton
        data-test-start
        @alignRight={{true}}
        @idleText="Start Job"
        @cancelText="Cancel"
        @confirmText="Yes, Start Job"
        @confirmationMessage="Are you sure you want to start this job?"
        @awaitingConfirmation={{this.startJob.isRunning}}
        @onConfirm={{perform this.startJob}}
        {{keyboard-shortcut 
          label="Start"
          pattern=(array "s" "t" "a" "r" "t")
          action=(perform this.startJob true)
        }}
        />
    {{/if}}
  </div>
</h1>
