fix(striker-ui): passthrough input validation in EditUpsInputGroup

main
Tsu-ba-me 2 years ago
parent c0fb71ea29
commit 7976170ca2
  1. 25
      striker-ui/components/ManageUps/EditUpsInputGroup.tsx
  2. 5
      striker-ui/types/EditUpsInputGroup.d.ts

@ -1,27 +1,40 @@
import { FC, ReactElement, useMemo } from 'react'; import { ReactElement, useMemo } from 'react';
import AddUpsInputGroup from './AddUpsInputGroup'; import AddUpsInputGroup, { INPUT_ID_UPS_TYPE } from './AddUpsInputGroup';
import { INPUT_ID_UPS_IP, INPUT_ID_UPS_NAME } from './CommonUpsInputGroup';
import Spinner from '../Spinner'; import Spinner from '../Spinner';
const INPUT_ID_UPS_UUID = 'edit-ups-input-ups-uuid'; const INPUT_ID_UPS_UUID = 'edit-ups-input-ups-uuid';
const EditUpsInputGroup: FC<EditUpsInputGroupProps> = ({ const EditUpsInputGroup = <
M extends {
[K in
| typeof INPUT_ID_UPS_IP
| typeof INPUT_ID_UPS_NAME
| typeof INPUT_ID_UPS_TYPE]: string;
},
>({
formUtils,
loading: isExternalLoading, loading: isExternalLoading,
previous, previous,
upsTemplate, upsTemplate,
upsUUID, upsUUID,
}) => { }: EditUpsInputGroupProps<M>): ReactElement => {
const content = useMemo<ReactElement>( const content = useMemo<ReactElement>(
() => () =>
isExternalLoading ? ( isExternalLoading ? (
<Spinner /> <Spinner />
) : ( ) : (
<> <>
<AddUpsInputGroup previous={previous} upsTemplate={upsTemplate} /> <AddUpsInputGroup
formUtils={formUtils}
previous={previous}
upsTemplate={upsTemplate}
/>
<input hidden id={INPUT_ID_UPS_UUID} readOnly value={upsUUID} /> <input hidden id={INPUT_ID_UPS_UUID} readOnly value={upsUUID} />
</> </>
), ),
[isExternalLoading, previous, upsTemplate, upsUUID], [formUtils, isExternalLoading, previous, upsTemplate, upsUUID],
); );
return content; return content;

@ -2,7 +2,8 @@ type EditUpsInputGroupOptionalProps = {
loading?: boolean; loading?: boolean;
}; };
type EditUpsInputGroupProps = EditUpsInputGroupOptionalProps & type EditUpsInputGroupProps<M extends MapToInputTestID> =
Pick<AddUpsInputGroupProps, 'previous' | 'upsTemplate'> & { EditUpsInputGroupOptionalProps &
Pick<AddUpsInputGroupProps<M>, 'formUtils' | 'previous' | 'upsTemplate'> & {
upsUUID: string; upsUUID: string;
}; };

Loading…
Cancel
Save