mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
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:
committed by
GitHub
parent
e590a3ee68
commit
56ace2811b
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user