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

<div>
  <JobEditor::Alert 
    @data={{merge (hash error=this.error stage=this.stage) this.data}}
    @fns={{this.fns}}
  />

    {{#if (eq @context "new")}}
      <header class="run-job-header">
        <h1 class="title is-3">Run a job</h1>
        <p>
          Paste or author HCL or JSON to submit to your cluster, or select from a list of templates. A plan will be requested before the job is submitted. You can also attach a job spec by uploading a job file or dragging &amp; dropping a file to the editor.
        </p>

        {{#if (can "write variable" path="*" namespace="*")}}
          <Hds::ButtonSet>
            <label
              class="job-spec-upload hds-button hds-button--color-secondary hds-button--size-medium"
            >
              <div class="hds-button__text">Upload file</div>
              <input
                type="file"
                onchange={{action this.uploadJobSpec}}
                accept=".hcl,.json,.nomad"
              />
            </label>
            <Hds::Button
              @text="Choose from template"
              @color="secondary"
              @route="jobs.run.templates"
              data-test-choose-template
            />
          </Hds::ButtonSet>
        {{/if}}

      </header>
    {{/if}}
    {{did-update this.setDefinitionOnModel this.definition}}
    {{component (concat 'job-editor/' this.stage) data=this.data fns=this.fns}}
</div>
