-
Notifications
You must be signed in to change notification settings - Fork 15
Implement Upsert Metric Modal for Experiments v2 #2756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zackcl
merged 34 commits into
experiment-design-refresh
from
feature/2631-upsert-metric-modal-v2
Dec 15, 2025
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3e3eb37
Implement Upsert Metric Modal for Experiments v2
d896093
Correct the metric-helper.service.ts filename
zackcl 2691597
Fix lint errors
zackcl 1417718
Filter out all reward metric options in the Metric ID field
zackcl 828b6a2
Disallow reward metric editing and deleting
zackcl a7f9a3b
fix: require metric ID selection from autocomplete options and preven…
zackcl 6d02007
Add validation requiring metric class, key, and ID selection from aut…
zackcl f6d68fd
Prevent Save button from being incorrectly enabled in edit mode for c…
zackcl e32acb6
Apply appTrimInput directive to all the input fields in the UpsertMet…
zackcl 54fdf42
Resolve sonarqube warnings
zackcl d7ace57
Extract populateFormForEditMode into focused helper methods
zackcl 8c44ad0
Make Metric Class and ID options to appear on Edit Metric modal, and …
zackcl 11c1fa2
Remove the Description field from the Add/Edit Metrics modal
zackcl 687599f
Wait for metrics data before hydrating edit metric form
zackcl b0ad916
Resolve potential memory leak
zackcl cfe4059
Disable Save button on Edit Metric modal when Metric ID type (continu…
zackcl f7bc0fa
Fix some fields not being required on the Edit Metric modal
zackcl 41594cf
Add placeholder for the Value field
zackcl 3244d0f
Remove misleading comment
zackcl 6936d9d
Remove logic to disable actions for reward metrics in table, and remo…
zackcl 5d3a62a
Remove menu button from Metrics section card
zackcl a072f6c
Extract warning messages to translation keys
zackcl 6a2d386
Add missing translation keys for metrics and conditions update notifi…
zackcl 7ecbc7d
Show snackbar when upsert metric lacks experiment or source query
zackcl 5183257
Merge branch 'experiment-design-refresh' into feature/2631-upsert-met…
zackcl 4baa856
Add missing import WeightingMethod
zackcl 01fe8ec
Tighten the metric autocomplete typing
zackcl 1b2eb29
Typed the form pipeline so the modal now works with explicit metric s…
zackcl a6895c2
Type the backend and frontend around experiment queries by sharing a …
zackcl 47c343e
Add unit tests for UpsertMetricModalComponent
zackcl 18d0dec
Add targeted TSDoc blocks in UpsertMetricModalComponent
zackcl 98a29a4
Merge branch 'experiment-design-refresh' into feature/2631-upsert-met…
zackcl 76db22c
Merge remote-tracking branch 'origin/experiment-design-refresh' into …
zackcl 4b530a7
Merge branch 'experiment-design-refresh' into feature/2631-upsert-met…
zackcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
frontend/projects/upgrade/src/app/core/experiments/metric-helper.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { v4 as uuidv4 } from 'uuid'; | ||
|
|
||
| import { ExperimentService } from './experiments.service'; | ||
| import { Experiment, ExperimentQueryDTO, UpdateExperimentMetricsRequest } from './store/experiments.model'; | ||
|
|
||
| @Injectable({ | ||
| providedIn: 'root', | ||
| }) | ||
| export class MetricHelperService { | ||
| constructor(private experimentService: ExperimentService) {} | ||
|
|
||
| /** | ||
| * Add a new metric to an experiment | ||
| */ | ||
| addMetric(experiment: Experiment, metricData: ExperimentQueryDTO): void { | ||
| const currentMetrics = [...(experiment.queries || [])]; | ||
| const newMetric = { | ||
| ...metricData, | ||
| id: uuidv4(), | ||
| }; | ||
|
|
||
| const updatedMetrics = [...currentMetrics, newMetric] as ExperimentQueryDTO[]; | ||
|
|
||
| this.updateExperimentMetrics(experiment, updatedMetrics); | ||
| } | ||
|
|
||
| /** | ||
| * Update an existing metric in an experiment | ||
| */ | ||
| updateMetric(experiment: Experiment, sourceMetric: ExperimentQueryDTO, metricData: ExperimentQueryDTO): void { | ||
| const currentMetrics = [...(experiment.queries || [])]; | ||
| const updatedMetrics = currentMetrics.map((metric) => | ||
| metric.id === sourceMetric.id | ||
| ? { | ||
| ...metric, | ||
| ...metricData, | ||
| } | ||
| : metric | ||
| ); | ||
|
|
||
| this.updateExperimentMetrics(experiment, updatedMetrics); | ||
| } | ||
|
|
||
| /** | ||
| * Delete a metric from an experiment | ||
| */ | ||
| deleteMetric(experiment: Experiment, metricToDelete: ExperimentQueryDTO): void { | ||
| const currentMetrics = [...(experiment.queries || [])]; | ||
| const updatedMetrics = currentMetrics.filter((metric) => metric.id !== metricToDelete.id); | ||
|
|
||
| this.updateExperimentMetrics(experiment, updatedMetrics); | ||
| } | ||
|
|
||
| /** | ||
| * Common method to update experiment metrics | ||
| */ | ||
| private updateExperimentMetrics(experiment: Experiment, updatedMetrics: ExperimentQueryDTO[]): void { | ||
| const updateRequest: UpdateExperimentMetricsRequest = { | ||
| experiment, | ||
| metrics: updatedMetrics, | ||
| }; | ||
|
|
||
| this.experimentService.updateExperimentMetrics(updateRequest); | ||
| } | ||
| } | ||
|
zackcl marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.