mirror of https://github.com/grafana/grafana.git
Provisioning: Skip folder sync when repository is empty (#111371)
* Provisioning: Skip folder sync when repository is empty * Simplify condition * Fix condition
This commit is contained in:
parent
5299878253
commit
460f776e6f
|
@ -101,14 +101,14 @@ export function ProvisioningWizard({ type }: { type: RepoType }) {
|
|||
handleSubmit,
|
||||
} = methods;
|
||||
|
||||
const [repoName = '', repoType] = watch(['repositoryName', 'repository.type']);
|
||||
const [repoName = '', repoType, syncTarget] = watch(['repositoryName', 'repository.type', 'repository.sync.target']);
|
||||
const [submitData] = useCreateOrUpdateRepository(repoName);
|
||||
const [deleteRepository] = useDeleteRepositoryMutation();
|
||||
const {
|
||||
shouldSkipSync,
|
||||
requiresMigration,
|
||||
isLoading: isResourceStatsLoading,
|
||||
} = useResourceStats(repoName, isLegacyStorage);
|
||||
} = useResourceStats(repoName, isLegacyStorage, syncTarget);
|
||||
const { createSyncJob, isLoading: isCreatingSkipJob } = useCreateSyncJob({
|
||||
repoName: repoName,
|
||||
requiresMigration,
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
GetRepositoryFilesApiResponse,
|
||||
GetResourceStatsApiResponse,
|
||||
ManagerStats,
|
||||
RepositoryView,
|
||||
ResourceCount,
|
||||
useGetRepositoryFilesQuery,
|
||||
useGetResourceStatsQuery,
|
||||
|
@ -76,7 +77,7 @@ function getResourceStats(files?: GetRepositoryFilesApiResponse, stats?: GetReso
|
|||
/**
|
||||
* Hook that provides resource statistics and sync logic
|
||||
*/
|
||||
export function useResourceStats(repoName?: string, isLegacyStorage?: boolean) {
|
||||
export function useResourceStats(repoName?: string, isLegacyStorage?: boolean, syncTarget?: RepositoryView['target']) {
|
||||
const resourceStatsQuery = useGetResourceStatsQuery(repoName ? undefined : skipToken);
|
||||
const filesQuery = useGetRepositoryFilesQuery(repoName ? { name: repoName } : skipToken);
|
||||
|
||||
|
@ -96,7 +97,7 @@ export function useResourceStats(repoName?: string, isLegacyStorage?: boolean) {
|
|||
}, [resourceStatsQuery.data]);
|
||||
|
||||
const requiresMigration = isLegacyStorage || resourceCount > 0;
|
||||
const shouldSkipSync = !requiresMigration && resourceCount === 0 && fileCount === 0;
|
||||
const shouldSkipSync = !isLegacyStorage && (resourceCount === 0 || syncTarget === 'folder') && fileCount === 0;
|
||||
|
||||
// Format display strings
|
||||
const resourceCountDisplay =
|
||||
|
|
Loading…
Reference in New Issue