diff --git a/src/nextapp/components/edit-display-name/edit-display-name.tsx b/src/nextapp/components/edit-display-name/edit-display-name.tsx index 2ff366bfb..53578f406 100644 --- a/src/nextapp/components/edit-display-name/edit-display-name.tsx +++ b/src/nextapp/components/edit-display-name/edit-display-name.tsx @@ -13,6 +13,7 @@ import { ModalFooter, ModalHeader, ModalOverlay, + Text, useDisclosure, useToast, } from '@chakra-ui/react'; @@ -35,10 +36,29 @@ const EditNamespaceDisplayName: React.FC = ({ const { isOpen, onOpen, onClose } = useDisclosure(); const queryClient = useQueryClient(); const mutate = useApiMutation(mutation); + // console.log(data) + const [inputValue, setInputValue] = React.useState(data?.name || ''); + const [charCount, setCharCount] = React.useState(data?.name?.length || 0); + const charLimit = 30; + const handleInputChange = (event) => { + const { value } = event.target; + setInputValue(value); + setCharCount(value.length); + }; const form = React.useRef(); const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); - updateNamespaceDisplayName(); + if (charCount <= charLimit) { + // updateNamespaceDisplayName(); + submitTheForm(); + } + }; + const submitTheForm = async () => { + toast({ + title: 'Submitted it!', + status: 'success', + isClosable: true, + }) }; const updateNamespaceDisplayName = async () => { if (form.current) { @@ -84,38 +104,60 @@ const EditNamespaceDisplayName: React.FC = ({ > Edit - + - - Edit display name - + + Edit display name +
- - A meaningful display name makes it easy for anyone to identify and distinguish this gateway from others. + + A meaningful display name makes it easy for anyone to identify and distinguish this Gateway from others. + charLimit ? 'bc-error' : 'gray.500'} + mt={2} + textAlign="right" + > + {charCount}/{charLimit} + charLimit} data-testid="edit-display-name-input" /> + {charCount > charLimit && ( + + You have reached the character limit + + )}
- + - diff --git a/src/nextapp/components/namespace-menu/namespace-menu.tsx b/src/nextapp/components/namespace-menu/namespace-menu.tsx index 4240c2b45..15fb7e7e1 100644 --- a/src/nextapp/components/namespace-menu/namespace-menu.tsx +++ b/src/nextapp/components/namespace-menu/namespace-menu.tsx @@ -215,7 +215,7 @@ const NamespaceMenu: React.FC = ({ > - {n.displayName ? n.displayName : 'Display name here'} + {n.displayName ? n.displayName : `Gateway ${n.name}`} {n.name}