Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 9 additions & 7 deletions api-editor/gui/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -160,39 +162,39 @@ export const App: React.FC = function () {
</GridItem>
<GridItem gridArea="middlePane" overflow="auto">
<Box flexGrow={1} overflowY="auto" width="100%">
{batchMode === BatchMode.None && <SelectionView />}
{(batchMode === BatchMode.None || !isValidUsername) && <SelectionView />}

{batchMode === BatchMode.Constant && (
{batchMode === BatchMode.Constant && isValidUsername && (
<ConstantBatchForm
targets={getMatchedElements(rawPythonPackage, filter, annotationStore, usages)}
/>
)}

{batchMode === BatchMode.Rename && (
{batchMode === BatchMode.Rename && isValidUsername && (
<RenameBatchForm
targets={getMatchedElements(rawPythonPackage, filter, annotationStore, usages)}
/>
)}

{batchMode === BatchMode.Move && (
{batchMode === BatchMode.Move && isValidUsername && (
<MoveBatchForm
targets={getMatchedElements(rawPythonPackage, filter, annotationStore, usages)}
/>
)}

{batchMode === BatchMode.Required && (
{batchMode === BatchMode.Required && isValidUsername && (
<RequiredBatchForm
targets={getMatchedElements(rawPythonPackage, filter, annotationStore, usages)}
/>
)}

{batchMode === BatchMode.Optional && (
{batchMode === BatchMode.Optional && isValidUsername && (
<OptionalBatchForm
targets={getMatchedElements(rawPythonPackage, filter, annotationStore, usages)}
/>
)}

{batchMode === BatchMode.Remove && (
{batchMode === BatchMode.Remove && isValidUsername && (
<RemoveBatchForm
targets={getMatchedElements(rawPythonPackage, filter, annotationStore, usages)}
/>
Expand Down
13 changes: 9 additions & 4 deletions api-editor/gui/src/common/DeleteAllAnnotations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -31,9 +34,11 @@ export const DeleteAllAnnotations = function () {

return (
<>
<Button onClick={() => setIsOpen(true)}>Delete All Annotations</Button>
<Button onClick={() => setIsOpen(true)} disabled={!usernameIsValid}>
Delete All Annotations
</Button>

<AlertDialog isOpen={isOpen} leastDestructiveRef={cancelRef} onClose={handleCancel}>
<AlertDialog isOpen={isOpen && usernameIsValid} leastDestructiveRef={cancelRef} onClose={handleCancel}>
<AlertDialogOverlay>
<AlertDialogContent>
<AlertDialogHeader>
Expand Down
5 changes: 3 additions & 2 deletions api-editor/gui/src/common/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -50,6 +50,7 @@ export const MenuBar: React.FC<MenuBarProps> = 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');
Expand Down Expand Up @@ -105,7 +106,7 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })

<Box>
<Menu closeOnSelect={false}>
<MenuButton as={Button} rightIcon={<Icon as={FaChevronDown} />}>
<MenuButton as={Button} rightIcon={<Icon as={FaChevronDown} />} disabled={!usernameIsValid}>
Batch
</MenuButton>
<MenuList>
Expand Down