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

Merged
merged 7 commits into from
Jan 28, 2025

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: 72c9926

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)

@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 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 3 times, most recently 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
@@ -346,6 +347,7 @@ export const SavedChartConfigSchema = z.intersection(
z.object({
name: z.string(),
source: z.string(),
alert: AlertSchemaBase.optional(),
Copy link
Contributor

@wrn14897 wrn14897 Jan 26, 2025

Choose a reason for hiding this comment

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

isn't this supposed to be AlertSchema ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really, since tile alerts are managed via /dashboard routes, we already know its source (Tile) and dashboardId and tileId, so we only need alert configuration here

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. But don't we still attach the redundant fields? from getDashboardAlerts, we fetch all fields in the alert. I guess the same thing applied to

alerts: z.array(AlertSchema).optional(),

@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 6616f30 to aafd130 Compare January 27, 2025 00:08
@ernestii ernestii requested a review from wrn14897 January 27, 2025 00:09
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch 2 times, most recently from 9cf83f4 to 48bdb7e Compare January 27, 2025 03:50
@ernestii ernestii force-pushed the ernest-/hdx-1303-tiles-alerting-ui branch from 48bdb7e to 1ea8af3 Compare January 27, 2025 03:57
Comment on lines +152 to +153
Object.entries(alertsByTile).map(async ([tileId, alert]) => {
return await Alert.findOneAndUpdate(
Copy link
Contributor

@wrn14897 wrn14897 Jan 27, 2025

Choose a reason for hiding this comment

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

nit: this async and await seem redundant

@wrn14897
Copy link
Contributor

The rest of the comments are minor. I'm going to clean this PR up and merge it

@kodiakhq kodiakhq bot merged commit b79433e into v2 Jan 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants