diff --git a/api-editor/gui/src/app/App.tsx b/api-editor/gui/src/app/App.tsx index 23b8a2e1b..117789e88 100644 --- a/api-editor/gui/src/app/App.tsx +++ b/api-editor/gui/src/app/App.tsx @@ -20,6 +20,7 @@ import { persistAnnotations, selectAnnotationSlice, selectAnnotationStore, + selectUsernameIsValid, } from '../features/annotations/annotationSlice'; import { BoundaryForm } from '../features/annotations/forms/BoundaryForm'; import { CalledAfterForm } from '../features/annotations/forms/CalledAfterForm'; @@ -96,6 +97,7 @@ export const App: React.FC = function () { const batchMode = useAppSelector(selectBatchMode); const showAddFilterDialog = useAppSelector(selectShowAddFilterDialog); const showStatistics = useAppSelector(selectShowStatistics); + const isValidUsername = useAppSelector(selectUsernameIsValid); return ( <> @@ -160,39 +162,39 @@ export const App: React.FC = function () { - {batchMode === BatchMode.None && } + {(batchMode === BatchMode.None || !isValidUsername) && } - {batchMode === BatchMode.Constant && ( + {batchMode === BatchMode.Constant && isValidUsername && ( )} - {batchMode === BatchMode.Rename && ( + {batchMode === BatchMode.Rename && isValidUsername && ( )} - {batchMode === BatchMode.Move && ( + {batchMode === BatchMode.Move && isValidUsername && ( )} - {batchMode === BatchMode.Required && ( + {batchMode === BatchMode.Required && isValidUsername && ( )} - {batchMode === BatchMode.Optional && ( + {batchMode === BatchMode.Optional && isValidUsername && ( )} - {batchMode === BatchMode.Remove && ( + {batchMode === BatchMode.Remove && isValidUsername && ( diff --git a/api-editor/gui/src/common/DeleteAllAnnotations.tsx b/api-editor/gui/src/common/DeleteAllAnnotations.tsx index 24a4b331a..1cb2b2a41 100644 --- a/api-editor/gui/src/common/DeleteAllAnnotations.tsx +++ b/api-editor/gui/src/common/DeleteAllAnnotations.tsx @@ -11,11 +11,14 @@ import { VStack, } from '@chakra-ui/react'; import React, { useRef, useState } from 'react'; -import { useAppDispatch } from '../app/hooks'; -import { resetAnnotationStore } from '../features/annotations/annotationSlice'; +import { useAppDispatch, useAppSelector } from '../app/hooks'; +import { resetAnnotationStore, selectUsernameIsValid } from '../features/annotations/annotationSlice'; export const DeleteAllAnnotations = function () { const dispatch = useAppDispatch(); + + const usernameIsValid = useAppSelector(selectUsernameIsValid); + const [isOpen, setIsOpen] = useState(false); const cancelRef = useRef(null); @@ -31,9 +34,11 @@ export const DeleteAllAnnotations = function () { return ( <> - + - + diff --git a/api-editor/gui/src/common/MenuBar.tsx b/api-editor/gui/src/common/MenuBar.tsx index a35ee8592..cac986b7b 100644 --- a/api-editor/gui/src/common/MenuBar.tsx +++ b/api-editor/gui/src/common/MenuBar.tsx @@ -18,7 +18,7 @@ import { import React from 'react'; import { FaChevronDown } from 'react-icons/fa'; import { useAppDispatch, useAppSelector } from '../app/hooks'; -import { selectAnnotationStore } from '../features/annotations/annotationSlice'; +import { selectAnnotationStore, selectUsernameIsValid } from '../features/annotations/annotationSlice'; import { BatchMode, HeatMapMode, @@ -50,6 +50,7 @@ export const MenuBar: React.FC = function ({ displayInferErrors }) const sortingMode = useAppSelector(selectSortingMode); const heatMapMode = useAppSelector(selectHeatMapMode); const showStatistics = useAppSelector(selectShowStatistics); + const usernameIsValid = useAppSelector(selectUsernameIsValid); const exportAnnotations = () => { const a = document.createElement('a'); @@ -105,7 +106,7 @@ export const MenuBar: React.FC = function ({ displayInferErrors }) - }> + } disabled={!usernameIsValid}> Batch