mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 06:22:56 +08:00

* Update the generator to include version * Add versioned APIs * Update imports * Prettier
23 lines
730 B
TypeScript
23 lines
730 B
TypeScript
import { useCallback } from 'react';
|
|
|
|
import {
|
|
ReplaceRepositoryFilesWithPathApiArg,
|
|
useCreateRepositoryFilesWithPathMutation,
|
|
useReplaceRepositoryFilesWithPathMutation,
|
|
} from 'app/api/clients/provisioning/v0alpha1';
|
|
|
|
export function useCreateOrUpdateRepositoryFile(name?: string) {
|
|
const [create, createRequest] = useCreateRepositoryFilesWithPathMutation();
|
|
const [update, updateRequest] = useReplaceRepositoryFilesWithPathMutation();
|
|
|
|
const updateOrCreate = useCallback(
|
|
(data: ReplaceRepositoryFilesWithPathApiArg) => {
|
|
const actions = name ? update : create;
|
|
return actions(data);
|
|
},
|
|
[create, name, update]
|
|
);
|
|
|
|
return [updateOrCreate, name ? updateRequest : createRequest] as const;
|
|
}
|