-
-
Notifications
You must be signed in to change notification settings - Fork 601
fix: orphaned monitor page components #1911
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ import { | |
| monitorsToStatusReport, | ||
| notification, | ||
| notificationsToMonitors, | ||
| pageComponent, | ||
| privateLocation, | ||
| privateLocationToMonitors, | ||
| selectIncidentSchema, | ||
|
|
@@ -85,6 +86,9 @@ export const monitorRouter = createTRPCRouter({ | |
| await tx | ||
| .delete(maintenancesToMonitors) | ||
| .where(eq(maintenancesToMonitors.monitorId, monitorToDelete.id)); | ||
| await tx | ||
| .delete(pageComponent) | ||
| .where(eq(pageComponent.monitorId, monitorToDelete.id)); | ||
| }); | ||
mxkaske marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }), | ||
|
|
||
|
|
@@ -131,6 +135,9 @@ export const monitorRouter = createTRPCRouter({ | |
| await tx | ||
| .delete(maintenancesToMonitors) | ||
| .where(inArray(maintenancesToMonitors.monitorId, opts.input.ids)); | ||
| await tx | ||
| .delete(pageComponent) | ||
| .where(inArray(pageComponent.monitorId, opts.input.ids)); | ||
| }); | ||
|
Comment on lines
132
to
137
|
||
| }), | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,6 +157,18 @@ export const pageComponentRouter = createTRPCRouter({ | |
|
|
||
| const pageComponentLimit = opts.ctx.workspace.limits["page-components"]; | ||
|
|
||
| // Validate the incoming component count against the limit | ||
| const newComponentCount = | ||
| opts.input.components.length + | ||
| opts.input.groups.reduce((sum, g) => sum + g.components.length, 0); | ||
|
|
||
| if (newComponentCount > pageComponentLimit) { | ||
| throw new TRPCError({ | ||
|
||
| code: "FORBIDDEN", | ||
| message: "You reached your page component limits.", | ||
| }); | ||
| } | ||
|
|
||
| // Get existing state | ||
| const existingComponents = await tx | ||
| .select() | ||
|
|
@@ -169,13 +181,6 @@ export const pageComponentRouter = createTRPCRouter({ | |
| ) | ||
| .all(); | ||
|
|
||
| if (existingComponents.length >= pageComponentLimit) { | ||
| throw new TRPCError({ | ||
| code: "FORBIDDEN", | ||
| message: "You reached your page component limits.", | ||
| }); | ||
| } | ||
|
|
||
| const existingGroups = await tx | ||
| .select() | ||
| .from(pageComponentGroup) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.