add middleware to handle 403 errors (#5245)

* add middleware to handle 403 errors

* remove log

* add logic to warn the user if not all requested images could be deleted

* lint

* fix copy

* feat(ui): simplify batchEnqueuedListener error toast logic

* feat(ui): use translations for error messages

* chore(ui): lint

---------

Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
This commit is contained in:
Mary Hipp Rogers
2023-12-07 19:26:15 -05:00
committed by GitHub
parent db58efbe65
commit b519b6e1e0
7 changed files with 60 additions and 50 deletions

View File

@ -27,6 +27,8 @@ import {
imagesSelectors,
} from 'services/api/util';
import { boardsApi } from './boards';
import { addToast } from 'features/system/store/systemSlice';
import { t } from 'i18next';
export const imagesApi = api.injectEndpoints({
endpoints: (build) => ({
@ -208,6 +210,16 @@ export const imagesApi = api.injectEndpoints({
try {
const { data } = await queryFulfilled;
if (data.deleted_images.length < imageDTOs.length) {
dispatch(
addToast({
title: t('gallery.problemDeletingImages'),
description: t('gallery.problemDeletingImagesDesc'),
status: 'warning',
})
);
}
// convert to an object so we can access the successfully delete image DTOs by name
const groupedImageDTOs = keyBy(imageDTOs, 'image_name');