Skip to content

chore: add ImpactMetricRegistrationContext - #11854

Open
dharmadeveloper108 wants to merge 1 commit into
mainfrom
dont-keep-both-impactmetrics-dialogs-open
Open

chore: add ImpactMetricRegistrationContext#11854
dharmadeveloper108 wants to merge 1 commit into
mainfrom
dont-keep-both-impactmetrics-dialogs-open

Conversation

@dharmadeveloper108

@dharmadeveloper108 dharmadeveloper108 commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Adds a context so that MetricSelector (the impact metric empty state) can determine wether to close the "Create impact metric" dialog and open the new register metric dialog, or just open the new register dialog.
On the /impact-metrics page, both dialogs are wrapped in a provider that coordinates the switch. On the flag page (no provider), the register dialog falls back to the original stacked behavior.

Screen.Recording.2026-04-17.at.10.18.28.mov

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

openRegisterDialog: () => void;
};

const ImpactMetricRegistrationContext = createContext<

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.

not super set on the name here

metrics={metricOptions}
loading={metadataLoading || settingsLoading}
/>
<ImpactMetricRegistrationProvider

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.

Could have also achieved the same thing by prop drilling (which is what I initially did), but I'm kinda allergic to it

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.

Is there a more generic way to solve this, though? We can probably assume that modals should replace one another, and it'd be neat to not have to this over and over again?

Also, we're assuming that we don't want that. Are we sure we don't? (we should check with ux)

@thomasheartman thomasheartman 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.

It solves the potential problem, but I wish we could do it in a less imperative fashion or solve the problem in more general terms. Not sure we can, though.

Anyway, I've added some state modeling suggestions that I think are reasonable. Have a look.

Comment on lines +36 to +38
const [createChartDialogOpen, setCreateChartDialogOpen] = useState(false);
const [registerMetricDialogOpen, setRegisterMetricDialogOpen] =
useState(false);

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.

What happens if they're both true, though? Instead of two independent pieces of state, could we model this as

const [openDialog, setOpenDialog] useState<'createChart' | 'registerMetrics' | null>(null)

Or something like that?

open={registerDialogOpen}
onClose={() => setRegisterDialogOpen(false)}
/>
{!registrationContext && (

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.

I'm having trouble understanding why this is here? What's it doing?

metrics={metricOptions}
loading={metadataLoading || settingsLoading}
/>
<ImpactMetricRegistrationProvider

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.

Is there a more generic way to solve this, though? We can probably assume that modals should replace one another, and it'd be neat to not have to this over and over again?

Also, we're assuming that we don't want that. Are we sure we don't? (we should check with ux)

@github-project-automation github-project-automation Bot moved this from New to Approved PRs in Issues and PRs Apr 17, 2026
@CLAassistant

CLAassistant commented Jun 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

3 participants