Implement reindex mechanism for search (#2104)

Adds a new button to repository settings to allow users to manually delete and re-create search indices. The actual re-indexing is happening in plugins that subscribe to the newly created event.

Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
Konstantin Schaper
2022-08-17 13:22:34 +02:00
committed by GitHub
parent e590a3ee68
commit 56ace2811b
12 changed files with 248 additions and 0 deletions

View File

@@ -373,3 +373,24 @@ export const useRenameRepository = (repository: Repository) => {
isRenamed: !!data
};
};
export const useReindexRepository = () => {
const queryClient = useQueryClient();
const { mutate, isLoading, error, data } = useMutation<unknown, Error, Repository>(
(repository) => {
const link = requiredLink(repository, "reindex");
return apiClient.post(link);
},
{
onSuccess: async (_, repository) => {
await queryClient.invalidateQueries(repoQueryKey(repository));
},
}
);
return {
reindex: (repository: Repository) => mutate(repository),
isLoading,
error,
isRunning: !!data,
};
};