mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-26 14:28:04 +00:00
Rename frontend directory (#472)
* Rename directory * Cleanup * Recover lost images * remove lint
This commit is contained in:
72
frontend/src/API/repositories.ts
Normal file
72
frontend/src/API/repositories.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import {
|
||||
type UseMutationOptions,
|
||||
type UseQueryOptions,
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query";
|
||||
import { HelmRepositories } from "./interfaces";
|
||||
import apiService from "./apiService";
|
||||
|
||||
// Get list of Helm repositories
|
||||
export function useGetRepositories(
|
||||
options?: UseQueryOptions<HelmRepositories>
|
||||
) {
|
||||
return useQuery<HelmRepositories>(
|
||||
["helm", "repositories"],
|
||||
() =>
|
||||
apiService.fetchWithDefaults<HelmRepositories>("/api/helm/repositories"),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
// Update repository from remote
|
||||
export function useUpdateRepo(
|
||||
repo: string,
|
||||
options?: UseMutationOptions<void, unknown, void>
|
||||
) {
|
||||
return useMutation<void, unknown, void>(() => {
|
||||
return apiService.fetchWithDefaults<void>(
|
||||
`/api/helm/repositories/${repo}`,
|
||||
{
|
||||
method: "POST",
|
||||
}
|
||||
);
|
||||
}, options);
|
||||
}
|
||||
|
||||
// Remove repository
|
||||
export function useDeleteRepo(
|
||||
repo: string,
|
||||
options?: UseMutationOptions<void, unknown, void>
|
||||
) {
|
||||
return useMutation<void, unknown, void>(() => {
|
||||
return apiService.fetchWithDefaults<void>(
|
||||
`/api/helm/repositories/${repo}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
}
|
||||
);
|
||||
}, options);
|
||||
}
|
||||
|
||||
export function useChartRepoValues({
|
||||
version,
|
||||
chart,
|
||||
}: {
|
||||
version: string;
|
||||
chart: string;
|
||||
}) {
|
||||
return useQuery<any>(
|
||||
["helm", "repositories", "values", chart, version],
|
||||
() =>
|
||||
apiService.fetchWithDefaults<any>(
|
||||
`/api/helm/repositories/values?chart=${chart}&version=${version}`,
|
||||
{
|
||||
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
||||
}
|
||||
),
|
||||
{
|
||||
enabled: Boolean(version) && Boolean(chart),
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user