mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
fix routes for sources and changesets // fix typing errors
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -84,7 +84,7 @@ export function fetchSourcesFailure(repository: Repository, revision: string, pa
|
||||
};
|
||||
}
|
||||
|
||||
function createItemId(repository: Repository, revision: string, path: string) {
|
||||
function createItemId(repository: Repository, revision: string | undefined, path: string) {
|
||||
const revPart = revision ? revision : "_";
|
||||
const pathPart = path ? path : "";
|
||||
return `${repository.namespace}/${repository.name}/${decodeURIComponent(revPart)}/${pathPart}`;
|
||||
@@ -121,7 +121,7 @@ export function isDirectory(state: any, repository: Repository, revision: string
|
||||
export function getSources(
|
||||
state: any,
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
revision: string | undefined,
|
||||
path: string
|
||||
): File | null | undefined {
|
||||
if (state.sources) {
|
||||
|
||||
Reference in New Issue
Block a user