mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 03:25:56 +01:00
Prepare search api for different types (#1732)
We introduced a new annotation '@IndexedType' which gets collected by the scm-annotation-processor. All classes which are annotated are index and searchable. This opens the search api for plugins.
This commit is contained in:
@@ -29,14 +29,18 @@ import { createQueryString } from "./utils";
|
||||
import { useQuery } from "react-query";
|
||||
|
||||
export type SearchOptions = {
|
||||
type: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
};
|
||||
|
||||
const defaultSearchOptions: SearchOptions = {};
|
||||
const defaultSearchOptions: SearchOptions = {
|
||||
type: "repository",
|
||||
};
|
||||
|
||||
export const useSearch = (query: string, options = defaultSearchOptions): ApiResult<QueryResult> => {
|
||||
const link = useRequiredIndexLink("search");
|
||||
export const useSearch = (query: string, optionParam = defaultSearchOptions): ApiResult<QueryResult> => {
|
||||
const options = { ...defaultSearchOptions, ...optionParam };
|
||||
const link = useRequiredIndexLink("search").replace("{type}", options.type);
|
||||
|
||||
const queryParams: Record<string, string> = {};
|
||||
queryParams.q = query;
|
||||
|
||||
Reference in New Issue
Block a user