mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
pulled out PageActions from OverviewPageActions because otherwise you can not check for name of OverviewPageActions because the component exported injectSheet -> jss
simplified CreateUser/GroupButton by not being used as external component
This commit is contained in:
@@ -32,7 +32,7 @@ class OverviewPageActions extends React.Component<Props> {
|
||||
const { history, location, link } = this.props;
|
||||
let directory = link.substring(0, link.indexOf("/"));
|
||||
return (
|
||||
<PageActions>
|
||||
<>
|
||||
<FilterInput
|
||||
value={urls.getQueryStringFromLocation(location)}
|
||||
filter={filter => {
|
||||
@@ -40,7 +40,7 @@ class OverviewPageActions extends React.Component<Props> {
|
||||
}}
|
||||
/>
|
||||
{this.renderCreateButton()}
|
||||
</PageActions>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import ErrorNotification from "./../ErrorNotification";
|
||||
import Title from "./Title";
|
||||
import Subtitle from "./Subtitle";
|
||||
import PageActions from "./PageActions";
|
||||
import OverviewPageActions from "../OverviewPageActions";
|
||||
import ErrorBoundary from "../ErrorBoundary";
|
||||
|
||||
type Props = {
|
||||
@@ -52,10 +51,7 @@ class Page extends React.Component<Props> {
|
||||
let pageActionsExists = false;
|
||||
React.Children.forEach(children, child => {
|
||||
if (child && !error) {
|
||||
if (
|
||||
child.type.name === PageActions.name ||
|
||||
child.type.name === OverviewPageActions.name
|
||||
)
|
||||
if (child.type.name === PageActions.name)
|
||||
pageActions = (
|
||||
<div
|
||||
className={classNames(
|
||||
@@ -100,10 +96,7 @@ class Page extends React.Component<Props> {
|
||||
let content = [];
|
||||
React.Children.forEach(children, child => {
|
||||
if (child) {
|
||||
if (
|
||||
child.type.name !== PageActions.name &&
|
||||
child.type.name !== OverviewPageActions.name
|
||||
) {
|
||||
if (child.type.name !== PageActions.name) {
|
||||
content.push(child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { CreateButton } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class CreateGroupButton extends React.Component<Props> {
|
||||
render() {
|
||||
const { t } = this.props;
|
||||
return (
|
||||
<CreateButton label={t("create-group-button.label")} link="/groups/add" />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("groups")(CreateGroupButton);
|
||||
@@ -14,13 +14,14 @@ import {
|
||||
} from "../modules/groups";
|
||||
import {
|
||||
Page,
|
||||
PageActions,
|
||||
OverviewPageActions,
|
||||
Notification,
|
||||
LinkPaginator,
|
||||
urls
|
||||
urls,
|
||||
CreateButton
|
||||
} from "@scm-manager/ui-components";
|
||||
import { GroupTable } from "./../components/table";
|
||||
import CreateGroupButton from "../components/buttons/CreateGroupButton";
|
||||
import { getGroupsLink } from "../../modules/indexResource";
|
||||
|
||||
type Props = {
|
||||
@@ -83,11 +84,13 @@ class Groups extends React.Component<Props> {
|
||||
>
|
||||
{this.renderGroupTable()}
|
||||
{this.renderCreateButton()}
|
||||
<PageActions>
|
||||
<OverviewPageActions
|
||||
showCreateButton={canAddGroups}
|
||||
link="groups/add"
|
||||
label={t("create-group-button.label")}
|
||||
/>
|
||||
</PageActions>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -110,8 +113,14 @@ class Groups extends React.Component<Props> {
|
||||
}
|
||||
|
||||
renderCreateButton() {
|
||||
if (this.props.canAddGroups) {
|
||||
return <CreateGroupButton />;
|
||||
const { canAddGroups, t } = this.props;
|
||||
if (canAddGroups) {
|
||||
return (
|
||||
<CreateButton
|
||||
label={t("create-group-button.label")}
|
||||
link="/groups/add"
|
||||
/>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
} from "../modules/repos";
|
||||
import {
|
||||
Page,
|
||||
PageActions,
|
||||
OverviewPageActions,
|
||||
CreateButton,
|
||||
Notification,
|
||||
@@ -81,11 +82,13 @@ class Overview extends React.Component<Props> {
|
||||
error={error}
|
||||
>
|
||||
{this.renderOverview()}
|
||||
<PageActions>
|
||||
<OverviewPageActions
|
||||
showCreateButton={showCreateButton}
|
||||
link="repos/create"
|
||||
label={t("overview.createButton")}
|
||||
/>
|
||||
</PageActions>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { CreateButton } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class CreateUserButton extends React.Component<Props> {
|
||||
render() {
|
||||
const { t } = this.props;
|
||||
return (
|
||||
<CreateButton label={t("users.createButton")} link="/users/add" />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("users")(CreateUserButton);
|
||||
@@ -14,13 +14,14 @@ import {
|
||||
} from "../modules/users";
|
||||
import {
|
||||
Page,
|
||||
PageActions,
|
||||
OverviewPageActions,
|
||||
Notification,
|
||||
LinkPaginator,
|
||||
urls
|
||||
urls,
|
||||
CreateButton
|
||||
} from "@scm-manager/ui-components";
|
||||
import { UserTable } from "./../components/table";
|
||||
import CreateUserButton from "../components/buttons/CreateUserButton";
|
||||
import { getUsersLink } from "../../modules/indexResource";
|
||||
|
||||
type Props = {
|
||||
@@ -83,11 +84,13 @@ class Users extends React.Component<Props> {
|
||||
>
|
||||
{this.renderUserTable()}
|
||||
{this.renderCreateButton()}
|
||||
<PageActions>
|
||||
<OverviewPageActions
|
||||
showCreateButton={canAddUsers}
|
||||
link="users/add"
|
||||
label={t("users.createButton")}
|
||||
/>
|
||||
</PageActions>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -110,8 +113,9 @@ class Users extends React.Component<Props> {
|
||||
}
|
||||
|
||||
renderCreateButton() {
|
||||
if (this.props.canAddUsers) {
|
||||
return <CreateUserButton />;
|
||||
const { canAddUsers, t } = this.props;
|
||||
if (canAddUsers) {
|
||||
return <CreateButton label={t("users.createButton")} link="/users/add" />;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user