{{page-title (concat "Deployment" " v" @model.sequence)}}
{{#if (not-eq this.target.currentRouteName "workspace.projects.project.app.deployments.deployment.resource")}}
  <PanelHeader @artifact="deployment" @sequence={{@model.sequence}}>
    <:actions>
      <div class="button-group">
        {{#if @model.preload.deployUrl}}
          <ExternalLink
            href={{enforce-protocol @model.preload.deployUrl}}
            class="button button--secondary button--external-link">
            <span>{{lowercase @model.preload.deployUrl}}</span>
            <FlightIcon @name="external-link" class="icon" />
          </ExternalLink>
        {{/if}}
        <Actions::Release @sequence={{@model.sequence}} />
      </div>
    </:actions>
  </PanelHeader>

  <div class="grid grid--overview-timeline">
    <Section @isExpandable={{false}}>
        <:heading>{{t "page.artifact.overview.heading"}}</:heading>
        <:body>
          <StatusReportMetaTable @model={{@model}} @artifactType="Deployment">
            <tr>
              <th scope="row">{{t "page.artifact.overview.status"}}</th>
              <td>
                <OperationStatusIndicator::Deployment @operation={{@model}} />
              </td>
            </tr>
          </StatusReportMetaTable>
        </:body>
      </Section>
      {{#if @model.timeline}}
        <Section @isExpandable={{false}}>
          <:heading>{{t "page.artifact.timeline.heading"}}</:heading>
          <:body>
            <Timeline @model={{@model.timeline}} />
          </:body>
        </Section>
      {{/if}}
  </div>

  {{#let
    @model.statusReport.resourcesList
    @model.release.statusReport.resourcesList
    as |deploymentResources releaseResources|
  }}
    {{#if (or deploymentResources.length releaseResources.length)}}
      <Section>
        <:heading>{{t "page.deployment.resources.heading"}}</:heading>
        <:body>
          {{#if deploymentResources.length}}
            <ResourcesTable
              @resources={{deploymentResources}}
              @route="workspace.projects.project.app.deployments.deployment.resource"
              @models={{array @model.sequence}}
              @withMargin={{true}}
            >
              <:caption>
                {{t "page.deployment.resources.deployment-table-caption" htmlSafe=true}}
              </:caption>
            </ResourcesTable>
          {{/if}}

          {{#if releaseResources.length}}
            <ResourcesTable
              @resources={{releaseResources}}
              @route="workspace.projects.project.app.release.resource"
              @models={{array @model.release.sequence}}
            >
              <:caption>
                {{t "page.deployment.resources.release-table-caption-prefix" htmlSafe=true}}
                <LinkTo
                  @route="workspace.projects.project.app.release"
                  @model={{@model.release.sequence}}
                >
                  <b class="badge badge--info badge--version">v{{@model.release.sequence}}</b>
                </LinkTo>
              </:caption>
            </ResourcesTable>
          {{/if}}
        </:body>
      </Section>
    {{/if}}
  {{/let}}

  <Section>
    <:heading>{{t "page.deployment.logs.heading"}}</:heading>
    <:body>
      <OperationLogs @jobId={{@model.jobId}} />
    </:body>
  </Section>
{{/if}}
{{outlet}}
