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

Co-authored-by: Ekaterina Petrova <epetrova@provectus.com>
This commit is contained in:
Ekaterina Petrova 2022-01-25 15:54:46 +03:00 committed by GitHub
parent f2272bd6b3
commit 471e84d0f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

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

View file

@ -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));

View file

@ -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'),