added pageactions for every page component

This commit is contained in:
Florian Scholdei
2019-02-20 11:16:59 +01:00
parent deedb573a6
commit ef6259da58
3 changed files with 58 additions and 3 deletions

View File

@@ -20,8 +20,15 @@ class Page extends React.Component<Props> {
return (
<section className="section">
<div className="container">
<Title title={title} />
<Subtitle subtitle={subtitle} />
<div className="columns">
<div className="column">
<Title title={title} />
<Subtitle subtitle={subtitle} />
</div>
<div className="column is-two-fifths is-pulled-right">
{this.renderPageActions()}
</div>
</div>
<ErrorNotification error={error} />
{this.renderContent()}
</div>
@@ -37,7 +44,26 @@ class Page extends React.Component<Props> {
if (loading) {
return <Loading />;
}
return children;
let content = [];
React.Children.forEach(children, child => {
if (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;
}
}