mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-26 06:18:04 +00:00
Huge bump of versions + husky + fixed DropDown key issue and pointer (#628)
* Bump lint-staged * Check * Check * Added husky * Check * Check * Check * Check * Check * Check * Check * Check * Fix husky * Used * instead **/* in lint-staged * Bump tailwindcss and related * Added @tailwindcss/vite and removed postcss * Added lint into staged * Bump @babel/core and updated .prettierignore * Removed tailwind.config.cjs * Added ThemeInit * Added cursor-pointer to Help dropdown * Bump react-router * Removed @types/uuid and react-router-dom * Bump diff2html, prettier, @typescript-eslint/eslint-plugin, @typescript-eslint/parser * removed vite-plugin-html-config and @babel/core * removed "@eslint/eslintrc" and "@eslint/js" * Removed redundant link * Returned plugins and source to index.css * Set dark to false in tailwindcss * Fixed storybook * Fixed useGetLatestVersion with correct gcTime: 0 option * Added eslint-plugin-prettier * Removed spaces * ClustersList.tsx improved and type fixes for another files * Repository.tsx improved * Huge fix of types * Huge fix of types missed * Fixed type of SingleValue * Added cursor pointer
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
import {
|
||||
useQuery,
|
||||
type UseQueryOptions,
|
||||
useMutation,
|
||||
type UseMutationOptions,
|
||||
useQuery,
|
||||
type UseQueryOptions,
|
||||
} from "@tanstack/react-query";
|
||||
import { ChartVersion, Release } from "../data/types";
|
||||
import { LatestChartVersion } from "./interfaces";
|
||||
import apiService from "./apiService";
|
||||
import { getVersionManifestFormData } from "./shared";
|
||||
import { isNewerVersion } from "../utils";
|
||||
|
||||
export const HD_RESOURCE_CONDITION_TYPE = "hdHealth"; // it's our custom condition type, only one exists
|
||||
|
||||
export function useGetInstalledReleases(
|
||||
context: string,
|
||||
options?: UseQueryOptions<Release[]>
|
||||
) {
|
||||
export function useGetInstalledReleases(context: string) {
|
||||
return useQuery<Release[]>({
|
||||
queryKey: ["installedReleases", context],
|
||||
queryFn: () =>
|
||||
apiService.fetchWithDefaults<Release[]>("/api/helm/releases"),
|
||||
...(options ?? {}),
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,18 +73,14 @@ export function useGetReleaseManifest({
|
||||
}
|
||||
|
||||
// List of installed k8s resources for this release
|
||||
export function useGetResources(
|
||||
ns: string,
|
||||
name: string,
|
||||
options?: UseQueryOptions<StructuredResources[]>
|
||||
) {
|
||||
export function useGetResources(ns: string, name: string, enabled?: boolean) {
|
||||
const { data, ...rest } = useQuery<StructuredResources[]>({
|
||||
queryKey: ["resources", ns, name],
|
||||
queryFn: () =>
|
||||
apiService.fetchWithDefaults<StructuredResources[]>(
|
||||
`/api/helm/releases/${ns}/${name}/resources?health=true`
|
||||
),
|
||||
...(options ?? {}),
|
||||
enabled,
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -138,6 +133,7 @@ export function useGetLatestVersion(
|
||||
apiService.fetchWithDefaults<ChartVersion[]>(
|
||||
`/api/helm/repositories/latestver?name=${chartName}`
|
||||
),
|
||||
gcTime: 0,
|
||||
...(options ?? {}),
|
||||
});
|
||||
}
|
||||
@@ -151,6 +147,8 @@ export function useGetVersions(
|
||||
apiService.fetchWithDefaults<LatestChartVersion[]>(
|
||||
`/api/helm/repositories/versions?name=${chartName}`
|
||||
),
|
||||
select: (data) =>
|
||||
data?.sort((a, b) => (isNewerVersion(a.version, b.version) ? 1 : -1)),
|
||||
...(options ?? {}),
|
||||
});
|
||||
}
|
||||
@@ -250,12 +248,12 @@ export function useChartReleaseValues({
|
||||
userDefinedValue?: string;
|
||||
revision?: number;
|
||||
version?: string;
|
||||
options?: UseQueryOptions<unknown>;
|
||||
options?: UseQueryOptions<string>;
|
||||
}) {
|
||||
return useQuery<unknown>({
|
||||
return useQuery<string>({
|
||||
queryKey: ["values", namespace, release, userDefinedValue, version],
|
||||
queryFn: () =>
|
||||
apiService.fetchWithDefaults<unknown>(
|
||||
apiService.fetchWithDefaults(
|
||||
`/api/helm/releases/${namespace}/${release}/values?${"userDefined=true"}${
|
||||
revision ? `&revision=${revision}` : ""
|
||||
}`,
|
||||
@@ -267,6 +265,12 @@ export function useChartReleaseValues({
|
||||
});
|
||||
}
|
||||
|
||||
export type VersionData = {
|
||||
version: string;
|
||||
repository?: string;
|
||||
urls: string[];
|
||||
};
|
||||
|
||||
export const useVersionData = ({
|
||||
version,
|
||||
userValues,
|
||||
@@ -275,7 +279,7 @@ export const useVersionData = ({
|
||||
namespace,
|
||||
releaseName,
|
||||
isInstallRepoChart = false,
|
||||
options,
|
||||
enabled = true,
|
||||
}: {
|
||||
version: string;
|
||||
userValues: string;
|
||||
@@ -284,9 +288,9 @@ export const useVersionData = ({
|
||||
namespace: string;
|
||||
releaseName: string;
|
||||
isInstallRepoChart?: boolean;
|
||||
options?: UseQueryOptions;
|
||||
enabled?: boolean;
|
||||
}) => {
|
||||
return useQuery({
|
||||
return useQuery<{ [key: string]: string }>({
|
||||
queryKey: [
|
||||
version,
|
||||
userValues,
|
||||
@@ -311,15 +315,16 @@ export const useVersionData = ({
|
||||
namespace ? namespace : "[empty]"
|
||||
}${`/${releaseName}`}`;
|
||||
|
||||
const data = await apiService.fetchWithDefaults(fetchUrl, {
|
||||
method: "post",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
return data;
|
||||
return await apiService.fetchWithDefaults<{ [key: string]: string }>(
|
||||
fetchUrl,
|
||||
{
|
||||
method: "post",
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
...(options ?? {}),
|
||||
enabled,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user