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

<div class="action-block is-rounded" data-test-generate-token-replication>
  <div class="action-block-info">
    <h4 class="title is-5 is-marginless">
      Generate operation token
    </h4>
    <p>
      This token is needed for update and promote actions.
    </p>
  </div>

  <div class="action-block-action">
    <button
      type="button"
      class="button is-tertiary"
      onclick={{action (mut this.isModalActive) true}}
      data-test-replication-action-trigger
    >
      Generate token
    </button>
  </div>
</div>

<Modal
  @title="Generate operation token"
  @onClose={{action (mut this.isModalActive) false}}
  @isActive={{this.isModalActive}}
  @type="warning"
  @showCloseButton={{true}}
>
  {{#if this.isModalActive}}
    {{! Wrapped in if statement so the Shamir constructor fires on modal open }}
    <Shamir::DrTokenFlow @action="generate-dr-operation-token" @onCancel={{action (mut this.isModalActive) false}} />
    {{! Section & Footer is in child component since the form must do side effects on cancel }}
  {{/if}}
</Modal>