diff --git a/scm-ui/ui-components/src/OverviewPageActions.tsx b/scm-ui/ui-components/src/OverviewPageActions.tsx index 4cbffb32ef..57672d4138 100644 --- a/scm-ui/ui-components/src/OverviewPageActions.tsx +++ b/scm-ui/ui-components/src/OverviewPageActions.tsx @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import React from "react"; -import { withRouter, RouteComponentProps } from "react-router-dom"; +import React, { FC } from "react"; +import { useHistory, useLocation } from "react-router-dom"; import classNames from "classnames"; import { Button, DropDown, urls } from "./index"; import { FilterInput } from "./forms"; -type Props = RouteComponentProps & { +type Props = { showCreateButton: boolean; currentGroup: string; groups: string[]; @@ -35,41 +35,36 @@ type Props = RouteComponentProps & { groupSelected: (namespace: string) => void; label?: string; testId?: string; + searchPlaceholder?: string; + filterPlaceholder?: string; }; -class OverviewPageActions extends React.Component { - render() { - const { history, currentGroup, groups, location, link, testId, groupSelected } = this.props; - const groupSelector = groups && ( -
- -
- ); +const OverviewPageActions: FC = ({ + groups, + currentGroup, + showCreateButton, + link, + groupSelected, + label, + testId, + searchPlaceholder, + filterPlaceholder +}) => { + const history = useHistory(); + const location = useLocation(); + const groupSelector = groups && ( +
+ +
+ ); - return ( -
- {groupSelector} -
- { - history.push(`/${link}/?q=${filter}`); - }} - testId={testId + "-filter"} - /> -
- {this.renderCreateButton()} -
- ); - } - - renderCreateButton() { - const { showCreateButton, link, label } = this.props; + const renderCreateButton = () => { if (showCreateButton) { return (
@@ -78,7 +73,24 @@ class OverviewPageActions extends React.Component { ); } return null; - } -} + }; -export default withRouter(OverviewPageActions); + return ( +
+ {groupSelector} +
+ { + history.push(`/${link}/?q=${filter}`); + }} + testId={testId + "-filter"} + /> +
+ {renderCreateButton()} +
+ ); +}; + +export default OverviewPageActions; diff --git a/scm-ui/ui-components/src/forms/DropDown.tsx b/scm-ui/ui-components/src/forms/DropDown.tsx index e801a0c2a8..504f37de87 100644 --- a/scm-ui/ui-components/src/forms/DropDown.tsx +++ b/scm-ui/ui-components/src/forms/DropDown.tsx @@ -32,6 +32,7 @@ type Props = { preselectedOption?: string; className?: string; disabled?: boolean; + placeholder?: string; }; const FullWidthSelect = styled.select` @@ -40,7 +41,7 @@ const FullWidthSelect = styled.select` class DropDown extends React.Component { render() { - const { options, optionValues, preselectedOption, className, disabled } = this.props; + const { options, optionValues, preselectedOption, className, disabled, placeholder } = this.props; if (preselectedOption && options.filter(o => o === preselectedOption).length === 0) { options.push(preselectedOption); @@ -48,7 +49,12 @@ class DropDown extends React.Component { return (
- + {options.map((option, index) => { const value = optionValues && optionValues[index] ? optionValues[index] : option; return ( diff --git a/scm-ui/ui-components/src/forms/FilterInput.tsx b/scm-ui/ui-components/src/forms/FilterInput.tsx index 15dcabb9e1..b90ce3d61d 100644 --- a/scm-ui/ui-components/src/forms/FilterInput.tsx +++ b/scm-ui/ui-components/src/forms/FilterInput.tsx @@ -65,7 +65,7 @@ const FilterInput: FC = ({ filter, value, testId, placeholder }) => { setStateValue(event.target.value)} /> diff --git a/scm-ui/ui-webapp/public/locales/de/repos.json b/scm-ui/ui-webapp/public/locales/de/repos.json index d95ef44970..d9a2f94b37 100644 --- a/scm-ui/ui-webapp/public/locales/de/repos.json +++ b/scm-ui/ui-webapp/public/locales/de/repos.json @@ -42,7 +42,9 @@ "title": "Repositories", "subtitle": "Übersicht aller verfügbaren Repositories", "noRepositories": "Keine Repositories gefunden.", - "createButton": "Repository erstellen" + "createButton": "Repository erstellen", + "searchRepository": "Repository suchen", + "filterNamespace": "Namespace filtern" }, "create": { "title": "Repository erstellen", diff --git a/scm-ui/ui-webapp/public/locales/en/repos.json b/scm-ui/ui-webapp/public/locales/en/repos.json index 59981282df..87c6301ffb 100644 --- a/scm-ui/ui-webapp/public/locales/en/repos.json +++ b/scm-ui/ui-webapp/public/locales/en/repos.json @@ -42,7 +42,9 @@ "title": "Repositories", "subtitle": "Overview of available repositories", "noRepositories": "No repositories found.", - "createButton": "Create Repository" + "createButton": "Create Repository", + "searchRepository": "Search repository", + "filterNamespace": "Filter by namespace" }, "create": { "title": "Create Repository", diff --git a/scm-ui/ui-webapp/src/repos/components/list/RepositoryGroupEntry.tsx b/scm-ui/ui-webapp/src/repos/components/list/RepositoryGroupEntry.tsx index 936c5c2ebb..2351a8ec08 100644 --- a/scm-ui/ui-webapp/src/repos/components/list/RepositoryGroupEntry.tsx +++ b/scm-ui/ui-webapp/src/repos/components/list/RepositoryGroupEntry.tsx @@ -22,22 +22,26 @@ * SOFTWARE. */ import React from "react"; -import { Link } from "react-router-dom"; -import { CardColumnGroup, RepositoryEntry } from "@scm-manager/ui-components"; -import { RepositoryGroup } from "@scm-manager/ui-types"; -import { Icon } from "@scm-manager/ui-components"; -import { WithTranslation, withTranslation } from "react-i18next"; +import {Link} from "react-router-dom"; +import {CardColumnGroup, Icon, RepositoryEntry} from "@scm-manager/ui-components"; +import {RepositoryGroup} from "@scm-manager/ui-types"; +import {WithTranslation, withTranslation} from "react-i18next"; +import styled from "styled-components"; type Props = WithTranslation & { group: RepositoryGroup; }; +const SizedIcon = styled(Icon)` + font-size: 1.33rem; +`; + class RepositoryGroupEntry extends React.Component { render() { const { group, t } = this.props; const settingsLink = group.namespace?._links?.permissions && ( - + ); const namespaceHeader = ( diff --git a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx index 0dae2f03d9..eaee435640 100644 --- a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx @@ -126,6 +126,8 @@ class Overview extends React.Component { link="repos" label={t("overview.createButton")} testId="repository-overview" + searchPlaceholder={t("overview.searchRepository")} + filterPlaceholder={t("overview.filterNamespace")} />