<section class="horizontal-form container-fluid">
  <h2>
    {{t "editStack.title"}}
  </h2>

  {{form-name-description
    name=primaryResource.name
    nameDisabled=true
    nameRequired=false
    bothColClass="col span-12 mt-0"
    colClass="col span-12 mt-0"
    description=primaryResource.description
    descriptionPlaceholder="editStack.description.placeholder"
  }}

  <div class="row">
    <div class="col span-6">
      <label class="pt-20 pb-5 acc-label">
        {{t "editStack.project.label"}}
      </label>
      {{#if canMoveNamespace}}
        {{new-select
          classNames="form-control"
          optionValuePath="id"
          optionLabelPath="displayName"
          content=allProjects
          value=primaryResource.projectId
          prompt="editStack.project.prompt"
          localizedPrompt=true
        }}
      {{else}}
        <div class="pt-10">
          {{primaryResource.project.displayName}}
        </div>
      {{/if}}
    </div>
    {{#if scope.currentCluster.istioEnabled}}
      <div class="col span-6">
        <label class="pt-20 pb-5 acc-label">
          {{t "editStack.autoInject.label"}}
        </label>
        <div class="mt-5">
          {{#if istioInjection}}
            <div class="btn-group no-inline-space">
              <div class="btn btn-link btn-sm bg-success">
                {{t "generic.enabled"}}
              </div>
              <div class="btn btn-link btn-sm bg-default" {{action "toggleAutoInject"}}>
                {{t "generic.disable"}}
              </div>
            </div>
          {{else}}
            <div class="btn-group no-inline-space">
              <div class="btn btn-link btn-sm bg-default" {{action "toggleAutoInject"}}>
                {{t "generic.enable"}}
              </div>
              <div class="btn btn-link btn-sm bg-primary">
                {{t "generic.disabled"}}
              </div>
            </div>
          {{/if}}
        </div>
      </div>
    {{/if}}
  </div>

  <div class="row mt-20">
    {{#accordion-list showExpandAll=false as | al expandFn | }}
      {{#if (and primaryResource.project.resourceQuota (not switchingProject))}}
        {{#accordion-list-item
           title=(t "editStack.resourceQuota.title")
           detail=(t "editStack.resourceQuota.detail")
           expandAll=al.expandAll
           expand=(action expandFn)
           expandOnInit=true
        }}
          {{namespace-resource-quota
            editing=(or editing isNew)
            isNew=false
            expanded=expanded
            limit=primaryResource.resourceQuota.limit
            projectLimit=projectLimit
            usedLimit=projectUsedLimit
            nsDefaultQuota=nsDefaultQuota
            changed=(action "updateNsQuota")
          }}
        {{/accordion-list-item}}
      {{/if}}

      {{#accordion-list-item
         title=(t "projectsPage.containerDefaultLimit.title")
         detail=(t "projectsPage.containerDefaultLimit.detail")
         expandAll=al.expandAll
         expand=(action expandFn)
         expandOnInit=true
      }}
        {{container-default-limit
          editing=(or editing isNew)
          expanded=expanded
          limit=primaryResource.containerDefaultResourceLimit
          changed=(action "updateContainerDefault")
        }}
      {{/accordion-list-item}}

      {{form-labels-annotations
        classNames="accordion-wrapper"
        expandAll=al.expandAll
        expandFn=expandFn
        initialLabels=primaryResource.labels
        model=primaryResource
        editing=(or editing isNew)
        setLabels=(action "setLabels")
      }}
    {{/accordion-list}}
  </div>

</section>

{{top-errors errors=errors}}

{{#if (and (not initAutoInjectionStatus) istioInjection)}}
  {{banner-message
    color="bg-warning"
    message=(t "editStack.autoInject.warning")
  }}
{{/if}}

{{save-cancel
  editing=editing
  save=(action "save")
  cancel=(action "cancel")
}}
