Skip to content

feat(ui): allow copying flags across environments#5772

Open
AnouarMohamed wants to merge 12 commits into
flipt-io:v2from
AnouarMohamed:feat/ui-copy-flags-across-environments
Open

feat(ui): allow copying flags across environments#5772
AnouarMohamed wants to merge 12 commits into
flipt-io:v2from
AnouarMohamed:feat/ui-copy-flags-across-environments

Conversation

@AnouarMohamed

Copy link
Copy Markdown

Summary

Adds support for copying a flag to a namespace in another environment from the flag details page.

Fixes #5382.

Changes

  • Added a dedicated copy dialog with environment and namespace selectors
  • Updated flag copy to read from the source environment and write using the destination environment revision
  • Added UI coverage for cross-environment flag copy
  • Included a small Listbox control fix as a prerequisite for dependent selections

Backward Compatibility

Existing same-environment namespace copy behavior still works.

Signed-off-by: AnouarMohamed <m.anouar@mundiapolis.ma>
Signed-off-by: AnouarMohamed <m.anouar@mundiapolis.ma>
@AnouarMohamed AnouarMohamed requested a review from a team as a code owner April 22, 2026 22:36
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 22, 2026
@lamoboos223

Copy link
Copy Markdown

@AnouarMohamed

This is great we should also add the ability to populate segments as well

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.75%. Comparing base (acda1ab) to head (a2a1e04).

Additional details and impacted files
@@           Coverage Diff           @@
##               v2    #5772   +/-   ##
=======================================
  Coverage   61.75%   61.75%           
=======================================
  Files         142      142           
  Lines       14442    14442           
=======================================
  Hits         8919     8919           
  Misses       4784     4784           
  Partials      739      739           
Flag Coverage Δ
integrationtests 34.30% <ø> (ø)
unittests 52.97% <ø> (ø)

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: comment

The cross-environment flag copy is well-scoped and the new test coverage is solid. However, three UX/consistency issues raised in the previous automated review are still unfixed in this revision: a stale error_state bug when switching environments, a missing in-flight guard on the Copy button, and an unused dependency in a React effect.

ui/src/components/panels/CopyFlagPanel.tsx

  • minor (L154): The remote-namespace fetch calls setError(err) on failure but never clears the error on success. If a user selects an environment where the fetch previously failed, then switches to one that succeeds, the stale error persists in the UI. Call clearError() in the .then handler before setRemoteNamespaces(data.items ?? []).
  • minor (L283): The Copy button is not disabled while a copy is in-flight. A double-click can start two concurrent handleCopy promises, which may race on the backend and produce a misleading conflict error even though one copy succeeds. Add a local copying state, include it in the disabled condition, and reset it in both the .then and .catch handlers of the onClick promise chain.
  • nit (L175): namespace.key is listed in the remote-namespace fetch effect's dependency array but is never referenced inside the effect body. Remove it to avoid unnecessary refetches if the current namespace changes while the dialog is open.

🤖 Automated review by the Flipt PR review agent.

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 20, 2026
Signed-off-by: AnouarMohamed <m.anouar@mundiapolis.ma>
Signed-off-by: AnouarMohamed <m.anouar@mundiapolis.ma>
@AnouarMohamed AnouarMohamed force-pushed the feat/ui-copy-flags-across-environments branch from d3d8830 to ef3d381 Compare June 20, 2026 14:01
(candidate) => candidate.key === initialEnvironmentKey
) || environmentOptions[0];

if (selectedEnvironment?.key !== initialEnvironment.key) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this effect can accidentally undo the user's selection. Since selectedEnvironment?.key is in the dependency list, picking another environment reruns the effect and recomputes the initial environment. When the current env has another namespace, that initial value is the current env, so the cross-env selection gets snapped back. Could we make this initialization run only when the dialog opens / when there's no valid selected environment, instead of whenever the selected env changes?

return;
}

setRemoteNamespaces([]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If this request fails, we clear the remote namespaces and the dialog falls through to the same empty-state message as a valid environment with no namespaces. That makes a network/API error look like 'No namespaces are available', and there's no obvious retry path. Could we keep a local load error state and show an inline error/retry here, only showing the empty-state copy after a successful empty response?

</DialogHeader>
<div className="my-2 space-y-4">
<div className="space-y-2">
<div className="text-sm font-medium">Environment</div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small accessibility issue: this text looks like a label visually, but it isn't associated with the select trigger. Same for Namespace below. Screen readers won't get a reliable accessible name for these controls, and tests can't query them by role/name. Could we wire these up with a real label or aria-labelledby on the Listbox trigger?

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

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to duplicate a flag to another environment / namespace

3 participants