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

{{! @onWrap is recommend to be a concurrency task! see <Page::Secret::Details> in KV addon for example }}
<BasicDropdown @class="popup-menu" @horizontalPosition="auto-right" @verticalPosition="below" @onClose={{@onClose}} as |D|>
  <D.Trigger data-test-copy-menu-trigger class="toolbar-link {{if D.isOpen 'is-active'}}" @htmlTag="button">
    Copy
    <Chevron @direction={{if D.isOpen "up" "down"}} @isButton={{true}} />
  </D.Trigger>
  <D.Content @defaultClass="popup-menu-content is-wide">
    <nav class="box menu">
      <ul class="menu-list">
        <li class="action">
          <CopyButton
            @class="link"
            @clipboardText={{@clipboardText}}
            @success={{fn (set-flash-message "JSON Copied!")}}
            data-test-copy-button
          >
            Copy JSON
          </CopyButton>
        </li>
        <li class="action">
          {{#if @wrappedData}}
            <MaskedInput @class="has-padding" @displayOnly={{true}} @allowCopy={{true}} @value={{@wrappedData}} />
          {{else}}
            <button
              class="link button {{if @isWrapping 'is-loading'}}"
              type="button"
              {{on "click" @onWrap}}
              disabled={{@isWrapping}}
              data-test-wrap-button
            >
              Wrap secret
            </button>
          {{/if}}
        </li>
      </ul>
    </nav>
  </D.Content>
</BasicDropdown>