mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 03:12:13 +08:00

* centralise iam api * centralise folder api client * rename to baseAPI * centralise provisioning api * remove iam feature folder from CODEOWNERS * fix type name * Update public/app/features/provisioning/utils/selectors.ts Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> --------- Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
23 lines
726 B
TypeScript
23 lines
726 B
TypeScript
import { useCallback } from 'react';
|
|
|
|
import {
|
|
ReplaceRepositoryFilesWithPathApiArg,
|
|
useCreateRepositoryFilesWithPathMutation,
|
|
useReplaceRepositoryFilesWithPathMutation,
|
|
} from '../../../api/clients/provisioning';
|
|
|
|
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;
|
|
}
|