From 2620c972cefb9d1ac1871940523064753d3c7d89 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Thu, 31 Aug 2023 17:17:03 +1000 Subject: [PATCH 01/11] Add delete-image UI and stub reducers --- src/features/loupe/FullSizeImage.jsx | 19 ++++++++++++++++--- src/features/review/reviewSlice.js | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/features/loupe/FullSizeImage.jsx b/src/features/loupe/FullSizeImage.jsx index af102f05..ddb900b0 100644 --- a/src/features/loupe/FullSizeImage.jsx +++ b/src/features/loupe/FullSizeImage.jsx @@ -1,13 +1,13 @@ import React, { useState, useRef, useEffect } from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { Cross2Icon, PlusIcon } from '@radix-ui/react-icons'; +import { Cross2Icon, PlusIcon, TrashIcon } from '@radix-ui/react-icons'; import { useResizeObserver } from '../../app/utils'; import { styled } from '../../theme/stitches.config'; // import { CircleSpinner, SpinnerOverlay } from '../../components/Spinner'; import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice'; import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles'; import { drawBboxStart, selectIsDrawingBbox} from './loupeSlice'; -import { selectWorkingImages, labelValidated, markedEmpty } from '../review/reviewSlice'; +import { selectWorkingImages, labelValidated, markedEmpty, deleteImage } from '../review/reviewSlice'; import { Image } from '../../components/Image'; import BoundingBox from './BoundingBox'; import DrawBboxOverlay from './DrawBboxOverlay'; @@ -143,6 +143,8 @@ const FullSizeImage = ({ image, focusIndex }) => { const handleAddObjectButtonClick = () => dispatch(drawBboxStart()); + const handleDeleteButtonClick = () => dispatch(deleteImage(image._id)); + return ( {isDrawingBbox && @@ -190,6 +192,14 @@ const FullSizeImage = ({ image, focusIndex }) => { Mark empty + + + + + Delete + @@ -197,6 +207,9 @@ const FullSizeImage = ({ image, focusIndex }) => { {hasRole(userRoles, WRITE_OBJECTS_ROLES) && + + Delete + Mark empty @@ -215,4 +228,4 @@ const FullSizeImage = ({ image, focusIndex }) => { ); }; -export default FullSizeImage; \ No newline at end of file +export default FullSizeImage; diff --git a/src/features/review/reviewSlice.js b/src/features/review/reviewSlice.js index 520585b7..8df6ab3a 100644 --- a/src/features/review/reviewSlice.js +++ b/src/features/review/reviewSlice.js @@ -124,6 +124,15 @@ export const reviewSlice = createSlice({ state.loadingStates.labels.errors.splice(index, 1); }, + deleteImageStart: (state, { payload}) => { + // TODO + }, + + deleteImageSuccess: (state, { payload }) => { + state.workingImages = state.workingImages.filter( + ({ _id }) => _id !== payload + ); + } }, extraReducers: (builder) => { @@ -153,8 +162,16 @@ export const { editLabelFailure, editLabelSuccess, dismissLabelsError, + deleteImageStart, + deleteImageSuccess, } = reviewSlice.actions; +export const deleteImage = (id) => async (dispatch) => { + dispatch(deleteImageStart()); + // TODO: Submit delete image + dispatch(deleteImageSuccess(id)) +} + // editLabel thunk export const editLabel = (operation, entity, payload, projId) => { return async (dispatch, getState) => { From 74b00b77eb40a2d66e19efdfa0df225d83860f2e Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Thu, 28 Sep 2023 11:47:04 +1000 Subject: [PATCH 02/11] Wire delete-image API --- src/api/buildQuery.js | 15 +++++++++++ src/features/review/reviewSlice.js | 43 +++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/api/buildQuery.js b/src/api/buildQuery.js index cb11bfe9..2191c74e 100644 --- a/src/api/buildQuery.js +++ b/src/api/buildQuery.js @@ -190,6 +190,21 @@ const queries = { } }, + deleteImage: (input) => { + return { + template: ` + mutation DeleteImage($input: DeleteImageInput!) { + deleteImage(input: $input) { + message + } + } + `, + variables: { + input + } + } + }, + getImages: ({ filters, pageInfo, page }) => ({ template: ` query GetImages($input: QueryImagesInput!) { diff --git a/src/features/review/reviewSlice.js b/src/features/review/reviewSlice.js index 8df6ab3a..3fb88d9e 100644 --- a/src/features/review/reviewSlice.js +++ b/src/features/review/reviewSlice.js @@ -17,6 +17,11 @@ const initialState = { isLoading: false, operation: null, /* 'fetching', 'updating', 'deleting' */ errors: null, + }, + images: { + isLoading: false, + operation: null, /* 'deleting' */ + errors: null, } } }; @@ -124,15 +129,24 @@ export const reviewSlice = createSlice({ state.loadingStates.labels.errors.splice(index, 1); }, - deleteImageStart: (state, { payload}) => { - // TODO + deleteImageStart: (state) => { + state.loadingStates.images.isLoading = true; + state.loadingStates.images.operation = 'deleting'; + state.loadingStates.images.error = null; }, deleteImageSuccess: (state, { payload }) => { state.workingImages = state.workingImages.filter( ({ _id }) => _id !== payload ); - } + state.loadingStates.images.isLoading = false; + state.loadingStates.images.operation = null; + }, + + deleteImageError: (state, { payload }) => { + state.loadingStates.images.isLoading = false; + state.loadingStates.images.error = payload; + }, }, extraReducers: (builder) => { @@ -166,10 +180,27 @@ export const { deleteImageSuccess, } = reviewSlice.actions; -export const deleteImage = (id) => async (dispatch) => { +export const deleteImage = (imageId) => async (dispatch, getState) => { dispatch(deleteImageStart()); - // TODO: Submit delete image - dispatch(deleteImageSuccess(id)) + try { + const currentUser = await Auth.currentAuthenticatedUser(); + const token = currentUser.getSignInUserSession().getIdToken().getJwtToken(); + + const projects = getState().projects.projects; + const selectedProj = projects.find((proj) => proj.selected); + + if (token && selectedProj) { + const r = await call({ + projId: selectedProj._id, + request: 'deleteImage', + input: { imageId }, + }); + } + dispatch(deleteImageSuccess(imageId)); + } catch (err) { + console.log(`error attempting to delete image: `, err); + dispatch(deleteImageError(err)); + } } // editLabel thunk From ce5d4d099499c493ab3d440edae1ce78b8ac1ee9 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Mon, 2 Oct 2023 11:51:43 +1100 Subject: [PATCH 03/11] Use deleteImages endpoint --- src/api/buildQuery.js | 6 +++--- src/features/loupe/FullSizeImage.jsx | 4 ++-- src/features/review/reviewSlice.js | 25 +++++++++++++------------ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/api/buildQuery.js b/src/api/buildQuery.js index 7c0cd4af..007cb910 100644 --- a/src/api/buildQuery.js +++ b/src/api/buildQuery.js @@ -190,11 +190,11 @@ const queries = { } }, - deleteImage: (input) => { + deleteImages: (input) => { return { template: ` - mutation DeleteImage($input: DeleteImageInput!) { - deleteImage(input: $input) { + mutation DeleteImages($input: DeleteImagesInput!) { + deleteImages(input: $input) { message } } diff --git a/src/features/loupe/FullSizeImage.jsx b/src/features/loupe/FullSizeImage.jsx index 61779479..f563887f 100644 --- a/src/features/loupe/FullSizeImage.jsx +++ b/src/features/loupe/FullSizeImage.jsx @@ -7,7 +7,7 @@ import { styled } from '../../theme/stitches.config'; import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice'; import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles'; import { drawBboxStart, selectIsDrawingBbox} from './loupeSlice'; -import { selectWorkingImages, labelsValidated, markedEmpty, deleteImage } from '../review/reviewSlice'; +import { selectWorkingImages, labelsValidated, markedEmpty, deleteImages } from '../review/reviewSlice'; import { Image } from '../../components/Image'; import BoundingBox from './BoundingBox'; import DrawBboxOverlay from './DrawBboxOverlay'; @@ -145,7 +145,7 @@ const FullSizeImage = ({ image, focusIndex }) => { const handleAddObjectButtonClick = () => dispatch(drawBboxStart()); - const handleDeleteButtonClick = () => dispatch(deleteImage(image._id)); + const handleDeleteButtonClick = () => dispatch(deleteImages([image._id])); return ( diff --git a/src/features/review/reviewSlice.js b/src/features/review/reviewSlice.js index 6052175d..d7ab1ae1 100644 --- a/src/features/review/reviewSlice.js +++ b/src/features/review/reviewSlice.js @@ -141,21 +141,21 @@ export const reviewSlice = createSlice({ state.loadingStates.labels.errors.splice(index, 1); }, - deleteImageStart: (state) => { + deleteImagesStart: (state) => { state.loadingStates.images.isLoading = true; state.loadingStates.images.operation = 'deleting'; state.loadingStates.images.error = null; }, - deleteImageSuccess: (state, { payload }) => { + deleteImagesSuccess: (state, { payload }) => { state.workingImages = state.workingImages.filter( - ({ _id }) => _id !== payload + ({ _id }) => !payload.includes(_id) ); state.loadingStates.images.isLoading = false; state.loadingStates.images.operation = null; }, - deleteImageError: (state, { payload }) => { + deleteImagesError: (state, { payload }) => { state.loadingStates.images.isLoading = false; state.loadingStates.images.error = payload; }, @@ -188,12 +188,13 @@ export const { editLabelFailure, editLabelSuccess, dismissLabelsError, - deleteImageStart, - deleteImageSuccess, + deleteImagesStart, + deleteImagesSuccess, + deleteImagesError, } = reviewSlice.actions; -export const deleteImage = (imageId) => async (dispatch, getState) => { - dispatch(deleteImageStart()); +export const deleteImages = (imageIds) => async (dispatch, getState) => { + dispatch(deleteImagesStart()); try { const currentUser = await Auth.currentAuthenticatedUser(); const token = currentUser.getSignInUserSession().getIdToken().getJwtToken(); @@ -204,14 +205,14 @@ export const deleteImage = (imageId) => async (dispatch, getState) => { if (token && selectedProj) { const r = await call({ projId: selectedProj._id, - request: 'deleteImage', - input: { imageId }, + request: 'deleteImages', + input: { imageIds }, }); } - dispatch(deleteImageSuccess(imageId)); + dispatch(deleteImagesSuccess(imageIds)); } catch (err) { console.log(`error attempting to delete image: `, err); - dispatch(deleteImageError(err)); + dispatch(deleteImagesError(err)); } } From a2f6a9352a185ae70fce0f6187026da0171a57e1 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Mon, 2 Oct 2023 11:56:41 +1100 Subject: [PATCH 04/11] Restrict delete image in context menu --- src/features/loupe/FullSizeImage.jsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/features/loupe/FullSizeImage.jsx b/src/features/loupe/FullSizeImage.jsx index f563887f..82c88818 100644 --- a/src/features/loupe/FullSizeImage.jsx +++ b/src/features/loupe/FullSizeImage.jsx @@ -5,7 +5,7 @@ import { useResizeObserver } from '../../app/utils'; import { styled } from '../../theme/stitches.config'; // import { CircleSpinner, SpinnerOverlay } from '../../components/Spinner'; import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice'; -import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles'; +import { hasRole, WRITE_OBJECTS_ROLES, WRITE_IMAGES_ROLES } from '../../auth/roles'; import { drawBboxStart, selectIsDrawingBbox} from './loupeSlice'; import { selectWorkingImages, labelsValidated, markedEmpty, deleteImages } from '../review/reviewSlice'; import { Image } from '../../components/Image'; @@ -194,14 +194,16 @@ const FullSizeImage = ({ image, focusIndex }) => { Mark empty - - - - - Delete - + {hasRole(userRoles, WRITE_IMAGES_ROLES) && + + + + + Delete + + } From 7a4199a40123506f023ef116fcddd56cb8e009e1 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Wed, 4 Oct 2023 16:58:49 +1100 Subject: [PATCH 05/11] Move delete image action to imageSlice --- src/features/images/imagesSlice.js | 42 ++++++++++++++++++++++ src/features/loupe/FullSizeImage.jsx | 3 +- src/features/review/reviewSlice.js | 54 ++++------------------------ 3 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/features/images/imagesSlice.js b/src/features/images/imagesSlice.js index 61e67fa2..1cc62125 100644 --- a/src/features/images/imagesSlice.js +++ b/src/features/images/imagesSlice.js @@ -240,6 +240,22 @@ export const imagesSlice = createSlice({ const index = payload; state.loadingStates.export.errors.splice(index, 1); }, + + deleteImagesStart: (state) => { + state.loadingStates.images.isLoading = true; + state.loadingStates.images.operation = 'deleting'; + state.loadingStates.images.error = null; + }, + + deleteImagesSuccess: (state, { payload }) => { + state.loadingStates.images.isLoading = false; + state.loadingStates.images.operation = null; + }, + + deleteImagesError: (state, { payload }) => { + state.loadingStates.images.isLoading = false; + state.loadingStates.images.error = payload; + }, }, }); @@ -268,6 +284,9 @@ export const { exportFailure, clearExport, dismissExportError, + deleteImagesStart, + deleteImagesSuccess, + deleteImagesError, } = imagesSlice.actions; // fetchImages thunk @@ -451,6 +470,29 @@ export const getExportStatus = (documentId) => { }; }; +export const deleteImages = (imageIds) => async (dispatch, getState) => { + dispatch(deleteImagesStart(imageIds)); + try { + const currentUser = await Auth.currentAuthenticatedUser(); + const token = currentUser.getSignInUserSession().getIdToken().getJwtToken(); + + const projects = getState().projects.projects; + const selectedProj = projects.find((proj) => proj.selected); + + if (token && selectedProj) { + const r = await call({ + projId: selectedProj._id, + request: 'deleteImages', + input: { imageIds }, + }); + } + dispatch(deleteImagesSuccess(imageIds)); + } catch (err) { + console.log(`error attempting to delete image: `, err); + dispatch(deleteImagesError(err)); + } +} + export const selectPageInfo = state => state.images.pageInfo; export const selectPaginatedField = state => state.images.pageInfo.paginatedField; export const selectSortAscending = state => state.images.pageInfo.sortAscending; diff --git a/src/features/loupe/FullSizeImage.jsx b/src/features/loupe/FullSizeImage.jsx index 82c88818..923cce97 100644 --- a/src/features/loupe/FullSizeImage.jsx +++ b/src/features/loupe/FullSizeImage.jsx @@ -7,7 +7,8 @@ import { styled } from '../../theme/stitches.config'; import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice'; import { hasRole, WRITE_OBJECTS_ROLES, WRITE_IMAGES_ROLES } from '../../auth/roles'; import { drawBboxStart, selectIsDrawingBbox} from './loupeSlice'; -import { selectWorkingImages, labelsValidated, markedEmpty, deleteImages } from '../review/reviewSlice'; +import { selectWorkingImages, labelsValidated, markedEmpty } from '../review/reviewSlice'; +import { deleteImages } from '../images/imagesSlice'; import { Image } from '../../components/Image'; import BoundingBox from './BoundingBox'; import DrawBboxOverlay from './DrawBboxOverlay'; diff --git a/src/features/review/reviewSlice.js b/src/features/review/reviewSlice.js index d7ab1ae1..52a53b77 100644 --- a/src/features/review/reviewSlice.js +++ b/src/features/review/reviewSlice.js @@ -2,7 +2,7 @@ import { createSlice, createAction } from '@reduxjs/toolkit'; import { Auth } from 'aws-amplify'; import { call } from '../../api'; import { findImage, findObject, findLabel } from '../../app/utils'; -import { getImagesSuccess, clearImages } from '../images/imagesSlice'; +import { getImagesSuccess, clearImages, deleteImagesStart } from '../images/imagesSlice'; const initialState = { workingImages: [], @@ -139,26 +139,7 @@ export const reviewSlice = createSlice({ dismissLabelsError: (state, { payload }) => { const index = payload; state.loadingStates.labels.errors.splice(index, 1); - }, - - deleteImagesStart: (state) => { - state.loadingStates.images.isLoading = true; - state.loadingStates.images.operation = 'deleting'; - state.loadingStates.images.error = null; - }, - - deleteImagesSuccess: (state, { payload }) => { - state.workingImages = state.workingImages.filter( - ({ _id }) => !payload.includes(_id) - ); - state.loadingStates.images.isLoading = false; - state.loadingStates.images.operation = null; - }, - - deleteImagesError: (state, { payload }) => { - state.loadingStates.images.isLoading = false; - state.loadingStates.images.error = payload; - }, + } }, extraReducers: (builder) => { @@ -170,6 +151,11 @@ export const reviewSlice = createSlice({ .addCase(clearImages, (state) => { state.workingImages = []; }) + .addCase(deleteImagesStart, (state, { payload }) => { + state.workingImages = state.workingImages.filter( + ({ _id }) => !payload.includes(_id) + ); + }) }, }); @@ -188,34 +174,8 @@ export const { editLabelFailure, editLabelSuccess, dismissLabelsError, - deleteImagesStart, - deleteImagesSuccess, - deleteImagesError, } = reviewSlice.actions; -export const deleteImages = (imageIds) => async (dispatch, getState) => { - dispatch(deleteImagesStart()); - try { - const currentUser = await Auth.currentAuthenticatedUser(); - const token = currentUser.getSignInUserSession().getIdToken().getJwtToken(); - - const projects = getState().projects.projects; - const selectedProj = projects.find((proj) => proj.selected); - - if (token && selectedProj) { - const r = await call({ - projId: selectedProj._id, - request: 'deleteImages', - input: { imageIds }, - }); - } - dispatch(deleteImagesSuccess(imageIds)); - } catch (err) { - console.log(`error attempting to delete image: `, err); - dispatch(deleteImagesError(err)); - } -} - // editLabel thunk export const editLabel = (operation, entity, payload, projId) => { return async (dispatch, getState) => { From c5bbdb6141521de0f85553af447ea0671b9d0ec8 Mon Sep 17 00:00:00 2001 From: Nathaniel Rindlaub Date: Fri, 20 Oct 2023 09:15:16 -0700 Subject: [PATCH 06/11] Remove deleted images from state after successful mutation --- src/features/review/reviewSlice.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features/review/reviewSlice.js b/src/features/review/reviewSlice.js index 52a53b77..759abd43 100644 --- a/src/features/review/reviewSlice.js +++ b/src/features/review/reviewSlice.js @@ -2,7 +2,7 @@ import { createSlice, createAction } from '@reduxjs/toolkit'; import { Auth } from 'aws-amplify'; import { call } from '../../api'; import { findImage, findObject, findLabel } from '../../app/utils'; -import { getImagesSuccess, clearImages, deleteImagesStart } from '../images/imagesSlice'; +import { getImagesSuccess, clearImages, deleteImagesSuccess } from '../images/imagesSlice'; const initialState = { workingImages: [], @@ -151,7 +151,7 @@ export const reviewSlice = createSlice({ .addCase(clearImages, (state) => { state.workingImages = []; }) - .addCase(deleteImagesStart, (state, { payload }) => { + .addCase(deleteImagesSuccess, (state, { payload }) => { state.workingImages = state.workingImages.filter( ({ _id }) => !payload.includes(_id) ); From b29ee427e4b4beb5b7eae83cd9812fba47a9b514 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Mon, 23 Oct 2023 16:26:45 +1100 Subject: [PATCH 07/11] Remove unused state --- src/features/review/reviewSlice.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/features/review/reviewSlice.js b/src/features/review/reviewSlice.js index 759abd43..53440431 100644 --- a/src/features/review/reviewSlice.js +++ b/src/features/review/reviewSlice.js @@ -17,11 +17,6 @@ const initialState = { isLoading: false, operation: null, /* 'fetching', 'updating', 'deleting' */ errors: null, - }, - images: { - isLoading: false, - operation: null, /* 'deleting' */ - errors: null, } } }; From f185097dba8f694b41362adc2d38362e77cfc120 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Mon, 23 Oct 2023 16:31:47 +1100 Subject: [PATCH 08/11] Guard delete-image with DELETE_IMAGES role --- src/auth/roles.js | 1 + src/features/loupe/FullSizeImage.jsx | 40 +++++++++++++++------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/auth/roles.js b/src/auth/roles.js index 9b590b1d..b7209940 100644 --- a/src/auth/roles.js +++ b/src/auth/roles.js @@ -12,6 +12,7 @@ export const WRITE_DEPLOYMENTS_ROLES = [MANAGER]; export const WRITE_AUTOMATION_RULES_ROLES = [MANAGER]; export const WRITE_CAMERA_REGISTRATION_ROLES = [MANAGER]; export const QUERY_WITH_CUSTOM_FILTER = [MANAGER]; +export const DELETE_IMAGES = [MANAGER, MEMBER]; export const hasRole = (currRoles, targetRoles = []) => ( currRoles && (currRoles.includes(SUPER_USER) || currRoles.some((role) => targetRoles.includes(role))) diff --git a/src/features/loupe/FullSizeImage.jsx b/src/features/loupe/FullSizeImage.jsx index 923cce97..c3d73b3b 100644 --- a/src/features/loupe/FullSizeImage.jsx +++ b/src/features/loupe/FullSizeImage.jsx @@ -5,7 +5,7 @@ import { useResizeObserver } from '../../app/utils'; import { styled } from '../../theme/stitches.config'; // import { CircleSpinner, SpinnerOverlay } from '../../components/Spinner'; import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice'; -import { hasRole, WRITE_OBJECTS_ROLES, WRITE_IMAGES_ROLES } from '../../auth/roles'; +import { hasRole, WRITE_OBJECTS_ROLES, DELETE_IMAGES } from '../../auth/roles'; import { drawBboxStart, selectIsDrawingBbox} from './loupeSlice'; import { selectWorkingImages, labelsValidated, markedEmpty } from '../review/reviewSlice'; import { deleteImages } from '../images/imagesSlice'; @@ -195,7 +195,7 @@ const FullSizeImage = ({ image, focusIndex }) => { Mark empty - {hasRole(userRoles, WRITE_IMAGES_ROLES) && + {hasRole(userRoles, DELETE_IMAGES) && @@ -210,25 +210,29 @@ const FullSizeImage = ({ image, focusIndex }) => { - {hasRole(userRoles, WRITE_OBJECTS_ROLES) && - + + {hasRole(userRoles, DELETE_IMAGES) && Delete - - Mark empty - - - Add object - - - } + } + {hasRole(userRoles, WRITE_OBJECTS_ROLES) && + <> + + Mark empty + + + Add object + + + } + ); }; From 81e72369df9f1b756696222d138297747ffbab27 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Mon, 23 Oct 2023 17:30:28 +1100 Subject: [PATCH 09/11] Fix image error display --- src/components/ErrorAlerts.jsx | 1 - src/features/images/imagesSlice.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ErrorAlerts.jsx b/src/components/ErrorAlerts.jsx index e41bc209..402ac36b 100644 --- a/src/components/ErrorAlerts.jsx +++ b/src/components/ErrorAlerts.jsx @@ -54,7 +54,6 @@ const ErrorAlerts = () => { const statsErrors = useSelector(selectStatsErrors); const exportErrors = useSelector(selectExportErrors); - const enrichedErrors = [ enrichErrors(labelsErrors, 'Label Error', 'labels'), enrichErrors(projectsErrors, 'Project Error', 'projects'), diff --git a/src/features/images/imagesSlice.js b/src/features/images/imagesSlice.js index 1cc62125..c2db3edc 100644 --- a/src/features/images/imagesSlice.js +++ b/src/features/images/imagesSlice.js @@ -97,7 +97,7 @@ export const imagesSlice = createSlice({ dismissImagesError: (state, { payload }) => { const index = payload; - state.loadingStates.image.errors.splice(index, 1); + state.loadingStates.images.errors.splice(index, 1); }, preFocusImageStart: (state, { payload }) => { @@ -254,7 +254,7 @@ export const imagesSlice = createSlice({ deleteImagesError: (state, { payload }) => { state.loadingStates.images.isLoading = false; - state.loadingStates.images.error = payload; + state.loadingStates.images.errors = payload; }, }, }); From 90df794ec0bd15fa88d4870984b6a86d9d4c0d27 Mon Sep 17 00:00:00 2001 From: Nathaniel Rindlaub Date: Tue, 24 Oct 2023 10:50:34 -0700 Subject: [PATCH 10/11] Update image error alert message --- src/components/ErrorAlerts.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ErrorAlerts.jsx b/src/components/ErrorAlerts.jsx index 402ac36b..e938d4b4 100644 --- a/src/components/ErrorAlerts.jsx +++ b/src/components/ErrorAlerts.jsx @@ -61,7 +61,7 @@ const ErrorAlerts = () => { enrichErrors(depsErrors, 'Deployment Error', 'deployments'), enrichErrors(modelsErrors, 'Model Error', 'models'), enrichErrors(camerasErrors, 'Camera Error', 'cameras'), - enrichErrors(imagesErrors, 'Error Fetching Images', 'images'), + enrichErrors(imagesErrors, 'Image Error', 'images'), enrichErrors(imageContextErrors, 'Image Error', 'imageContext'), enrichErrors(statsErrors, 'Error Getting Stats', 'stats'), enrichErrors(exportErrors, 'Error Exporting Data', 'data'), From 582b7696c8d8ef4aeac1da8beb9b6f4ea5494565 Mon Sep 17 00:00:00 2001 From: Nathaniel Rindlaub Date: Tue, 24 Oct 2023 10:52:52 -0700 Subject: [PATCH 11/11] Remove delete image button from loupe --- src/features/loupe/FullSizeImage.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/features/loupe/FullSizeImage.jsx b/src/features/loupe/FullSizeImage.jsx index c3d73b3b..df5d11c3 100644 --- a/src/features/loupe/FullSizeImage.jsx +++ b/src/features/loupe/FullSizeImage.jsx @@ -211,11 +211,6 @@ const FullSizeImage = ({ image, focusIndex }) => { - {hasRole(userRoles, DELETE_IMAGES) && - - Delete - - } {hasRole(userRoles, WRITE_OBJECTS_ROLES) && <>