Skip to content

feat(aci): Add ability to create envs inline#112558

Merged
saponifi3d merged 4 commits intomasterfrom
jcallender/aci/env-selector
Apr 9, 2026
Merged

feat(aci): Add ability to create envs inline#112558
saponifi3d merged 4 commits intomasterfrom
jcallender/aci/env-selector

Conversation

@saponifi3d
Copy link
Copy Markdown
Contributor

Description

Updated the environment selector to be able to create a new environment inline.

Right now, we can only select environments on Uptime and Metric monitors. The Metric monitor will be able to save the new environments after #112537 is deployed.

Metric Monitor

Screenshot 2026-04-08 at 4 56 33 PM

Uptime Monitor

Screenshot 2026-04-08 at 4 58 48 PM

Uptime Saves

Screenshot 2026-04-08 at 4 59 33 PM

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 9, 2026
@saponifi3d saponifi3d marked this pull request as ready for review April 9, 2026 18:30
@saponifi3d saponifi3d requested a review from a team as a code owner April 9, 2026 18:30
@saponifi3d saponifi3d merged commit 2bd8da7 into master Apr 9, 2026
62 checks passed
@saponifi3d saponifi3d deleted the jcallender/aci/env-selector branch April 9, 2026 18:30
Comment on lines +51 to 55
onCreateOption={env => {
setNewEnvironment(env);
formContext.form?.setValue(ENV_FIELD_NAME, env);
}}
{...props}
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.

Bug: The internal onCreateOption handler is placed before {...props}, so a caller-provided onCreateOption will override it, preventing new options from being saved.
Severity: MEDIUM

Suggested Fix

Move the component's props, including the internal onCreateOption handler, to be defined after the {...props} spread. This ensures the internal logic is preserved and can be extended by chaining any caller-provided onCreateOption function if needed.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
static/app/views/detectors/components/forms/common/environmentField.tsx#L51-L55

Potential issue: In the `EnvironmentField` component, the internal `onCreateOption`
handler is defined before the `{...props}` spread. This means any `onCreateOption` prop
passed by a parent component will silently override the internal logic. The internal
handler is responsible for adding newly created environment options to the dropdown
choices and updating the form's state. When this handler is overridden, these actions do
not occur, and the newly created option is effectively lost, not being reflected in the
UI or the form data.

Did we get this right? 👍 / 👎 to inform future reviews.

george-sentry pushed a commit that referenced this pull request Apr 9, 2026
# Description
Updated the environment selector to be able to create a new environment
inline.

Right now, we can only select environments on Uptime and Metric
monitors. The Metric monitor will be able to save the new environments
after #112537 is deployed.

### Metric Monitor
<img width="1624" height="1061" alt="Screenshot 2026-04-08 at 4 56
33 PM"
src="https://github.com/user-attachments/assets/f6c2ebef-3b2c-45fe-bc29-839c4be81f35"
/>

### Uptime Monitor
<img width="1624" height="1061" alt="Screenshot 2026-04-08 at 4 58
48 PM"
src="https://github.com/user-attachments/assets/09b61794-3242-48ee-8f03-d3b0ecc05060"
/>

### Uptime Saves
<img width="1624" height="1061" alt="Screenshot 2026-04-08 at 4 59
33 PM"
src="https://github.com/user-attachments/assets/5783da6b-a7f7-4e07-b501-eb7eebcab22f"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants