mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Delete Query UX: Better error handling if query is a part of policies (#2278)
This commit is contained in:
parent
7d5821f527
commit
1b2b926380
2 changed files with 21 additions and 7 deletions
1
changes/issue-2059-delete-query-in-policy-ux
Normal file
1
changes/issue-2059-delete-query-in-policy-ux
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Better error handling when a user tries to delete a query that is set in a policy
|
||||
|
|
@ -108,13 +108,26 @@ const ManageQueriesPage = (): JSX.Element => {
|
|||
toggleRemoveQueryModal();
|
||||
dispatch(queryActions.loadAll());
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(
|
||||
renderFlash(
|
||||
"error",
|
||||
`Unable to remove ${queryOrQueries}. Please try again.`
|
||||
)
|
||||
);
|
||||
.catch((response) => {
|
||||
if (
|
||||
response.base.slice(0, 47) ===
|
||||
"the operation violates a foreign key constraint"
|
||||
) {
|
||||
dispatch(
|
||||
renderFlash(
|
||||
"error",
|
||||
`Could not delete query because this query is used as a policy. First remove the policy and then try deleting the query again.`
|
||||
)
|
||||
);
|
||||
dispatch(queryActions.loadAll());
|
||||
} else {
|
||||
dispatch(
|
||||
renderFlash(
|
||||
"error",
|
||||
`Unable to remove ${queryOrQueries}. Please try again.`
|
||||
)
|
||||
);
|
||||
}
|
||||
toggleRemoveQueryModal();
|
||||
});
|
||||
}, [dispatch, selectedQueryIds, toggleRemoveQueryModal]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue