mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 04:00:55 +08:00

* Provisioning: Add hooks and utils * Fix folder API call * Update public/app/features/provisioning/utils/git.ts Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * Fixes * Remove unused import --------- Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
23 lines
693 B
TypeScript
23 lines
693 B
TypeScript
import { useCallback } from 'react';
|
|
|
|
import {
|
|
ReplaceRepositoryFilesWithPathArg,
|
|
useCreateRepositoryFilesWithPathMutation,
|
|
useReplaceRepositoryFilesWithPathMutation,
|
|
} from '../api';
|
|
|
|
export function useCreateOrUpdateRepositoryFile(name?: string) {
|
|
const [create, createRequest] = useCreateRepositoryFilesWithPathMutation();
|
|
const [update, updateRequest] = useReplaceRepositoryFilesWithPathMutation();
|
|
|
|
const updateOrCreate = useCallback(
|
|
(data: ReplaceRepositoryFilesWithPathArg) => {
|
|
const actions = name ? update : create;
|
|
return actions(data);
|
|
},
|
|
[create, name, update]
|
|
);
|
|
|
|
return [updateOrCreate, name ? updateRequest : createRequest] as const;
|
|
}
|