Skip to content

Commit

Permalink
fix(2155,2173,2131): fixed api catalog spa schema form bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilmhdh authored and deshmukhmayur committed Jul 18, 2022
1 parent 2ac58d9 commit 217c563
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/api-catalog-spa/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api-catalog-spa/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "api-catalog-spa",
"private": true,
"version": "1.0.5",
"version": "1.0.6",
"scripts": {
"dev": "vite",
"build": "NODE_OPTIONS=--max-old-space-size=4096 tsc --noEmit && vite build",
Expand Down
4 changes: 4 additions & 0 deletions packages/api-catalog-spa/src/pages/APICUDPage/APICUDPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ const APICUDPage = () => {
})
.toPromise();

window.OpNotification.success({
subject: 'Successfully validated schema',
});

return res.data?.fetchAPISchema;
} catch (error) {
window.OpNotification.danger({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,12 @@ export const APIBasicDetailsForm = forwardRef<HTMLDivElement, Props>(
label="Owners"
fieldId="api-owners"
validated={error ? 'error' : 'success'}
helperTextInvalid={error?.message}
helperTextInvalid={error?.message || (error as any)?.[0]?.mid?.message}
>
<AsyncSelect
render={debouncePromise(onSearchOwners)}
variant={SelectVariant.typeaheadMulti}
isCreatable
// onCreateOption={(mid) =>
// onChange([...value, { group: ApiEmailGroup.MAILING_LIST, mid, email: mid }])
// }
onSelect={(_, selected, isPlaceholder) =>
onSelectOwner(onChange, value, selected, isPlaceholder)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface Props {

export const APISchemaForm = forwardRef<HTMLDivElement, Props>(
({ handleSchemaValidation, isUpdate, onSearchCMDB }: Props, ref): JSX.Element => {
const { control } = useFormContext<FormData>();
const { control, trigger } = useFormContext<FormData>();
const { append, fields, remove } = useFieldArray({
control,
name: 'schemas',
Expand Down Expand Up @@ -142,7 +142,10 @@ export const APISchemaForm = forwardRef<HTMLDivElement, Props>(
render={({ field: { value, onChange }, fieldState: { error } }) => (
<ApiTypeSelector
value={value as ApiCategory}
onChange={onChange}
onChange={(e) => {
onChange(e);
trigger(`schemas.${index}.category`, { shouldFocus: false });
}}
errorMsg={error?.message}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const EnvironmentFormSection = ({
control={control}
rules={{ required: true }}
defaultValue=""
render={({ field: controllerField, fieldState: { error } }) => (
render={({ field: { value, onChange, onBlur }, fieldState: { error } }) => (
<FormGroup
fieldId={`schemas.${schemaPos}.environments.${index}.name`}
label="Name"
Expand All @@ -153,9 +153,10 @@ export const EnvironmentFormSection = ({
<Select
variant={SelectVariant.typeahead}
typeAheadAriaLabel="Select a state"
onSelect={callbackify(onEnvNameSelect, controllerField.onChange)}
onClear={callbackify(onEnvNameClear, controllerField.onChange)}
selections={controllerField.value}
onSelect={callbackify(onEnvNameSelect, onChange)}
onClear={callbackify(onEnvNameClear, onChange)}
onBlur={onBlur}
selections={value}
aria-label="env link"
placeholder="Enter environment name"
isCreatable
Expand Down

0 comments on commit 217c563

Please sign in to comment.