{{#if (eq @mode "edit")}}
  <form onsubmit={{action "onSaveChanges"}} data-test-clients-config-form>
    <div class="box is-sideless is-fullwidth is-marginless">
      <MessageError @model={{@model}} @errorMessage={{this.error}} />
      {{#each @model.formFields as |attr|}}
        {{#if (eq attr.name "enabled")}}
          <label class="is-label">Usage data collection</label>
          <p class="sub-text">
            Enable or disable client tracking. Keep in mind that disabling tracking will delete the data for the current
            month.
          </p>
          <div class="control is-flex has-bottom-margin-l">
            <input
              data-test-input="enabled"
              type="checkbox"
              id="enabled"
              name="enabled"
              class="switch is-rounded is-success is-small"
              disabled={{@model.reportingEnabled}}
              checked={{eq @model.enabled "On"}}
              {{on "change" this.toggleEnabled}}
            />
            <label for="enabled">
              Data collection is
              {{lowercase @model.enabled}}
            </label>
          </div>
        {{else}}
          <FormField @attr={{attr}} @model={{@model}} @modelValidations={{this.validations}} />
        {{/if}}
      {{/each}}
    </div>
    <div class="field is-grouped-split box is-fullwidth is-bottomless">
      <div class="control">
        <button type="submit" disabled={{this.buttonDisabled}} class="button is-primary" data-test-clients-config-save>
          Save
        </button>
        <LinkTo @route="vault.cluster.clients.config" class="button">
          Cancel
        </LinkTo>
      </div>
    </div>
  </form>

  <Modal
    @title={{this.modalTitle}}
    @onClose={{action (mut this.modalOpen) false}}
    @isActive={{this.modalOpen}}
    @type="warning"
    @showCloseButton={{true}}
  >
    <section class="modal-card-body">
      {{#if (eq @model.enabled "On")}}
        <p class="has-bottom-margin-s" data-test-clients-config-modal="on">
          Vault will start tracking data starting from today’s date,
          {{date-format (now) "MMMM d, yyyy"}}. If you’ve previously enabled usage tracking, that historical data will still
          be available to you.
        </p>
      {{else}}
        <p class="has-bottom-margin-s" data-test-clients-config-modal="off">
          Turning usage tracking off means that all data for the current month will be deleted. You will still be able to
          query previous months.
        </p>
        <p>Are you sure?</p>
      {{/if}}
    </section>
    <footer class="modal-card-foot modal-card-foot-outlined">
      <button
        type="button"
        class="button is-primary"
        data-test-clients-config-modal="continue"
        {{on "click" (perform this.save)}}
      >
        Continue
      </button>
      <button
        type="button"
        class="button is-secondary"
        {{on "click" (fn (mut this.modalOpen) false)}}
        data-test-clients-config-modal="cancel"
      >
        Cancel
      </button>
    </footer>
  </Modal>
{{else}}
  <div class="tabs-container box is-bottomless is-marginless is-fullwidth is-paddingless" data-test-clients-config-table>
    {{#each this.infoRows as |item|}}
      <InfoTableRow @label={{item.label}} @helperText={{item.helperText}} @value={{get @model item.valueKey}} />
    {{/each}}
  </div>
{{/if}}