From 76cf2d2bbc7ae43a7fd3f32b7ecee20f89a37977 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sun, 26 Jun 2022 11:18:22 +0200 Subject: [PATCH] feat(gui): categorized annotations in annotation dropdown --- .../annotations/AnnotationDropdown.tsx | 166 ++++++++++++------ 1 file changed, 113 insertions(+), 53 deletions(-) diff --git a/api-editor/gui/src/features/annotations/AnnotationDropdown.tsx b/api-editor/gui/src/features/annotations/AnnotationDropdown.tsx index a03068f3c..6211b0204 100644 --- a/api-editor/gui/src/features/annotations/AnnotationDropdown.tsx +++ b/api-editor/gui/src/features/annotations/AnnotationDropdown.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Icon, Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/react'; +import { Box, Button, Icon, Menu, MenuButton, MenuGroup, MenuItem, MenuList } from '@chakra-ui/react'; import React from 'react'; import { FaChevronDown } from 'react-icons/fa'; import { useAppDispatch, useAppSelector } from '../../app/hooks'; @@ -8,12 +8,12 @@ import { showBoundaryAnnotationForm, showCalledAfterAnnotationForm, showConstantAnnotationForm, + showDescriptionAnnotationForm, showEnumAnnotationForm, showGroupAnnotationForm, showMoveAnnotationForm, showOptionalAnnotationForm, showRenameAnnotationForm, - showDescriptionAnnotationForm, showTodoAnnotationForm, } from '../ui/uiSlice'; @@ -71,60 +71,120 @@ export const AnnotationDropdown: React.FC = function ({ Annotations - {showAttribute && ( - dispatch(showAttributeAnnotationForm(target))}>@attribute - )} - {showBoundary && ( - dispatch(showBoundaryAnnotationForm(target))}>@boundary - )} - {showCalledAfter && ( - - dispatch( - showCalledAfterAnnotationForm({ - target, - calledAfterName: '', - }), - ) - } - > - @calledAfter - - )} - {showConstant && ( - dispatch(showConstantAnnotationForm(target))}>@constant + {(showEnum || showBoundary) && ( + + {showBoundary && ( + dispatch(showBoundaryAnnotationForm(target))} paddingLeft={8}> + @boundary + + )} + {showEnum && ( + dispatch(showEnumAnnotationForm(target))} paddingLeft={8}> + @enum + + )} + )} - {showDescription && ( - dispatch(showDescriptionAnnotationForm(target))}> - @description - - )} - {showEnum && dispatch(showEnumAnnotationForm(target))}>@enum} - {showGroup && ( - - dispatch( - showGroupAnnotationForm({ - target, - groupName: '', - }), - ) - } - > - @group - - )} - {showMove && dispatch(showMoveAnnotationForm(target))}>@move} - {showOptional && ( - dispatch(showOptionalAnnotationForm(target))}>@optional + + {(showAttribute || showConstant || showOptional || showRequired) && ( + + {showAttribute && ( + dispatch(showAttributeAnnotationForm(target))} paddingLeft={8}> + @attribute + + )} + {showConstant && ( + dispatch(showConstantAnnotationForm(target))} paddingLeft={8}> + @constant + + )} + {showOptional && ( + dispatch(showOptionalAnnotationForm(target))} paddingLeft={8}> + @optional + + )} + {showRequired && ( + dispatch(addRequired({ target }))} paddingLeft={8}> + @required + + )} + )} - {showPure && dispatch(addPure({ target }))}>@pure} - {showRemove && dispatch(addRemove({ target }))}>@remove} - {showRename && ( - dispatch(showRenameAnnotationForm(target))}>@rename + + {(showCalledAfter || + showDescription || + showGroup || + showMove || + showPure || + showRemove || + showRename || + showTodo) && ( + + {showCalledAfter && ( + + dispatch( + showCalledAfterAnnotationForm({ + target, + calledAfterName: '', + }), + ) + } + paddingLeft={8} + > + @calledAfter + + )} + {showDescription && ( + dispatch(showDescriptionAnnotationForm(target))} + paddingLeft={8} + > + @description + + )} + {showGroup && ( + + dispatch( + showGroupAnnotationForm({ + target, + groupName: '', + }), + ) + } + paddingLeft={8} + > + @group + + )} + {showMove && ( + dispatch(showMoveAnnotationForm(target))} paddingLeft={8}> + @move + + )} + {showPure && ( + dispatch(addPure({ target }))} paddingLeft={8}> + @pure + + )} + {showRemove && ( + dispatch(addRemove({ target }))} paddingLeft={8}> + @remove + + )} + {showRename && ( + dispatch(showRenameAnnotationForm(target))} paddingLeft={8}> + @rename + + )} + {showTodo && ( + dispatch(showTodoAnnotationForm(target))} paddingLeft={8}> + @todo + + )} + )} - {showRequired && dispatch(addRequired({ target }))}>@required} - {showTodo && dispatch(showTodoAnnotationForm(target))}>@todo}