Filepath search (#1568)

Add search for files to the sources view. The search is only for finding file paths. It does not search any file metadata nor the content. Results get a rating, where file names are rated higher than file paths. The results are sorted by the score and the first 50 results are displayed.

Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
Sebastian Sdorra
2021-03-04 10:39:58 +01:00
committed by GitHub
parent bafe84b79a
commit 89548d45bd
36 changed files with 1112 additions and 30 deletions

View File

@@ -30,6 +30,7 @@ import CodeActionBar from "../../codeSection/components/CodeActionBar";
import replaceBranchWithRevision from "../ReplaceBranchWithRevision";
import { useSources } from "@scm-manager/ui-api";
import { useHistory, useLocation, useParams } from "react-router-dom";
import FileSearchButton from "../../codeSection/components/FileSearchButton";
import { isEmptyDirectory, isRootFile } from "../utils/files";
import { useTranslation } from "react-i18next";
@@ -106,8 +107,14 @@ const Sources: FC<Props> = ({ repository, branches, selectedBranch, baseUrl }) =
const renderBreadcrumb = () => {
const permalink = file?.revision ? replaceBranchWithRevision(location.pathname, file.revision) : null;
const buttons = [];
if (repository._links.paths) {
buttons.push(<FileSearchButton baseUrl={baseUrl} revision={revision || file.revision} />);
}
return (
<Breadcrumb
preButtons={buttons}
repository={repository}
revision={revision || file.revision}
path={path || ""}