mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-28 23:38:04 +00:00
Enabled recommended-requiring-type-checking as result type fixes provided (#632)
* Enabled recommended-requiring-type-checking * from .cjs to .js * check * check * check * check * A lot of types aligned and refactored * More strict types * Improvement * Improvements * Improvements * Fixed routs * Fixed import types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useEffectEvent, useMemo, useState } from "react";
|
||||
import { Cluster, Release } from "../data/types";
|
||||
import { useEffect, useEffectEvent, useMemo } from "react";
|
||||
import type { Cluster, Release } from "../data/types";
|
||||
import apiService from "../API/apiService";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import useCustomSearchParams from "../hooks/useCustomSearchParams";
|
||||
@@ -43,21 +43,19 @@ function ClustersList({
|
||||
}: ClustersListProps) {
|
||||
const { upsertSearchParams, removeSearchParam } = useCustomSearchParams();
|
||||
const { clusterMode } = useAppContext();
|
||||
const [sortedClusters, setSortedClusters] = useState<Cluster[]>([]);
|
||||
|
||||
const { data: clusters, isSuccess } = useQuery<Cluster[]>({
|
||||
const { data: clusters = [], isSuccess } = useQuery<Cluster[]>({
|
||||
queryKey: ["clusters", selectedCluster],
|
||||
queryFn: apiService.getClusters,
|
||||
select: (data) =>
|
||||
data?.sort((a, b) =>
|
||||
getCleanClusterName(a.Name).localeCompare(getCleanClusterName(b.Name))
|
||||
),
|
||||
});
|
||||
|
||||
const onSuccess = useEffectEvent((clusters: Cluster[]) => {
|
||||
const sortedData = [...clusters].sort((a, b) =>
|
||||
getCleanClusterName(a.Name).localeCompare(getCleanClusterName(b.Name))
|
||||
);
|
||||
setSortedClusters(sortedData);
|
||||
|
||||
if (sortedData && sortedData.length > 0 && !selectedCluster) {
|
||||
onClusterChange(sortedData[0].Name);
|
||||
if (clusters && clusters.length && !selectedCluster) {
|
||||
onClusterChange(clusters[0].Name);
|
||||
}
|
||||
|
||||
if (selectedCluster) {
|
||||
@@ -111,10 +109,10 @@ function ClustersList({
|
||||
{!clusterMode ? (
|
||||
<>
|
||||
<label className="font-bold">Clusters</label>
|
||||
{sortedClusters?.map((cluster) => {
|
||||
{clusters?.map((cluster) => {
|
||||
return (
|
||||
<span
|
||||
key={cluster.Name}
|
||||
key={cluster.Name + cluster.Namespace}
|
||||
className="data-cy-clusterName mt-2 flex items-center text-xs"
|
||||
>
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user