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

feat: add UI support for flag metadata #3717

Merged
merged 48 commits into from
Jan 1, 2025
Merged

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 11, 2024

Implements UI components for flag metadata CRUD operations.

Closes #2682

Link to Devin run: https://app.devin.ai/sessions/d62abd8bc3cb467dba175d847f5b8f07

Metadata entries can be of type primitive, array, or object.
If array or object we render the JSONEditor.
If primitive the user selects a subtype of 'string, number, or boolean'

CleanShot 2024-12-14 at 12 35 40@2x
CleanShot 2024-12-14 at 12 36 11@2x
CleanShot 2024-12-31 at 10 39 29@2x

Handling Errors

If there is an error rendering the MetadataForm we use an ErrorBoundary to render a more simplified version of the metadata which just uses the JSONEditor component:

CleanShot 2024-12-31 at 16 16 19

TODO

  • test with more complicated metadata
  • Fix UI ITs

Robot Summary

This pull request introduces several changes across multiple files to enhance the handling of JSON editors, metadata in flags, and to update dependencies. The most significant changes include renaming and updating the JSON editor component, adding metadata support to flags, and updating test cases to reflect these changes.

JSON Editor Updates:

  • Renamed ContextEditor to JsonEditor and updated its implementation to support additional props such as value, disabled, strict, and height. The linter function was also updated to handle strict mode. (ui/src/components/json/JsonEditor.tsx, ui/src/components/json/JsonEditor.module.css, ui/src/components/json/lint.ts) [1] [2] [3] [4] [5]

Metadata Support in Flags:

  • Added metadata support to the FlagForm component, including validation and UI changes to handle metadata input. (ui/src/components/flags/forms/FlagForm.tsx, ui/src/app/flags/flagsApi.ts, ui/src/types/Flag.ts) [1] [2] [3] [4] [5] [6] [7]

Test Case Updates:

  • Added new test cases to verify the creation, updating, and deletion of flags with metadata, as well as ensuring metadata cannot be edited in read-only mode. (ui/tests/flags.spec.ts) [1] [2]

Dependency Updates:

  • Removed an outdated dependency from go.work.sum. (go.work.sum)

Miscellaneous:

  • Added coverage to the .gitignore file to exclude coverage reports from version control. (ui/.gitignore)
  • Minor UI adjustments in table-skeleton.tsx and updated a helper function in helpers.ts. (ui/src/components/ui/table-skeleton.tsx, ui/src/utils/helpers.ts) [1] [2]

devin-ai-integration bot and others added 12 commits December 11, 2024 17:22
- Add IFlagMetadata interface to Flag.ts
- Create MetadataForm component with CRUD operations
- Add validation using Yup schema
- Use Radix UI components for accessibility
- Style with TailwindCSS
- Install required type declarations

Co-Authored-By: Mark Phelps <[email protected]>
- Add metadata field to flag form
- Update validation schema for metadata
- Follow existing styling patterns
- Add proper TypeScript types

Co-Authored-By: Mark Phelps <[email protected]>
- Ensure metadata is preserved in updateFlag mutation
- Preserve metadata when copying flags
- Add proper TypeScript types for metadata handling

Co-Authored-By: Mark Phelps <[email protected]>
@devin-ai-integration devin-ai-integration bot added ui enhancement Created by Linear-GitHub Sync labels Dec 11, 2024
@erka
Copy link
Collaborator

erka commented Dec 11, 2024

The object could be included in the metadata. This is an example what people have https://discord.com/channels/960634591000014878/1309109822657921034/1309120286142107668.

Signed-off-by: Mark Phelps <[email protected]>
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.84%. Comparing base (1c01075) to head (73a08b4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3717   +/-   ##
=======================================
  Coverage   64.84%   64.84%           
=======================================
  Files         171      171           
  Lines       17391    17391           
=======================================
  Hits        11277    11277           
  Misses       5418     5418           
  Partials      696      696           
Flag Coverage Δ
unittests 64.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@markphelps
Copy link
Collaborator

The object could be included in the metadata. This is an example what people have https://discord.com/channels/960634591000014878/1309109822657921034/1309120286142107668.

im updating it to support nested objects and other types such as arrays

@markphelps markphelps marked this pull request as ready for review December 31, 2024 15:43
@markphelps markphelps requested a review from a team as a code owner December 31, 2024 15:43
@erka
Copy link
Collaborator

erka commented Jan 1, 2025

Great work @markphelps.

I think we have a very strict rules for keys right npw. Probably many people would like to use - and _ in the key name.
Another thing, I could have few records with the same key while adding. Is it by design?

@markphelps
Copy link
Collaborator

Great work @markphelps.

I think we have a very strict rules for keys right npw. Probably many people would like to use - and _ in the key name. Another thing, I could have few records with the same key while adding. Is it by design?

Cheers @erka ! I went ahead and reverted the change to the stringAsKey helper and added validation to check for duplicate keys and a test.

CleanShot 2025-01-01 at 10 04 24

Signed-off-by: Mark Phelps <[email protected]>
…lipt-io/flipt into devin/1733937099-flag-metadata

* 'devin/1733937099-flag-metadata' of https://github.com/flipt-io/flipt:
  refactor(ui): replace headlessui Switch with radix-ui (#3774)
@markphelps markphelps added the automerge Used by Kodiak bot to automerge PRs label Jan 1, 2025
Copy link
Collaborator

@erka erka left a comment

Choose a reason for hiding this comment

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

nice!

Signed-off-by: Mark Phelps <[email protected]>
@kodiakhq kodiakhq bot merged commit e62f4b4 into main Jan 1, 2025
37 checks passed
@kodiakhq kodiakhq bot deleted the devin/1733937099-flag-metadata branch January 1, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Used by Kodiak bot to automerge PRs enhancement Created by Linear-GitHub Sync needs docs Requires documentation updates ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FLI-786] Flag Metadata
2 participants