fix routes for sources and changesets // fix typing errors

This commit is contained in:
Eduard Heimbuch
2020-01-08 10:31:43 +01:00
parent 20c00e7222
commit c73e85e3d6
13 changed files with 130 additions and 257 deletions

View File

@@ -24,7 +24,7 @@ type Props = WithTranslation &
sources?: File | null;
// dispatch props
fetchSources: (repository: Repository, revision: string, path: string) => void;
fetchSources: (repository: Repository, revision: string | undefined, path: string | undefined) => void;
};
const extensionPointName = "repos.sources.extensions";
@@ -33,7 +33,7 @@ class SourceExtensions extends React.Component<Props> {
componentDidMount() {
const { fetchSources, repository, revision, path } = this.props;
// TODO get typing right
fetchSources(repository, revision || "", path || "");
fetchSources(repository, revision, path);
}
render() {

View File

@@ -1,9 +1,9 @@
import React from "react";
import { connect } from "react-redux";
import { connect, Dispatch, DispatchProp, MapDispatchToProps } from "react-redux";
import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next";
import { Branch, Repository } from "@scm-manager/ui-types";
import { BranchSelector, Breadcrumb, ErrorNotification, Loading } from "@scm-manager/ui-components";
import { Breadcrumb, ErrorNotification, Loading } from "@scm-manager/ui-components";
import FileTree from "../components/FileTree";
import {
fetchBranches,
@@ -58,7 +58,7 @@ class Sources extends React.Component<Props, State> {
this.redirectToDefaultBranch();
}
componentDidUpdate(prevProps) {
componentDidUpdate(prevProps: Props) {
const { fetchSources, repository, revision, path } = this.props;
if (prevProps.revision !== revision || prevProps.path !== path) {
fetchSources(repository, this.decodeRevision(revision), path);
@@ -147,7 +147,7 @@ class Sources extends React.Component<Props, State> {
};
}
const mapStateToProps = (state, ownProps) => {
const mapStateToProps = (state: any, ownProps: Props) => {
const { repository, match } = ownProps;
const { revision, path } = match.params;
const decodedRevision = revision ? decodeURIComponent(revision) : undefined;
@@ -171,7 +171,7 @@ const mapStateToProps = (state, ownProps) => {
};
};
const mapDispatchToProps = dispatch => {
const mapDispatchToProps = (dispatch: any) => {
return {
fetchBranches: (repository: Repository) => {
dispatch(fetchBranches(repository));