Moved getBranchFromMatch to ui-components

This commit is contained in:
Philipp Czora
2018-10-17 17:11:21 +02:00
parent 5871bf052f
commit 8ff19a3d2f
5 changed files with 14 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ export { default as LinkPaginator } from "./LinkPaginator.js";
export { default as ProtectedRoute } from "./ProtectedRoute.js"; export { default as ProtectedRoute } from "./ProtectedRoute.js";
export { default as Help } from "./Help.js"; export { default as Help } from "./Help.js";
export { default as LabelWithHelpIcon } from "./LabelWithHelpIcon.js"; export { default as LabelWithHelpIcon } from "./LabelWithHelpIcon.js";
export { getPageFromMatch } from "./urls";
export { apiClient, NOT_FOUND_ERROR, UNAUTHORIZED_ERROR } from "./apiclient.js"; export { apiClient, NOT_FOUND_ERROR, UNAUTHORIZED_ERROR } from "./apiclient.js";

View File

@@ -4,3 +4,11 @@ export const contextPath = window.ctxPath || "";
export function withContextPath(path: string) { export function withContextPath(path: string) {
return contextPath + path; return contextPath + path;
} }
export function getPageFromMatch(match: any) {
let page = parseInt(match.params.page, 10);
if (isNaN(page) || !page) {
page = 1;
}
return page;
}

View File

@@ -1,5 +1,5 @@
// @flow // @flow
import { getPageFromMatch } from "./Changesets"; import { getPageFromMatch } from "./urls";
describe("tests for getPageFromMatch", () => { describe("tests for getPageFromMatch", () => {
function createMatch(page: string) { function createMatch(page: string) {

View File

@@ -21,7 +21,8 @@ import ChangesetList from "../components/changesets/ChangesetList";
import { import {
ErrorNotification, ErrorNotification,
LinkPaginator, LinkPaginator,
Loading Loading,
getPageFromMatch
} from "@scm-manager/ui-components"; } from "@scm-manager/ui-components";
import { compose } from "redux"; import { compose } from "redux";
@@ -94,14 +95,6 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export function getPageFromMatch(match: any) {
let page = parseInt(match.params.page, 10);
if (isNaN(page) || !page) {
page = 1;
}
return page;
}
const mapStateToProps = (state: any, ownProps: Props) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { repository, branch, match } = ownProps; const { repository, branch, match } = ownProps;
const changesets = getChangesets(state, repository, branch); const changesets = getChangesets(state, repository, branch);