Repository: hashicorp/vault
File: ui/lib/core/addon/components/form-field.js (JavaScript)

Code before:
    assert(
      'Form is attempting to modify an ID. Ember-data does not allow this.',
      valuePath.toLowerCase() !== 'id'
    );
    const modelValue = model[valuePath];
    this.showToggleTextInput = !!modelValue;
    this.toggleInputEnabled = !!modelValue;
  }

  // ---------------------------------------------------------------
  // IMPORTANT:
  // this controls the top-level logic in the associated template
  // to decide which type of form field to render (Vault or HDS)
  // ---------------------------------------------------------------
  //
  get isHdsFormField() {
    const { type, options } = this.args.attr;

    // here we replicate the logic in the template, to make sure we don't change the order in which the "ifs" are evaluated
    if (options?.possibleValues?.length > 0) {
      return true;
    } else {
      if (!options?.sensitive && (type === 'number' || type === 'string')) {
        if (
          options?.editType === undefined ||
          options?.editType === 'password' ||
          options?.editType === 'textarea' ||
          options?.editType === 'string' ||
          options?.editType === 'number'
        ) {
          return true;
        } else {
          return false;
        }
      } else if (type === 'boolean' || options?.editType === 'boolean') {
        return true;
      } else {
        // we leave these fields as they are (for now)
        return false;
      }
    }
  }

  get hasRadioSubText() {
    // for 'radio' editType, check to see if any of the possibleValues has a subText
    return this.args?.attr?.options?.possibleValues?.any((v) => v.subText);
  }

  get hasRadioHelpText() {
    // for 'radio' editType, check to see if any of the possibleValues has a helpText
    return this.args?.attr?.options?.possibleValues?.any((v) => v.helpText);

Review comment (suggestion):
[Note] These could be consolidated into one if block, but were left separate to best match the existing logic in the template file. 

Code after:
    const { attr, model } = this.args;
    const valuePath = attr.options?.fieldValue || attr.name;
    assert(
      'Form is attempting to modify an ID. Ember-data does not allow this.',
      valuePath.toLowerCase() !== 'id'
    );
    assert('@name is required', presence(attr.name));
    assert('@model (or resource object being updated) is required', presence(model));
    const modelValue = get(model, valuePath);
    this.showToggleTextInput = !!modelValue;
    this.toggleInputEnabled = !!modelValue;
  }

  // ---------------------------------------------------------------
  // IMPORTANT:
  // this controls the top-level logic in the associated template
  // to decide which type of form field to render (Vault or HDS)
  // ---------------------------------------------------------------
  //
  get isHdsFormField() {
    const { type, options } = this.args.attr;

    // here we replicate the logic in the `form-field.hbs` template, as it was at the beginning of the migation to HDS
    // to make sure we don't change the order in which the "ifs" are evaluated
    // see: https://github.com/hashicorp/vault/blob/e99c06a0249f1ecde02c5b48990cb0e91e4ec575/ui/lib/core/addon/components/form-field.hbs
    if (options?.possibleValues?.length > 0) {
      return true;
    } else {
      if (options?.editType === 'dateTimeLocal') {
        return true;
      } else if (
        options?.editType === 'searchSelect' ||
        options?.editType === 'mountAccessor' ||
        options?.editType === 'kv' ||
        options?.editType === 'file' ||
        options?.editType === 'ttl' ||
        options?.editType === 'regex' ||
        options?.editType === 'toggleButton' ||
        options?.editType === 'optionalText' ||
        options?.editType === 'stringArray' ||
        options?.sensitive === true
      ) {
        return false;
      } else if (type === 'number' || type === 'string') {
        if (options?.editType === 'textarea' || options?.editType === 'password') {
          return true;
        } else if (options?.editType === 'json') {
          return false;
        } else {
          return true;
        }