Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(forms): number values in map fields #1809

Merged
merged 3 commits into from
Nov 26, 2024
Merged

Conversation

Leopoldthecoder
Copy link
Member

@Leopoldthecoder Leopoldthecoder commented Nov 25, 2024

Summary

Problematic field example:

 {
    "trace_services": {
      "description": "Map of routes matchers with sampling rates, use when plugin mode is global",
      "keys": {
        "type": "string"
      },
      "type": "map",
      "values": {
        "between": [
          0,
          1
        ],
        "default": 0,
        "required": true,
        "type": "number"
      }
    }
  }

This PR ensures the form respects "type": "number" and "default": 0.

FTI-6360

@@ -216,9 +219,10 @@ export default {
Array.isArray(this.subSchema.fields) &&
this.subSchema.fields.length === 1 &&
this.subSchema.fields[0].type === 'array'
const type = this.subSchema ? valueIsArray ? [''] : {} : ''
const defaultValue = this.schema.values?.default ?? ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If value's type is not string, would it cause problem to set default value as ''?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

@sumimakito sumimakito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually verified the fix. LGTM

@Leopoldthecoder Leopoldthecoder merged commit 81f8cc6 into main Nov 26, 2024
12 checks passed
@Leopoldthecoder Leopoldthecoder deleted the fix/number-map branch November 26, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants