|
@@ -43,7 +43,7 @@ const Edit = ({
|
|
const {
|
|
const {
|
|
register,
|
|
register,
|
|
handleSubmit,
|
|
handleSubmit,
|
|
- formState: { isSubmitting },
|
|
|
|
|
|
+ formState: { isSubmitting, isDirty },
|
|
control,
|
|
control,
|
|
} = useForm<NewSchemaSubjectRaw>({ mode: 'onChange' });
|
|
} = useForm<NewSchemaSubjectRaw>({ mode: 'onChange' });
|
|
|
|
|
|
@@ -62,15 +62,19 @@ const Edit = ({
|
|
compatibilityLevel: CompatibilityLevelCompatibilityEnum;
|
|
compatibilityLevel: CompatibilityLevelCompatibilityEnum;
|
|
newSchema: string;
|
|
newSchema: string;
|
|
}) => {
|
|
}) => {
|
|
- await updateSchema(
|
|
|
|
- schema,
|
|
|
|
- newSchema,
|
|
|
|
- schemaType,
|
|
|
|
- compatibilityLevel,
|
|
|
|
- clusterName,
|
|
|
|
- subject
|
|
|
|
- );
|
|
|
|
- history.push(clusterSchemaPath(clusterName, subject));
|
|
|
|
|
|
+ try {
|
|
|
|
+ await updateSchema(
|
|
|
|
+ schema,
|
|
|
|
+ newSchema,
|
|
|
|
+ schemaType,
|
|
|
|
+ compatibilityLevel,
|
|
|
|
+ clusterName,
|
|
|
|
+ subject
|
|
|
|
+ );
|
|
|
|
+ history.push(clusterSchemaPath(clusterName, subject));
|
|
|
|
+ } catch (e) {
|
|
|
|
+ // do not redirect
|
|
|
|
+ }
|
|
},
|
|
},
|
|
[schema, register, control, clusterName, subject, updateSchema, history]
|
|
[schema, register, control, clusterName, subject, updateSchema, history]
|
|
);
|
|
);
|
|
@@ -96,7 +100,7 @@ const Edit = ({
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- {schemasAreFetched && !isSubmitting ? (
|
|
|
|
|
|
+ {schemasAreFetched ? (
|
|
<div className="box">
|
|
<div className="box">
|
|
<form
|
|
<form
|
|
onSubmit={handleSubmit(onSubmit)}
|
|
onSubmit={handleSubmit(onSubmit)}
|
|
@@ -111,6 +115,7 @@ const Edit = ({
|
|
required: 'Schema Type is required.',
|
|
required: 'Schema Type is required.',
|
|
})}
|
|
})}
|
|
defaultValue={schema.schemaType}
|
|
defaultValue={schema.schemaType}
|
|
|
|
+ disabled={isSubmitting}
|
|
>
|
|
>
|
|
{Object.keys(SchemaType).map((type: string) => (
|
|
{Object.keys(SchemaType).map((type: string) => (
|
|
<option key={type} value={type}>
|
|
<option key={type} value={type}>
|
|
@@ -128,6 +133,7 @@ const Edit = ({
|
|
name="compatibilityLevel"
|
|
name="compatibilityLevel"
|
|
ref={register()}
|
|
ref={register()}
|
|
defaultValue={schema.compatibilityLevel}
|
|
defaultValue={schema.compatibilityLevel}
|
|
|
|
+ disabled={isSubmitting}
|
|
>
|
|
>
|
|
{Object.keys(CompatibilityLevelCompatibilityEnum).map(
|
|
{Object.keys(CompatibilityLevelCompatibilityEnum).map(
|
|
(level: string) => (
|
|
(level: string) => (
|
|
@@ -143,7 +149,9 @@ const Edit = ({
|
|
<div className="column is-one-half">
|
|
<div className="column is-one-half">
|
|
<h4 className="title is-5 mb-2">Latest Schema</h4>
|
|
<h4 className="title is-5 mb-2">Latest Schema</h4>
|
|
<JSONEditor
|
|
<JSONEditor
|
|
|
|
+ isFixedHeight
|
|
readOnly
|
|
readOnly
|
|
|
|
+ height="500px"
|
|
value={getFormattedSchema()}
|
|
value={getFormattedSchema()}
|
|
name="latestSchema"
|
|
name="latestSchema"
|
|
highlightActiveLine={false}
|
|
highlightActiveLine={false}
|
|
@@ -154,8 +162,10 @@ const Edit = ({
|
|
<Controller
|
|
<Controller
|
|
control={control}
|
|
control={control}
|
|
name="newSchema"
|
|
name="newSchema"
|
|
|
|
+ disabled={isSubmitting}
|
|
render={({ name, onChange }) => (
|
|
render={({ name, onChange }) => (
|
|
<JSONEditor
|
|
<JSONEditor
|
|
|
|
+ readOnly={isSubmitting}
|
|
defaultValue={getFormattedSchema()}
|
|
defaultValue={getFormattedSchema()}
|
|
name={name}
|
|
name={name}
|
|
onChange={onChange}
|
|
onChange={onChange}
|
|
@@ -164,7 +174,11 @@ const Edit = ({
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <button type="submit" className="button is-primary">
|
|
|
|
|
|
+ <button
|
|
|
|
+ type="submit"
|
|
|
|
+ className="button is-primary"
|
|
|
|
+ disabled={!isDirty || isSubmitting}
|
|
|
|
+ >
|
|
Submit
|
|
Submit
|
|
</button>
|
|
</button>
|
|
</form>
|
|
</form>
|