Skip to content

feat: frontend context values in segment#5766

Merged
khvn26 merged 18 commits intomainfrom
feat/frontend-context-values-in-segment
Jul 23, 2025
Merged

feat: frontend context values in segment#5766
khvn26 merged 18 commits intomainfrom
feat/frontend-context-values-in-segment

Conversation

@Zaimwa9
Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 commented Jul 16, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Related: #5764 and #5675

⚠️ will still need some interfacing with API once ready

  • Allow to select pre-defined context values (identifier or environment_name for now) as condition properties.
  • Implemented an input-dropdown component usable when creating/editing rules of a segment
  • Migrated related components to functional components
  • Removed the tooltip on the input component
image image image

How did you test this code?

  • E2E tests

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner July 16, 2025 10:54
@Zaimwa9 Zaimwa9 requested review from tiagoapolo and removed request for a team July 16, 2025 10:54
@vercel
Copy link
Copy Markdown

vercel bot commented Jul 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 10:34am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 10:34am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2025 10:34am

@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label Jul 16, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 16, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-5766 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-5766 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-5766 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-5766 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5766 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-5766 Finished ✅ Results

@github-actions github-actions bot added the feature New feature or request label Jul 16, 2025
@khvn26
Copy link
Copy Markdown
Member

khvn26 commented Jul 16, 2025

Traits are not supported for the selected operator

Oh they certainly are going to be supported, no need to impose the restriction here.

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jul 16, 2025
Comment on lines +59 to +63
const isContextPropertyEnabled =
Utils.getFlagsmithHasFeature('context_values')
const contextValues: OptionType[] = JSON.parse(
Utils.getFlagsmithValue('context_values') || '{}',
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not convinced with this approach. We loose in control / validation and i'm not sure about the upside.
Maybe use it to disable specific values if needed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we can utilise the evaluation context schema: #5764

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A bit complicated in its current shape because it doesn't work with the json-path we are using.

For identifier we would need something like $.defs.IdentityEvaluationContext.properties.identifier.title so it looks like quite a lot of gymnastic

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Jsonschema doesn't seem too hard to parse? https://stackoverflow.com/a/60297881

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As discussed offline, added custom properties to the schema to simplify the schema parsing. It shouldn't be a problem to use titles and descriptions from the schema now.

Comment thread frontend/web/components/segments/Rule/components/RuleConditionRow.tsx Outdated
Comment on lines +59 to +63
const isContextPropertyEnabled =
Utils.getFlagsmithHasFeature('context_values')
const contextValues: OptionType[] = JSON.parse(
Utils.getFlagsmithValue('context_values') || '{}',
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we can utilise the evaluation context schema: #5764

tiagoapolo
tiagoapolo previously approved these changes Jul 22, 2025
@khvn26 khvn26 merged commit 9115f16 into main Jul 23, 2025
25 checks passed
@khvn26 khvn26 deleted the feat/frontend-context-values-in-segment branch July 23, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants