This commit is contained in:
Oleg Shuralev 2021-02-18 21:35:10 +03:00
parent 1e8359897f
commit c78c149721
No known key found for this signature in database
GPG key ID: 99C6BDC0A1C2E647
4 changed files with 8 additions and 15 deletions

View file

@ -26,7 +26,7 @@ const Details: React.FC<DetailsProps> = ({
isFetched,
}) => {
React.useEffect(() => {
fetchSchemaVersions(clusterName, schema.subject);
fetchSchemaVersions(clusterName, schema.subject as SchemaName);
}, [fetchSchemaVersions, clusterName]);
return (
<div className="section">

View file

@ -4,7 +4,7 @@ import { RouteComponentProps, withRouter } from 'react-router-dom';
import {
getIsSchemaVersionFetched,
getSchema,
getSchemaVersions,
getSortedSchemaVersions,
} from 'redux/reducers/schemas/selectors';
import { fetchSchemaVersions } from 'redux/actions';
import Details from './Details';
@ -25,7 +25,7 @@ const mapStateToProps = (
}: OwnProps
) => ({
schema: getSchema(state, subject),
versions: getSchemaVersions(state),
versions: getSortedSchemaVersions(state),
isFetched: getIsSchemaVersionFetched(state),
clusterName,
});

View file

@ -1,6 +1,6 @@
import { SchemaSubject } from 'generated-sources';
export type SchemaName = SchemaSubject['subject'];
export type SchemaName = string;
export interface SchemasState {
byName: { [subject: string]: SchemaSubject };

View file

@ -1,7 +1,6 @@
import { createSelector } from 'reselect';
import { RootState, SchemasState } from 'redux/interfaces';
import { createFetchingSelector } from 'redux/reducers/loader/selectors';
import { SchemaSubject } from 'generated-sources';
const schemasState = ({ schemas }: RootState): SchemasState => schemas;
@ -30,12 +29,8 @@ export const getSchemaList = createSelector(
getIsSchemaListFetched,
getAllNames,
getSchemaMap,
(isFetched, allNames, byName) => {
if (!isFetched) {
return [];
}
return allNames.map((subject) => byName[subject as string]);
}
(isFetched, allNames, byName) =>
isFetched ? allNames.map((subject) => byName[subject]) : []
);
const getSchemaName = (_: RootState, subject: string) => subject;
@ -46,10 +41,8 @@ export const getSchema = createSelector(
(schemas, subject) => schemas[subject]
);
export const getSchemaVersions = createSelector(
export const getSortedSchemaVersions = createSelector(
schemasState,
({ currentSchemaVersions }) =>
currentSchemaVersions.sort(
(a: SchemaSubject, b: SchemaSubject) => a.id - b.id
)
currentSchemaVersions.sort((a, b) => a.id - b.id)
);