mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +01:00
Do not use "namespaces" in generic overview
This commit is contained in:
@@ -26,47 +26,52 @@ import { withRouter, RouteComponentProps } from "react-router-dom";
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Button, DropDown, urls } from "./index";
|
import { Button, DropDown, urls } from "./index";
|
||||||
import { FilterInput } from "./forms";
|
import { FilterInput } from "./forms";
|
||||||
import { Namespace } from "@scm-manager/ui-types";
|
|
||||||
|
|
||||||
type Props = RouteComponentProps & {
|
type Props = RouteComponentProps & {
|
||||||
showCreateButton: boolean;
|
showCreateButton: boolean;
|
||||||
namespace: string;
|
currentGroup: string;
|
||||||
namespaces: Namespace[];
|
groups: string[];
|
||||||
link: string;
|
link: string;
|
||||||
namespaceSelected: (namespace: string) => void;
|
groupSelected: (namespace: string) => void;
|
||||||
label?: string;
|
label?: string;
|
||||||
testId?: string;
|
testId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OverviewPageActions extends React.Component<Props> {
|
class OverviewPageActions extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { history, namespace, namespaces, location, link, testId } = this.props;
|
const { history, currentGroup, groups, location, link, testId, groupSelected } = this.props;
|
||||||
const sortedNamespaces = namespaces ? namespaces.map(n => n.namespace).sort() : [];
|
const groupSelector = groups && (
|
||||||
const namespaceOptions = ["", ...sortedNamespaces];
|
<div className={"column is-flex"}>
|
||||||
return (
|
<DropDown
|
||||||
<>
|
options={groups}
|
||||||
<DropDown options={namespaceOptions} preselectedOption={namespace} optionSelected={this.namespaceSelected} />
|
preselectedOption={currentGroup}
|
||||||
<FilterInput
|
optionSelected={groupSelected}
|
||||||
value={urls.getQueryStringFromLocation(location)}
|
|
||||||
filter={filter => {
|
|
||||||
history.push(`/${link}/?q=${filter}`);
|
|
||||||
}}
|
|
||||||
testId={testId + "-filter"}
|
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={"columns is-tablet"}>
|
||||||
|
{groupSelector}
|
||||||
|
<div className={"column"}>
|
||||||
|
<FilterInput
|
||||||
|
value={urls.getQueryStringFromLocation(location)}
|
||||||
|
filter={filter => {
|
||||||
|
history.push(`/${link}/?q=${filter}`);
|
||||||
|
}}
|
||||||
|
testId={testId + "-filter"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{this.renderCreateButton()}
|
{this.renderCreateButton()}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespaceSelected = (newNamespace: string) => {
|
|
||||||
this.props.namespaceSelected(newNamespace);
|
|
||||||
};
|
|
||||||
|
|
||||||
renderCreateButton() {
|
renderCreateButton() {
|
||||||
const { showCreateButton, link, label } = this.props;
|
const { showCreateButton, link, label } = this.props;
|
||||||
if (showCreateButton) {
|
if (showCreateButton) {
|
||||||
return (
|
return (
|
||||||
<div className={classNames("input-button", "control")}>
|
<div className={classNames("input-button", "control", "column")}>
|
||||||
<Button label={label} link={`/${link}/create`} color="primary" />
|
<Button label={label} link={`/${link}/create`} color="primary" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export default class Page extends React.Component<Props> {
|
|||||||
if (this.isPageAction(child)) {
|
if (this.isPageAction(child)) {
|
||||||
pageActions = (
|
pageActions = (
|
||||||
<PageActionContainer
|
<PageActionContainer
|
||||||
className={classNames("column", "is-three-fifths", "is-mobile-action-spacing", "is-flex")}
|
className={classNames("column", "is-three-fifths", "is-mobile-action-spacing", "is-flex-tablet")}
|
||||||
>
|
>
|
||||||
{child}
|
{child}
|
||||||
</PageActionContainer>
|
</PageActionContainer>
|
||||||
|
|||||||
@@ -114,15 +114,17 @@ class Overview extends React.Component<Props> {
|
|||||||
|
|
||||||
const link = namespace ? `repos/${namespace}` : "repos";
|
const link = namespace ? `repos/${namespace}` : "repos";
|
||||||
|
|
||||||
|
const namespacesToRender = namespaces?["", ...namespaces.map(n => n.namespace).sort()]:[];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title={t("overview.title")} subtitle={t("overview.subtitle")} loading={loading} error={error}>
|
<Page title={t("overview.title")} subtitle={t("overview.subtitle")} loading={loading} error={error}>
|
||||||
{this.renderOverview()}
|
{this.renderOverview()}
|
||||||
<PageActions>
|
<PageActions>
|
||||||
<OverviewPageActions
|
<OverviewPageActions
|
||||||
showCreateButton={showCreateButton}
|
showCreateButton={showCreateButton}
|
||||||
namespace={namespace}
|
currentGroup={namespace}
|
||||||
namespaces={namespaces}
|
groups={namespacesToRender}
|
||||||
namespaceSelected={this.namespaceSelected}
|
groupSelected={this.namespaceSelected}
|
||||||
link={link}
|
link={link}
|
||||||
label={t("overview.createButton")}
|
label={t("overview.createButton")}
|
||||||
testId="repository-overview"
|
testId="repository-overview"
|
||||||
|
|||||||
Reference in New Issue
Block a user