Repository: hashicorp/vault
File: ui/app/models/database/connection.js (JavaScript)

Code before:
  tls_certificate: attr('string', {
    label: 'TLS Certificate Key',
    helpText: 'The x509 certificate for connecting to the database. Must be PEM encoded.',
    editType: 'file',
  }),
  tls_ca: attr('string', {
    label: 'TLS CA',
    helpText:
      'x509 CA file for validating the certificate presented by the database server. Must be PEM encoded.',
    editType: 'file',
  }),
  tls_server_name: attr('string', {
    label: 'TLS server name',
    subText: 'If set, this name is used to set the SNI host when connecting via 1TLS.',
  }),
  root_rotation_statements: attr({
    subText: `The database statements to be executed to rotate the root user's credentials. If nothing is entered, Vault will use a reasonable default.`,
    editType: 'stringArray',
    defaultShown: 'Default',
  }),

  // ENTERPRISE ONLY
  skip_static_role_rotation_import: attr({
    editType: 'toggleButton',
    label: 'Rotate static roles immediately',
    helperTextDisabled: 'Vault automatically rotates static roles upon their initial creation.',
    helperTextEnabled: 'Vault will not automatically rotate static role passwords upon creation.',
    defaultValue: false,
    isOppositeValue: true,
  }),

  self_managed: attr('boolean', {
    subText:
      'Allows onboarding static roles with a rootless connection configuration. Mutually exclusive with username and password. If true, will force verify_connection to be false.',
    defaultValue: false,
  }),

  isAvailablePlugin: computed('plugin_name', function () {
    return !!AVAILABLE_PLUGIN_TYPES.find((a) => a.value === this.plugin_name);
  }),

  showAttrs: computed('plugin_name', function () {
    const fields = this._filterFields((f) => f.show !== false).map((f) => f.attr);
    fields.push('allowed_roles');
    return expandAttributeMeta(this, fields);
  }),

  // for both create and edit fields
  fieldAttrs: computed('plugin_name', function () {
    let fields = ['plugin_name', 'name', 'connection_url', 'verify_connection', 'password_policy'];
    if (this.plugin_name) {

Review comment (refactor):
since `isOppositeValue` is a newer thing (and when this was implemented in PKI there was also a whole `mapToBoolean` situation so it was a slightly different application)

I wonder how we should handle this since this text actually displays when visually the toggle is "on" (and vice versa for `helperTextEnabled`
Perhaps a comment say "because isOppositeValue is true, this text actually displays when the input is enabled" or we could also include an `isOppositeValue` check where the helperTextDisabled/Enabled is rendered

What do you think?

Code after:
  tls_certificate: attr('string', {
    label: 'TLS Certificate Key',
    helpText: 'The x509 certificate for connecting to the database. Must be PEM encoded.',
    editType: 'file',
  }),
  tls_ca: attr('string', {
    label: 'TLS CA',
    helpText:
      'x509 CA file for validating the certificate presented by the database server. Must be PEM encoded.',
    editType: 'file',
  }),
  tls_server_name: attr('string', {
    label: 'TLS server name',
    subText: 'If set, this name is used to set the SNI host when connecting via 1TLS.',
  }),
  root_rotation_statements: attr({
    subText: `The database statements to be executed to rotate the root user's credentials. If nothing is entered, Vault will use a reasonable default.`,
    editType: 'stringArray',
    defaultShown: 'Default',
  }),

  // ENTERPRISE ONLY
  skip_static_role_rotation_import: attr({
    editType: 'toggleButton',
    label: 'Rotate static roles immediately',
    helperTextEnabled: 'Vault automatically rotates static roles upon their initial creation.',
    helperTextDisabled: 'Vault will not automatically rotate static role passwords upon creation.',
    defaultValue: false,
    isOppositeValue: true,
  }),

  self_managed: attr('boolean', {
    subText:
      'Allows onboarding static roles with a rootless connection configuration. Mutually exclusive with username and password. If true, will force verify_connection to be false.',
    defaultValue: false,
  }),

  isAvailablePlugin: computed('plugin_name', function () {
    return !!AVAILABLE_PLUGIN_TYPES.find((a) => a.value === this.plugin_name);
  }),

  showAttrs: computed('plugin_name', function () {
    const fields = this._filterFields((f) => f.show !== false).map((f) => f.attr);
    fields.push('allowed_roles');
    return expandAttributeMeta(this, fields);
  }),

  // for both create and edit fields
  fieldAttrs: computed('plugin_name', function () {
    let fields = ['plugin_name', 'name', 'connection_url', 'verify_connection', 'password_policy'];
    if (this.plugin_name) {