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

fix(ui): show error in UI if signal filter name already exists #5606

Merged
merged 4 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 12 additions & 30 deletions src/dispatch/signal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,9 @@ def create_engagement(
db_session=db_session, creator=current_user, signal_engagement_in=signal_engagement_in
)
except IntegrityError:
raise ValidationError(
[
ErrorWrapper(
ExistsError(msg="A signal engagement with this name already exists."),
loc="name",
)
],
model=SignalEngagementRead,
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
whitdog47 marked this conversation as resolved.
Show resolved Hide resolved
detail=[{"msg": "A signal engagement with this name already exists."}],
) from None


Expand Down Expand Up @@ -195,14 +190,9 @@ def update_engagement(
signal_engagement_in=signal_engagement_in,
)
except IntegrityError:
raise ValidationError(
[
ErrorWrapper(
ExistsError(msg="A signal engagement with this name already exists."),
loc="name",
)
],
model=SignalEngagementUpdate,
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=[{"msg": "A signal engagement with this name already exists."}],
) from None

return signal_engagement
Expand All @@ -220,13 +210,9 @@ def create_filter(
db_session=db_session, creator=current_user, signal_filter_in=signal_filter_in
)
except IntegrityError:
raise ValidationError(
[
ErrorWrapper(
ExistsError(msg="A signal filter with this name already exists."), loc="name"
)
],
model=SignalFilterRead,
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=[{"msg": "A signal filter with this name already exists."}],
) from None


Expand All @@ -253,13 +239,9 @@ def update_filter(
db_session=db_session, signal_filter=signal_filter, signal_filter_in=signal_filter_in
)
except IntegrityError:
raise ValidationError(
[
ErrorWrapper(
ExistsError(msg="A signal filter with this name already exists."), loc="name"
)
],
model=SignalFilterUpdate,
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=[{"msg": "A signal filter with this name already exists."}],
) from None

return signal_filter
Expand Down
19 changes: 16 additions & 3 deletions src/dispatch/static/dispatch/src/signal/engagement/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ const actions = {
commit("RESET_SELECTED")
return resp.data
})
.catch((error) => {
console.log(error)
.catch((err) => {
let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ")
commit(
"notification_backend/addBeNotification",
{ text: `Error trying to save: ${errorText}`, type: "exception" },
{ root: true }
)
commit("RESET_SELECTED")
commit("SET_SELECTED_LOADING", false)
})
} else {
Expand All @@ -55,7 +61,14 @@ const actions = {
)
commit("SET_SELECTED_LOADING", false)
})
.catch(() => {
.catch((err) => {
let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ")
commit(
"notification_backend/addBeNotification",
{ text: `Error trying to save: ${errorText}`, type: "exception" },
{ root: true }
)
commit("RESET_SELECTED")
commit("SET_SELECTED_LOADING", false)
})
}
Expand Down
18 changes: 16 additions & 2 deletions src/dispatch/static/dispatch/src/signal/filter/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ const actions = {
commit("SET_DIALOG_CREATE_EDIT", false)
return resp.data
})
.catch(() => {
.catch((err) => {
let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ")
commit(
"notification_backend/addBeNotification",
{ text: `Error trying to save: ${errorText}`, type: "exception" },
{ root: true }
)
commit("RESET_SELECTED")
commit("SET_SELECTED_LOADING", false)
})
} else {
Expand All @@ -78,7 +85,14 @@ const actions = {
)
commit("SET_SELECTED_LOADING", false)
})
.catch(() => {
.catch((err) => {
let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ")
commit(
"notification_backend/addBeNotification",
{ text: `Error trying to save: ${errorText}`, type: "exception" },
{ root: true }
)
commit("RESET_SELECTED")
commit("SET_SELECTED_LOADING", false)
})
}
Expand Down
Loading