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

Ensure "nullable" fields are rendered correctly in json forms #1441

Merged
merged 8 commits into from
Feb 6, 2025

Conversation

travjenkins
Copy link
Member

@travjenkins travjenkins commented Jan 31, 2025

Issues

#1442

Changes

1442

  • Get the "nullable" type from the schema and properly create a control for types other than anyOf or oneOf.
  • Check for type of string before checking format, secret, etc. to make those functions easier to handle and so they can check the "nullable" types as well

Misc

  • Updated how we add date/time formats to the schema to reduce duplication
  • Renamed functions that check things on the schema

Tests

Manually tested

  • Different schemas

Automated tests

  • n/a

Playwright tests ran locally

  • Admin
  • Captures
  • Collections
  • HomePage
  • Login
  • Materialization

Screenshots

Test cases

image

Used this schema to test

{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "title": "EndpointConfig",
  "type": "object",
  "properties": {
    "stringSecret": {
      "title": "String Secret",
      "description": "",
      "type": "string",
      "secret": true
    },
    "stringNullSecret": {
      "title": "String/Null Secret",
      "description": "",
      "type": ["string", "null"],
      "secret": true
    },
    "stringNonSecret": {
      "title": "String NOT Secret",
      "description": "",
      "type": "string"
    },
    "stringNullNonSecret": {
      "title": "String/Null NOT Secret",
      "description": "",
      "type": ["string", "null"]
    },
    "multiLineNullSecret": {
      "title": "MultiLine Null Secret",
      "description": "",
      "type": ["string", "null"],
      "multiline": true,
      "secret": true
    },
    "multiLineNullNonSecret": {
      "title": "MultiLine Null NOT Secret",
      "description": "",
      "type": ["string", "null"],
      "multiline": true
    },
    "multiLineSecret": {
      "title": "MultiLine Secret",
      "description": "",
      "type": "string",
      "multiline": true,
      "secret": true
    },
    "multiLineNonSecret": {
      "title": "MultiLine NOT Secret",
      "description": "",
      "type": "string",
      "multiline": true
    }
  }
}

Updating how we check formats
No longer want to check the string type as we need to check nullableType
  as well. So just easier to wrap all these in a single check
Adding some commenting explaining stuff
Adding nullable to any input near the bottom
@travjenkins travjenkins changed the title Allow clearing encrypted fields during edit Ensure "nullable" fields are rendered correctly in json forms Feb 3, 2025
@travjenkins travjenkins marked this pull request as ready for review February 3, 2025 21:35
@travjenkins travjenkins requested a review from a team as a code owner February 3, 2025 21:35
@travjenkins travjenkins added change:unplanned Unplanned change, useful for things like doc updates change:planned This is a planned change and removed change:unplanned Unplanned change, useful for things like doc updates labels Feb 4, 2025
@travjenkins travjenkins merged commit 1a5b38a into main Feb 6, 2025
3 checks passed
@travjenkins travjenkins deleted the travjenkins/bug/clear-sop-fields-on-edit branch February 6, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:planned This is a planned change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants