added check for new component to ensure correct representation, in my opinion still unpleasant

This commit is contained in:
Florian Scholdei
2019-04-19 13:27:12 +02:00
parent f209ca665d
commit ef35a2050c

View File

@@ -7,6 +7,7 @@ import ErrorNotification from "./../ErrorNotification";
import Title from "./Title"; import Title from "./Title";
import Subtitle from "./Subtitle"; import Subtitle from "./Subtitle";
import PageActions from "./PageActions"; import PageActions from "./PageActions";
import OverviewPageActions from "../OverviewPageActions";
import ErrorBoundary from "../ErrorBoundary"; import ErrorBoundary from "../ErrorBoundary";
type Props = { type Props = {
@@ -29,7 +30,6 @@ const styles = {
}; };
class Page extends React.Component<Props> { class Page extends React.Component<Props> {
render() { render() {
const { error } = this.props; const { error } = this.props;
return ( return (
@@ -51,17 +51,21 @@ class Page extends React.Component<Props> {
let pageActions = null; let pageActions = null;
let pageActionsExists = false; let pageActionsExists = false;
React.Children.forEach(children, child => { React.Children.forEach(children, child => {
if (child && child.type.name === PageActions.name && !error) { if (child && !error) {
pageActions = ( if (
<div child.type.name === PageActions.name ||
className={classNames( child.type.name === OverviewPageActions.name
classes.actions, )
"column is-three-fifths is-mobile-action-spacing" pageActions = (
)} <div
> className={classNames(
{child} classes.actions,
</div> "column is-three-fifths is-mobile-action-spacing"
); )}
>
{child}
</div>
);
pageActionsExists = true; pageActionsExists = true;
} }
}); });
@@ -95,8 +99,13 @@ class Page extends React.Component<Props> {
let content = []; let content = [];
React.Children.forEach(children, child => { React.Children.forEach(children, child => {
if (child && child.type.name !== PageActions.name) { if (child) {
content.push(child); if (
child.type.name !== PageActions.name &&
child.type.name !== OverviewPageActions.name
) {
content.push(child);
}
} }
}); });
return content; return content;