Browse Source

Schema type is not updated when history push (#1474)

Co-authored-by: Ekaterina Petrova <epetrova@provectus.com>
Ekaterina Petrova 3 years ago
parent
commit
471e84d0f9

+ 1 - 0
kafka-ui-react-app/src/components/ConsumerGroups/Details/ResetOffsets/ResetOffsets.tsx

@@ -194,6 +194,7 @@ const ResetOffsets: React.FC = () => {
                     minWidth="100%"
                     name={name}
                     onChange={onChange}
+                    defaultValue={value}
                     value={value}
                     options={uniqueTopics.map((topic) => ({
                       value: topic,

+ 10 - 1
kafka-ui-react-app/src/components/Schemas/Edit/Edit.tsx

@@ -14,7 +14,9 @@ import { InputLabel } from 'components/common/Input/InputLabel.styled';
 import PageHeading from 'components/common/PageHeading/PageHeading';
 import { useAppDispatch, useAppSelector } from 'lib/hooks/redux';
 import {
+  schemaAdded,
   schemasApiClient,
+  schemaUpdated,
   selectSchemaById,
 } from 'redux/reducers/schemas/schemasSlice';
 import { serverErrorAlertAdded } from 'redux/reducers/alerts/alertsSlice';
@@ -48,7 +50,7 @@ const Edit: React.FC = () => {
 
     try {
       if (dirtyFields.newSchema || dirtyFields.schemaType) {
-        await schemasApiClient.createNewSchema({
+        const resp = await schemasApiClient.createNewSchema({
           clusterName,
           newSchemaSubject: {
             ...schema,
@@ -56,6 +58,7 @@ const Edit: React.FC = () => {
             schemaType: props.schemaType || schema.schemaType,
           },
         });
+        dispatch(schemaAdded(resp));
       }
 
       if (dirtyFields.compatibilityLevel) {
@@ -66,6 +69,12 @@ const Edit: React.FC = () => {
             compatibility: props.compatibilityLevel,
           },
         });
+        dispatch(
+          schemaUpdated({
+            ...schema,
+            compatibilityLevel: props.compatibilityLevel,
+          })
+        );
       }
 
       history.push(clusterSchemaPath(clusterName, subject));

+ 2 - 1
kafka-ui-react-app/src/redux/reducers/schemas/schemasSlice.ts

@@ -55,6 +55,7 @@ const schemasSlice = createSlice({
   }),
   reducers: {
     schemaAdded: schemasAdapter.addOne,
+    schemaUpdated: schemasAdapter.upsertOne,
   },
   extraReducers: (builder) => {
     builder.addCase(fetchSchemas.fulfilled, (state, { payload }) => {
@@ -74,7 +75,7 @@ export const { selectAll: selectAllSchemaVersions } =
     (state) => state.schemas.versions
   );
 
-export const { schemaAdded } = schemasSlice.actions;
+export const { schemaAdded, schemaUpdated } = schemasSlice.actions;
 
 export const getAreSchemasFulfilled = createSelector(
   createFetchingSelector('schemas/fetch'),