Skip to content

refactor(featureStateToValue): extract into a Flux-free module - #8344

Open
talissoncosta wants to merge 1 commit into
fix/deeplink-feature-value-8337from
refactor/decouple-feature-state-value
Open

refactor(featureStateToValue): extract into a Flux-free module#8344
talissoncosta wants to merge 1 commit into
fix/deeplink-feature-value-8337from
refactor/decouple-feature-state-value

Conversation

@talissoncosta

Copy link
Copy Markdown
Contributor

Changes

Contributes to #8337 (follow-up to #8341)

Utils.featureStateToValue is a pure function, but it lives in utils.tsx, which imports the Flux stores (AccountStore/ProjectStore) at module load. That import chain breaks any unit-tested consumer, which is why #8341's deep-link hook had to inline its own copy of the flatten logic.

This extracts it into common/utils/featureStateToValue.ts (types only, no Flux) and has Utils delegate to it via a shorthand re-export — so the ~22 existing Utils.featureStateToValue(...) callers are unchanged. The deep-link hook now imports the shared function and drops its duplicate.

The function is broadened while moving:

  • accepts an already-flat value (returned untouched), so the hook doesn't need a cast;
  • normalises a missing int/float to null.

This is the first step of decoupling the pure helpers from utils.tsx (which follows the existing common/utils/<name>.ts convention, e.g. ensureTrailingSlash, multivariate).

Note: stacked on fix/deeplink-feature-value-8337 (#8341). Retarget to main once that merges.

How did you test this code?

  • New common/utils/__tests__/featureStateToValue.test.ts: covers every type branch (bool/float/int/unicode), value_type for core traits, missing int/float → null, null/undefined → null, and already-flat passthrough.
  • deepLinkedFeature.test.ts: keeps the pickEnvironmentFlag behaviour tests plus one integration case proving the nested value is flattened via the shared function.
  • 20 unit tests pass; eslint + typecheck clean on the changed files.

Utils.featureStateToValue is a pure function, but it lives in utils.tsx,
which imports the Flux stores (AccountStore/ProjectStore) at module load.
That import chain breaks any unit-tested consumer, which is why the
deep-link hook had to inline its own copy of the flatten logic.

Move it to common/utils/featureStateToValue.ts (types only, no Flux) and
have Utils delegate via a shorthand re-export, so the ~22 existing callers
are unchanged. The deep-link hook now imports the shared function and
drops its duplicate. The function is broadened to also accept an
already-flat value (returned untouched) and to normalise a missing
int/float to null.

First step of decoupling the pure helpers from utils.tsx.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview Aug 21, 2026 7:00pm
flagsmith-frontend-staging Ready Ready Preview Aug 21, 2026 7:00pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Aug 21, 2026 7:00pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b2fe525a-be82-4403-8eb9-5b64a5195d5e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Aug 21, 2026
@talissoncosta talissoncosta changed the title Extract featureStateToValue into a Flux-free module refactor(featureStateToValue): extract into a Flux-free module Aug 21, 2026
@talissoncosta
talissoncosta marked this pull request as ready for review August 21, 2026 19:03
@talissoncosta
talissoncosta requested a review from a team as a code owner August 21, 2026 19:03
@talissoncosta
talissoncosta requested review from kyle-ssg and removed request for a team August 21, 2026 19:03
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19641 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  5 passed

Details

stats  5 tests across 4 suites
duration  39 seconds
commit  1da53b5
info  🔄 Run: #19641 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #19641 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.6 seconds
commit  1da53b5
info  🔄 Run: #19641 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19641 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  46.4 seconds
commit  1da53b5
info  🔄 Run: #19641 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19641 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.8 seconds
commit  1da53b5
info  🔄 Run: #19641 (attempt 1)

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant