From b8dd00fc099ce3e5a73b1b4a0aa0e7f3667d003d Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Wed, 20 Feb 2019 11:53:38 +0100 Subject: [PATCH] caught uncaught child error and added PageAction Button to Repo Overview --- .../packages/ui-components/src/layout/Page.js | 27 ++++++++++--------- scm-ui/src/repos/containers/Overview.js | 20 ++++++++++---- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/layout/Page.js b/scm-ui-components/packages/ui-components/src/layout/Page.js index 6e25a86ac8..80f02139f4 100644 --- a/scm-ui-components/packages/ui-components/src/layout/Page.js +++ b/scm-ui-components/packages/ui-components/src/layout/Page.js @@ -36,8 +36,21 @@ class Page extends React.Component { ); } + renderPageActions() { + const { children } = this.props; + + let content = null; + React.Children.forEach(children, child => { + if (child && child.type.name === "PageActions") { + content = child; + } + }); + return content; + } + renderContent() { const { loading, children, showContentOnError, error } = this.props; + if (error && !showContentOnError) { return null; } @@ -47,24 +60,12 @@ class Page extends React.Component { let content = []; React.Children.forEach(children, child => { - if (child.type.name !== "PageActions") { + if (child && child.type.name !== "PageActions") { content.push(child); } }); return content; } - - renderPageActions() { - const { children } = this.props; - - let content = null; - React.Children.forEach(children, child => { - if (child.type.name === "PageActions") { - content = child; - } - }); - return content; - } } export default Page; diff --git a/scm-ui/src/repos/containers/Overview.js b/scm-ui/src/repos/containers/Overview.js index 598b6c94f2..ac044b5225 100644 --- a/scm-ui/src/repos/containers/Overview.js +++ b/scm-ui/src/repos/containers/Overview.js @@ -14,7 +14,13 @@ import { isFetchReposPending } from "../modules/repos"; import { translate } from "react-i18next"; -import { CreateButton, Page, Paginator } from "@scm-manager/ui-components"; +import { + Page, + PageActions, + Button, + CreateButton, + Paginator +} from "@scm-manager/ui-components"; import RepositoryList from "../components/list"; import { withRouter } from "react-router-dom"; import type { History } from "history"; @@ -67,6 +73,13 @@ class Overview extends React.Component { error={error} > {this.renderList()} + +