fix(striker-ui): show message when optional section appears in PrepareHostForm

main
Tsu-ba-me 2 years ago
parent c5d349bc92
commit 40dd856c50
  1. 22
      striker-ui/components/PrepareHostForm.tsx

@ -2,7 +2,7 @@ import {
Visibility as MUIVisibilityIcon, Visibility as MUIVisibilityIcon,
VisibilityOff as MUIVisibilityOffIcon, VisibilityOff as MUIVisibilityOffIcon,
} from '@mui/icons-material'; } from '@mui/icons-material';
import { IconButton as MUIIconButton } from '@mui/material'; import { Box as MUIBox, IconButton as MUIIconButton } from '@mui/material';
import { FC, useCallback, useMemo, useRef, useState } from 'react'; import { FC, useCallback, useMemo, useRef, useState } from 'react';
import { GREY } from '../lib/consts/DEFAULT_THEME'; import { GREY } from '../lib/consts/DEFAULT_THEME';
@ -201,6 +201,7 @@ const PrepareHostForm: FC = () => {
setIsShowAccessSubmit(isIdentifierChanged); setIsShowAccessSubmit(isIdentifierChanged);
setIsShowOptionalSection(!isIdentifierChanged); setIsShowOptionalSection(!isIdentifierChanged);
setIsShowRedhatSection(!isIdentifierChanged);
} }
}} }}
onSubmitAppend={( onSubmitAppend={(
@ -441,6 +442,15 @@ const PrepareHostForm: FC = () => {
], ],
); );
const messageSection = useMemo(
() => (
<MUIBox sx={{ display: isShowOptionalSection ? undefined : 'none' }}>
<MessageGroup count={1} ref={messageGroupRef} />
</MUIBox>
),
[isShowOptionalSection],
);
const submitSection = useMemo( const submitSection = useMemo(
() => ( () => (
<FlexBox <FlexBox
@ -452,10 +462,10 @@ const PrepareHostForm: FC = () => {
> >
<ContainedButton <ContainedButton
disabled={ disabled={
isInputHostNameValid && !isInputHostNameValid ||
isInputEnterpriseKeyValid && !isInputEnterpriseKeyValid ||
isInputRedhatUserValid && !isInputRedhatUserValid ||
isInputRedhatPasswordValid !isInputRedhatPasswordValid
} }
onClick={() => { onClick={() => {
const redhatPasswordInputValue = const redhatPasswordInputValue =
@ -511,7 +521,7 @@ const PrepareHostForm: FC = () => {
{accessSection} {accessSection}
{optionalSection} {optionalSection}
{redhatSection} {redhatSection}
<MessageGroup count={1} ref={messageGroupRef} /> {messageSection}
{submitSection} {submitSection}
</FlexBox> </FlexBox>
</Panel> </Panel>

Loading…
Cancel
Save