<section>

  {{#if isEnabled}}
      <BannerMessage
        @color="bg-info"
        @icon="icon-info"
        @message={{t "authPage.googleoauth.warning.doc" htmlSafe=true}}
      />

    {{else}}
       <BannerMessage
      @color="bg-warning"
      @icon="icon-alert"
      @message={{t "authPage.googleoauth.header.disabled.label" htmlSafe=true}}
    />
  {{/if}}
  {{top-errors
    errors=errors
  }}
</section>

{{#unless isEnabled}}
  <FormGoogleAuth
    @save={{action "save"}}
    @cancel={{action "cancel"}}
    @authConfig={{authConfig}}
    @saving={{saving}}
    @doneSaving={{doneSaving}}
  />
{{/unless}}

{{#accordion-list
  showExpandAll=false
  as |al expandFn|
}}
  {{#if isEnabled}}
    {{#accordion-list-item
      expand=(action expandFn)
      expandAll=al.expandAll
      expandOnInit=true
      expanded=true
      showExpand=false
      title=(t "authPage.googleoauth.authenticated.header.text")
    }}
      <section class="">
        <div class="clearfix">
          <div class="pull-right">
            <button class="btn btn-sm bg-primary" {{action "edit"}}>
              {{t "generic.edit"}}
            </button>
            <button class="btn btn-sm right-divider-btn bg-error" {{action "disable"}}>
              {{t "authPage.googleoauth.authenticated.disableAccess.disable"}}
            </button>
          </div>
        </div>
        <hr />
        <FormGoogleAuthRead
          @authConfig={{model.originalConfig}}
        />
        {{#if editing}}
          <FormGoogleAuth
            @save={{action "save"}}
            @cancel={{action "cancel"}}
            @authConfig={{authConfig}}
            @saving={{saving}}
            @doneSaving={{doneSaving}}
            @isEnabled={{isEnabled}}
          />
        {{/if}}
      </section>
    {{/accordion-list-item}}
  {{/if}}

  {{#if isEnabled}}
    {{#accordion-list-item
         classNames="mt-30"
         detail=(t "siteAccess.helpText" appName=settings.appName htmlSafe=true)
         expand=(action expandFn)
         expandAll=al.expandAll
         expandOnInit=true
         expanded=true
         showExpand=false
         title=(t "siteAccess.header")
    }}
      {{site-access
        model=authConfig
        principals=model.principals
        collection="siteAccess.organizations"
      }}
    {{/accordion-list-item}}
  {{/if}}
{{/accordion-list}}