{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

<Page::Header @title="Secrets recovery" class="bottom-margin-16">
  <:breadcrumbs>
    <Page::Breadcrumbs @breadcrumbs={{@breadcrumbs}} />
  </:breadcrumbs>
  <:badges>
    {{#if @model.showCommunityMessage}}
      <Hds::Badge @text="Enterprise" @color="highlight" data-test-badge="enterprise" />
    {{/if}}
  </:badges>
  <:description>
    Restore specific secrets from cluster snapshots without impacting the availability of the active Vault cluster.
    <Hds::Link::Inline @isHrefExternal={{true}} @href={{doc-link "/vault/gui/recover-secrets"}}>
      Learn more
    </Hds::Link::Inline>
  </:description>
</Page::Header>

{{#if @model.snapshots.showRaftStorageMessage}}
  <Hds::ApplicationState class="top-padding-32 is-marginless" as |A|>
    <A.Header @title="Raft storage required" @icon="info" @titleTag="h2" data-test-empty-state-title />
    <A.Body @text="Raft storage must be used in order to recover data from a snapshot." data-test-empty-state-message />
    <A.Footer data-test-empty-state-actions as |F|>
      <F.LinkStandalone
        @text="Snapshot management"
        @icon="docs-link"
        @iconPosition="trailing"
        @href={{doc-link "/vault/docs/sysadmin/snapshots"}}
        @isHrefExternal={{true}}
      />
    </A.Footer>
  </Hds::ApplicationState>
{{else}}
  {{#if @model.showCommunityMessage}}
    <Hds::ApplicationState class="top-padding-32 is-marginless" as |A|>
      <A.Header
        @title="Secrets Recovery is an enterprise feature"
        @icon="sync-reverse"
        @titleTag="h2"
        data-test-empty-state-title
      />
      <A.Body
        @text="Secrets Recovery allows you to restore accidentally deleted or lost secrets from a snapshot. The snapshots can be provided via upload or loaded from external storage."
        data-test-empty-state-message
      />
      <A.Footer data-test-empty-state-actions as |F|>
        <F.LinkStandalone
          @text="Learn more about upgrading"
          @icon="docs-link"
          @iconPosition="trailing"
          @href={{doc-link "/vault/docs/enterprise"}}
          @isHrefExternal={{true}}
        />
      </A.Footer>
    </Hds::ApplicationState>
  {{else if (not @model.snapshots)}}
    {{! Currently, only a single snapshot is supported and the UI automatically redirects users to "recovery.snapshots.snapshot.manage" if one exists.
  In the future, this may change to support multiple loaded snapshots and a LIST view will be built then. }}
    {{#let (get this.emptyStateDetails this.state) as |d|}}
      <Hds::Separator />

      <Hds::ApplicationState class="is-marginless" as |A|>
        <A.Header @title={{d.title}} @icon={{d.icon}} @titleTag="h2" data-test-empty-state-title />
        <A.Body @text={{d.message}} data-test-empty-state-message />
        <A.Footer data-test-empty-state-actions as |F|>
          {{#if (eq this.state this.viewState.ALLOW_UPLOAD)}}
            <F.Button @text={{d.buttonText}} @color={{d.buttonColor}} @route="vault.cluster.recovery.snapshots.load" />
          {{else}}
            <F.Button
              @text={{d.buttonText}}
              @color={{d.buttonColor}}
              @icon={{d.buttonIcon}}
              @iconPosition="trailing"
              @route={{d.buttonRoute}}
              @query={{if d.buttonRoute (hash namespace="")}}
              @href={{doc-link d.buttonHref}}
              @isHrefExternal={{if d.buttonHref true}}
            />
          {{/if}}
        </A.Footer>
      </Hds::ApplicationState>
    {{/let}}
  {{/if}}
{{/if}}