diff --git a/scm-ui/ui-components/src/OverviewPageActions.tsx b/scm-ui/ui-components/src/OverviewPageActions.tsx index a5c90960f0..ffdc65c68a 100644 --- a/scm-ui/ui-components/src/OverviewPageActions.tsx +++ b/scm-ui/ui-components/src/OverviewPageActions.tsx @@ -22,24 +22,30 @@ * SOFTWARE. */ import React from "react"; -import { History } from "history"; import { withRouter, RouteComponentProps } from "react-router-dom"; import classNames from "classnames"; -import { Button, urls } from "./index"; +import { Button, DropDown, urls } from "./index"; import { FilterInput } from "./forms"; +import { Namespace } from "@scm-manager/ui-types"; type Props = RouteComponentProps & { showCreateButton: boolean; + namespace: string; + namespaces: Namespace[]; link: string; + namespaceSelected: (namespace: string) => void; label?: string; testId?: string; }; class OverviewPageActions extends React.Component { render() { - const { history, location, link, testId } = this.props; + const { history, namespace, namespaces, location, link, testId } = this.props; + const sortedNamespaces = namespaces ? namespaces.map(n => n.namespace).sort() : []; + const namespaceOptions = ["", ...sortedNamespaces]; return ( <> + { @@ -52,6 +58,10 @@ class OverviewPageActions extends React.Component { ); } + namespaceSelected = (newNamespace: string) => { + this.props.namespaceSelected(newNamespace); + }; + renderCreateButton() { const { showCreateButton, link, label } = this.props; if (showCreateButton) { diff --git a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx index e0fef89c50..05564003db 100644 --- a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx @@ -101,8 +101,16 @@ class Overview extends React.Component { } }; + namespaceSelected = (newNamespace: string) => { + if (newNamespace === "") { + this.props.history.push("/repos/"); + } else { + this.props.history.push(`/repos/${newNamespace}/`); + } + }; + render() { - const { error, loading, showCreateButton, namespace, t } = this.props; + const { error, loading, showCreateButton, namespace, namespaces, t } = this.props; const link = namespace ? `repos/${namespace}` : "repos"; @@ -112,6 +120,9 @@ class Overview extends React.Component {