Skip to content
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

feat: UI for adding alerts for dashboard tiles #562

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from

Conversation

ernestii
Copy link
Contributor

@ernestii ernestii commented Jan 20, 2025

Screenshot 2025-01-20 at 3 34 13 PM

Copy link

changeset-bot bot commented Jan 20, 2025

🦋 Changeset detected

Latest commit: 6616f30

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ernestii ernestii marked this pull request as draft January 20, 2025 18:37
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch 5 times, most recently from a813a05 to 9aa649b Compare January 20, 2025 21:33
@ernestii ernestii marked this pull request as ready for review January 20, 2025 21:34
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 9aa649b to 67ee87d Compare January 21, 2025 04:10
@ernestii ernestii force-pushed the ernest-/hdx-1329-saved-search-alert-ui-threshold-chart branch 2 times, most recently from 21dcf30 to a90737e Compare January 21, 2025 04:36
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch 3 times, most recently from 6dda29e to 052e209 Compare January 21, 2025 05:34
@ernestii ernestii force-pushed the ernest-/hdx-1329-saved-search-alert-ui-threshold-chart branch from a90737e to a41f979 Compare January 21, 2025 05:48
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 052e209 to e7e9885 Compare January 21, 2025 05:48
await Alert.find({
dashboard: { $in: _dashboards.map(d => d._id) },
source: 'tile',
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

double check we want to select all fields from the alert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, I think all data is fine, we need full channel to populate the form

...d,
tiles: d.tiles.map(t => ({
...t,
config: { ...t.config, alert: alertsByTileId[t.id]?.[0] },
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason we want to add alert field to config instead of adding it to the top level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason what that it's easier to integrate alert form into Edit Chart form, since we can use same react-hook-form controller (it uses SavedChartConfig schema)

Comment on lines 67 to 83
// Create related alerts
for (const tile of dashboard.tiles) {
if (!tile.config.alert) {
await Alert.findOneAndUpdate(
{
dashboard: newDashboard._id,
tileId: tile.id,
source: 'tile',
team: teamId,
},
{ ...tile.config.alert },
{ new: true, upsert: true },
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm...maybe we don't want to create an alert here (SRP). I wonder if we should fire a request at the modal level instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm kinda on the fence... i think this implementation is more convenient in terms of API, as it prevents partial failure scenario on FE + easier to build forms (as long as tile.config.alert is always consistent with Alert type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lmk if we should implement it the way we did in the v1

@ernestii ernestii force-pushed the ernest-/hdx-1329-saved-search-alert-ui-threshold-chart branch from a41f979 to 74934e8 Compare January 24, 2025 04:04
@ernestii ernestii force-pushed the ernest-/hdx-1329-saved-search-alert-ui-threshold-chart branch from 74934e8 to 4a7a5d4 Compare January 24, 2025 04:16
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch 2 times, most recently from aac87a6 to 0d4adc2 Compare January 24, 2025 04:56
@ernestii
Copy link
Contributor Author

rebased and added team: teamId filters, going to address the rest tmr

@ernestii ernestii force-pushed the ernest-/hdx-1329-saved-search-alert-ui-threshold-chart branch from 4a7a5d4 to 85002c3 Compare January 24, 2025 16:25
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 0d4adc2 to b54104b Compare January 25, 2025 02:11
@ernestii ernestii changed the base branch from ernest-/hdx-1329-saved-search-alert-ui-threshold-chart to v2 January 25, 2025 02:12
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from b54104b to 464adef Compare January 25, 2025 02:15
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 464adef to 9880cb2 Compare January 25, 2025 03:11
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 9880cb2 to ae2dbdf Compare January 25, 2025 03:14
@ernestii ernestii requested a review from wrn14897 January 26, 2025 04:24
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from f0c8364 to 6616f30 Compare January 26, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants