Fix repository file search (#1867)

This commit is contained in:
Eduard Heimbuch
2021-11-19 14:33:06 +01:00
committed by René Pfeuffer
parent 02bcee5603
commit e58d3dd70c
7 changed files with 87 additions and 11 deletions

View File

@@ -39,7 +39,11 @@ const SearchIcon = styled(Icon)`
const FileSearchButton: FC<Props> = ({ baseUrl, revision }) => {
const [t] = useTranslation("repos");
return (
<Link to={`${baseUrl}/search/${encodeURIComponent(revision)}`} aria-label={t("fileSearch.button.title")}>
<Link
to={`${baseUrl}/search/${encodeURIComponent(revision)}`}
aria-label={t("fileSearch.button.title")}
data-testid="file_search_button"
>
<SearchIcon title={t("fileSearch.button.title")} name="search" color="inherit" />
</Link>
);

View File

@@ -62,7 +62,7 @@ const PathResultRow: FC<PathResultRowProps> = ({ contentBaseUrl, path }) => {
</Link>
</IconColumn>
<LeftOverflowTd>
<Link title={path} to={link}>
<Link title={path} to={link} data-testid="file_search_single_result">
{path}
</Link>
</LeftOverflowTd>
@@ -78,7 +78,7 @@ type ResultTableProps = {
const ResultTable: FC<ResultTableProps> = ({ contentBaseUrl, paths }) => (
<table className="table table-hover table-sm is-fullwidth">
<tbody>
{paths.map((path) => (
{paths.map(path => (
<PathResultRow contentBaseUrl={contentBaseUrl} path={path} />
))}
</tbody>

View File

@@ -28,7 +28,7 @@ import classNames from "classnames";
import styled from "styled-components";
import { Branch, Repository } from "@scm-manager/ui-types";
import { urls, usePaths } from "@scm-manager/ui-api";
import { ErrorNotification, FilterInput, Help, Icon, Loading } from "@scm-manager/ui-components";
import { createA11yId, ErrorNotification, FilterInput, Help, Icon, Loading } from "@scm-manager/ui-components";
import CodeActionBar from "../components/CodeActionBar";
import FileSearchResults from "../components/FileSearchResults";
import { filepathSearch } from "../utils/filepathSearch";
@@ -91,7 +91,7 @@ const FileSearch: FC<Props> = ({ repository, baseUrl, branches, selectedBranch }
};
const contentBaseUrl = `${baseUrl}/sources/${revision}/`;
const id = useA11yId("file-search");
const id = createA11yId("file-search");
return (
<>
@@ -123,6 +123,7 @@ const FileSearch: FC<Props> = ({ repository, baseUrl, branches, selectedBranch }
filter={search}
autoFocus={true}
id={id}
testId="file_search_filter_input"
/>
<Help className="ml-3" message={t("fileSearch.input.help")} id={id} />
</div>