<PageHeader as |p|>
  <p.levelLeft>
    <h1 class="title is-3">
      Rewrap token
    </h1>
  </p.levelLeft>
</PageHeader>

{{#if @rewrap_token}}
  <div class="box is-sideless is-fullwidth is-marginless">
    <div class="field">
      <label for="wrap-info" class="is-label">Rewrapped token</label>
      <div class="control">
        <Textarea
          @value={{@rewrap_token}}
          readonly={{true}}
          class="textarea"
          id="wrap-info"
          name="wrap-info"
          data-test-tools-input="rewrapped-token"
        />
      </div>
    </div>
  </div>
  <div class="field is-grouped box is-fullwidth is-bottomless">
    <div class="control">
      <CopyButton
        @clipboardText={{@rewrap_token}}
        @class="button is-primary"
        @buttonType="button"
        @success={{action (set-flash-message "Token copied!")}}
      >
        Copy
      </CopyButton>
    </div>
    <div class="control">
      <button {{on "click" this.onClear}} type="button" class="button">
        Back
      </button>
    </div>
  </div>
{{else}}
  <div class="box is-sideless is-fullwidth is-marginless">
    <NamespaceReminder @mode="perform" @noun={{@selectedAction}} />
    <MessageError @errors={{@errors}} />
    <div class="field">
      <label for="token" class="is-label">Wrapped token</label>
      <div class="has-text-grey is-size-8 has-bottom-margin-xs">
        Enter your wrapped token here to rewrap it and refresh its TTL.
      </div>
      <div class="control">
        <Input @value={{@token}} class="input" id="token" name="token" data-test-tools-input="wrapping-token" />
      </div>
    </div>
  </div>
  <div class="field is-grouped box is-fullwidth is-bottomless">
    <div class="control">
      <button type="submit" data-test-tools-submit="true" class="button is-primary">
        Rewrap token
      </button>
    </div>
  </div>
{{/if}}