@skyhook-io/radar-app 1.18.0 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +2 -3
- package/src/App.tsx +43 -12
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +197 -57
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/components/capacity/CapacityDemand.tsx +6 -3
- package/src/components/capacity/CapacityOverview.tsx +14 -7
- package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
- package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
- package/src/components/capacity/shared.tsx +9 -5
- package/src/components/cnpg/CNPGOverview.tsx +4 -1
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +60 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +62 -2
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +6 -5
- package/src/components/diagnose/InvestigationView.tsx +47 -13
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/assessmentCopy.ts +11 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
- package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +16 -2
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/observations.ts +8 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +81 -4
- package/src/components/diagnose/investigationEvidence/types.ts +15 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/storyParts.test.tsx +53 -0
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.tsx +6 -4
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +62 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +9 -8
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
- package/src/components/helm/HelmView.tsx +34 -23
- package/src/components/helm/InstallWizard.tsx +6 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
- package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
- package/src/components/helm/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +28 -21
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/mcpToolCatalog.ts +39 -2
- package/src/components/issues/IssuesPane.render.test.tsx +5 -5
- package/src/components/nav/PrimaryNavRail.tsx +34 -2
- package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
- package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
- package/src/components/product-hunt/launchWindow.ts +78 -0
- package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
- package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +30 -68
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +9 -55
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +82 -18
- package/src/components/ui/RadarOmnibar.test.tsx +201 -0
- package/src/components/ui/RadarOmnibar.tsx +39 -4
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +4 -1
- package/src/components/ui/UpdateNotification.tsx +61 -10
- package/src/components/ui/omnibar-match.test.ts +15 -8
- package/src/components/ui/omnibar-match.ts +11 -6
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/WorkloadView.tsx +18 -6
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
- package/src/hooks/useGitOpsWriteGuard.ts +25 -3
- package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +87 -4
- package/src/index.ts +7 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
package/src/api/client.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { createListRefetchInterval, normalizeResourceList, type ResourceListBody, type ResourceListResult } from './resourceLists'
|
|
2
|
+
import type { CascadeDetail } from '@skyhook-io/k8s-ui/components/ui/ForceDeleteConfirmDialog'
|
|
1
3
|
import { canonicalResourceGroup } from '@skyhook-io/k8s-ui/utils/api-resources'
|
|
2
4
|
import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
|
|
3
5
|
import { knownKindForPluralWithGroup, pluralToKind } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
4
6
|
import { useEffect, useRef, useCallback, useMemo } from 'react'
|
|
5
7
|
import type { KueueAdmissionResponse } from '@skyhook-io/k8s-ui/types/scheduling'
|
|
8
|
+
import { canonicalReadCode, readActionFor } from '@skyhook-io/k8s-ui/utils/read-actions'
|
|
9
|
+
import type { SearchCoverage } from '@skyhook-io/k8s-ui/types/read-coverage'
|
|
6
10
|
import type { GitOpsWriteEvidence } from '@skyhook-io/k8s-ui/utils/gitops-write-guard'
|
|
7
11
|
import type {
|
|
8
12
|
AppHistory,
|
|
@@ -291,13 +295,14 @@ export function isStillLoadingError(error: unknown): boolean {
|
|
|
291
295
|
return isKindSyncPending(error) || isClusterConnecting(error);
|
|
292
296
|
}
|
|
293
297
|
|
|
294
|
-
// isKindSyncFailed matches
|
|
295
|
-
//
|
|
298
|
+
// isKindSyncFailed matches a kind that missed its sync deadline. Radar keeps
|
|
299
|
+
// loading it, so a later reload may succeed, but retrying at once won't —
|
|
300
|
+
// show the error. Older Radars spelled the code kind_sync_failed.
|
|
296
301
|
export function isKindSyncFailed(error: unknown): boolean {
|
|
297
302
|
return (
|
|
298
303
|
error instanceof ApiError &&
|
|
299
304
|
error.status === 503 &&
|
|
300
|
-
error.data?.error_code === "
|
|
305
|
+
canonicalReadCode(error.data?.error_code) === "kind_sync_timed_out"
|
|
301
306
|
);
|
|
302
307
|
}
|
|
303
308
|
|
|
@@ -806,12 +811,14 @@ export function useResourceAudit(
|
|
|
806
811
|
name: string,
|
|
807
812
|
group?: string,
|
|
808
813
|
) {
|
|
814
|
+
const { segment: emptyNamespaceSegment, pending: capabilitiesPending } = useEmptyNamespaceSegment();
|
|
809
815
|
const params = new URLSearchParams();
|
|
810
816
|
if (group) params.set("group", group);
|
|
811
817
|
const query = params.toString();
|
|
812
818
|
return useQuery<AuditFinding[]>({
|
|
813
|
-
queryKey: ["audit", "resource", kind, group ?? "", namespace, name],
|
|
814
|
-
queryFn: () => fetchJSON(`/audit/resource/${kind
|
|
819
|
+
queryKey: ["audit", "resource", kind, group ?? "", namespace, name, namespace ? "" : emptyNamespaceSegment],
|
|
820
|
+
queryFn: () => fetchJSON(`/audit/resource/${resourcePathSegments(kind, namespace, name, emptyNamespaceSegment)}${query ? `?${query}` : ""}`),
|
|
821
|
+
enabled: namespace !== "" || !capabilitiesPending,
|
|
815
822
|
staleTime: 30000,
|
|
816
823
|
});
|
|
817
824
|
}
|
|
@@ -853,6 +860,7 @@ export function useResourceIssues(
|
|
|
853
860
|
// the caller's RBAC withheld. Polls like the page list.
|
|
854
861
|
export interface CronJobSchedulingEvidence {
|
|
855
862
|
uid: string;
|
|
863
|
+
event_id?: string;
|
|
856
864
|
state: 'reported' | 'configuration_changed' | 'history_incomplete';
|
|
857
865
|
reason: string;
|
|
858
866
|
message: string;
|
|
@@ -1785,6 +1793,7 @@ export async function markWhatsNewSeen(version: string): Promise<void> {
|
|
|
1785
1793
|
|
|
1786
1794
|
export interface VersionInfo {
|
|
1787
1795
|
currentVersion: string;
|
|
1796
|
+
buildChannel?: 'stable' | 'prerelease' | 'custom' | 'development';
|
|
1788
1797
|
latestVersion?: string;
|
|
1789
1798
|
updateAvailable: boolean;
|
|
1790
1799
|
releaseUrl?: string;
|
|
@@ -1792,6 +1801,7 @@ export interface VersionInfo {
|
|
|
1792
1801
|
installMethod: InstallMethod;
|
|
1793
1802
|
updateCommand?: string;
|
|
1794
1803
|
error?: string;
|
|
1804
|
+
productHuntLaunch?: { enabled: boolean; url: string; start: string; end: string };
|
|
1795
1805
|
}
|
|
1796
1806
|
|
|
1797
1807
|
const UPDATE_CHECK_STORAGE_KEY_PREFIX = 'radar-update-check';
|
|
@@ -2003,36 +2013,39 @@ export interface SearchResult {
|
|
|
2003
2013
|
total: number;
|
|
2004
2014
|
searched: number;
|
|
2005
2015
|
total_matched: number;
|
|
2006
|
-
/** "time_limit" when scan report findings were only partly searched. */
|
|
2016
|
+
/** From Radars that predate search coverage: "time_limit" when scan report findings were only partly searched. */
|
|
2007
2017
|
incomplete_findings?: string;
|
|
2008
|
-
/**
|
|
2018
|
+
/** From Radars that predate search coverage: some namespaces' scan reports were left out, access not confirmed yet. */
|
|
2009
2019
|
access_incomplete?: boolean;
|
|
2020
|
+
/** Absent from Radars that predate search coverage, which say nothing about it. */
|
|
2021
|
+
coverage?: SearchCoverage;
|
|
2010
2022
|
}
|
|
2011
2023
|
|
|
2012
2024
|
const SEARCH_MIN_QUERY = 2;
|
|
2013
2025
|
|
|
2014
2026
|
// useSearch hits the resource-search engine. The caller supplies the (already
|
|
2015
2027
|
// debounced) query; the hook is enabled only past the min length. include=none
|
|
2016
|
-
// keeps the per-hit payload identity-only; context=
|
|
2017
|
-
//
|
|
2028
|
+
// keeps the per-hit payload identity-only; context=status attaches health/issueCount,
|
|
2029
|
+
// while context=summary also requests navigation. React Query's AbortSignal cancels
|
|
2018
2030
|
// overlapping scans on a new query. keepPreviousData avoids flicker while the
|
|
2019
2031
|
// next query resolves.
|
|
2020
2032
|
export function useSearch(
|
|
2021
2033
|
query: string,
|
|
2022
2034
|
opts?: {
|
|
2023
2035
|
limit?: number;
|
|
2024
|
-
context?: "summary" | "none";
|
|
2036
|
+
context?: "summary" | "status" | "none";
|
|
2025
2037
|
enabled?: boolean;
|
|
2026
2038
|
globalNs?: boolean;
|
|
2039
|
+
/** Re-query on an interval decided from the latest response. */
|
|
2040
|
+
refetchInterval?: (data: SearchResult | undefined) => number | false;
|
|
2027
2041
|
},
|
|
2028
2042
|
) {
|
|
2029
2043
|
const trimmed = query.trim();
|
|
2030
2044
|
const enabled = (opts?.enabled ?? true) && trimmed.length >= SEARCH_MIN_QUERY;
|
|
2031
2045
|
const limit = opts?.limit ?? 20;
|
|
2032
2046
|
const context = opts?.context ?? "summary";
|
|
2033
|
-
//
|
|
2034
|
-
//
|
|
2035
|
-
// tokens). The omnibar opts in so ⌘K is a genuinely global lookup.
|
|
2047
|
+
// Searches always ignore the saved namespace pick. Keep globalNs as the
|
|
2048
|
+
// explicit global-search marker used by the omnibar and embedded hosts.
|
|
2036
2049
|
const globalNs = opts?.globalNs ?? false;
|
|
2037
2050
|
return useQuery<SearchResult>({
|
|
2038
2051
|
queryKey: ["search", trimmed, limit, context, globalNs],
|
|
@@ -2043,6 +2056,7 @@ export function useSearch(
|
|
|
2043
2056
|
),
|
|
2044
2057
|
enabled,
|
|
2045
2058
|
staleTime: 2000,
|
|
2059
|
+
refetchInterval: (q) => opts?.refetchInterval?.(q.state.data) ?? false,
|
|
2046
2060
|
placeholderData: (prev) => prev, // keepPreviousData
|
|
2047
2061
|
});
|
|
2048
2062
|
}
|
|
@@ -2758,21 +2772,42 @@ export function useArgoRevisionMetadata(
|
|
|
2758
2772
|
});
|
|
2759
2773
|
}
|
|
2760
2774
|
|
|
2775
|
+
// A cluster-scoped resource sends "_" as its namespace segment: proxies in
|
|
2776
|
+
// front of Radar (Radar Cloud's among them) merge "//", which drops the
|
|
2777
|
+
// segment and leaves a path no route matches.
|
|
2778
|
+
function resourcePathSegments(
|
|
2779
|
+
kind: string,
|
|
2780
|
+
namespace: string,
|
|
2781
|
+
name: string,
|
|
2782
|
+
emptyNamespaceSegment = "_",
|
|
2783
|
+
): string {
|
|
2784
|
+
return `${kind}/${namespace || emptyNamespaceSegment}/${name}`;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
// A Radar without the clusterScopedPlaceholder flag reads "_" on the update and
|
|
2788
|
+
// audit routes as a real namespace, so until the flag is confirmed these
|
|
2789
|
+
// routes keep the empty segment every Radar accepts when reached directly.
|
|
2790
|
+
function useEmptyNamespaceSegment() {
|
|
2791
|
+
const { data: capabilities, isPending } = useCapabilities();
|
|
2792
|
+
return {
|
|
2793
|
+
segment: capabilities?.features?.clusterScopedPlaceholder ? "_" : "",
|
|
2794
|
+
pending: isPending,
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2761
2798
|
// Generic resource fetching - returns resource with relationships
|
|
2762
|
-
// Uses '_' as placeholder for cluster-scoped resources (empty namespace)
|
|
2763
2799
|
export function fetchResourceWithRelationships<T>(
|
|
2764
2800
|
kind: string,
|
|
2765
2801
|
namespace: string,
|
|
2766
2802
|
name: string,
|
|
2767
2803
|
group?: string,
|
|
2768
2804
|
): Promise<ResourceWithRelationships<T>> {
|
|
2769
|
-
const ns = namespace || "_";
|
|
2770
2805
|
const params = new URLSearchParams();
|
|
2771
2806
|
if (group) params.set("group", group);
|
|
2772
2807
|
const queryString = params.toString();
|
|
2773
2808
|
|
|
2774
2809
|
return fetchJSON(
|
|
2775
|
-
`/resources/${kind
|
|
2810
|
+
`/resources/${resourcePathSegments(kind, namespace, name)}${queryString ? `?${queryString}` : ""}`,
|
|
2776
2811
|
);
|
|
2777
2812
|
}
|
|
2778
2813
|
|
|
@@ -2897,6 +2932,38 @@ export function useResourceWithRelationships<T>(
|
|
|
2897
2932
|
});
|
|
2898
2933
|
}
|
|
2899
2934
|
|
|
2935
|
+
export interface ResourceListOptions {
|
|
2936
|
+
namespaces?: string[]
|
|
2937
|
+
group?: string
|
|
2938
|
+
table?: boolean
|
|
2939
|
+
summary?: boolean
|
|
2940
|
+
signal?: AbortSignal
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
export async function fetchResourceList<T>(kind: string, options: ResourceListOptions = {}): Promise<ResourceListResult<T>> {
|
|
2944
|
+
const params = new URLSearchParams()
|
|
2945
|
+
if (options.namespaces?.length) params.set('namespaces', options.namespaces.join(','))
|
|
2946
|
+
if (options.group) params.set('group', options.group)
|
|
2947
|
+
if (options.table) params.set('table', '1')
|
|
2948
|
+
if (options.summary) params.set('include', 'summary')
|
|
2949
|
+
// A Radar that predates the list budget ignores the parameter.
|
|
2950
|
+
params.set('maxItems', options.summary ? '50000' : '25000')
|
|
2951
|
+
const body = await fetchJSON<ResourceListBody<T>>(`/resources/${encodeURIComponent(kind)}?${params}`, options.signal)
|
|
2952
|
+
return normalizeResourceList<T>(body)
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
// A read failure no retry can answer: the request, the caller's access or
|
|
2956
|
+
// Radar's collection has to change first (too large, outside the collector, a
|
|
2957
|
+
// denial), so it is shown at once.
|
|
2958
|
+
export function isUnretryableReadError(error: unknown): boolean {
|
|
2959
|
+
return error instanceof ApiError && !['retry', undefined].includes(readActionFor(error.data?.error_code))
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
// The list is over the request's size budget; the body carries `count` and `limit`.
|
|
2963
|
+
export function isListTooLargeError(error: unknown): error is ApiError {
|
|
2964
|
+
return error instanceof ApiError && error.data?.error_code === 'list_too_large'
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2900
2967
|
// List resources - queryKey includes group for cache sharing with ResourcesView
|
|
2901
2968
|
export function useResources<T>(
|
|
2902
2969
|
kind: string,
|
|
@@ -2904,29 +2971,26 @@ export function useResources<T>(
|
|
|
2904
2971
|
group?: string,
|
|
2905
2972
|
options?: { enabled?: boolean; refetchInterval?: number | false; cacheScope?: string },
|
|
2906
2973
|
) {
|
|
2907
|
-
const
|
|
2908
|
-
|
|
2909
|
-
if (group) params.set("group", group);
|
|
2910
|
-
const queryString = params.toString();
|
|
2911
|
-
|
|
2912
|
-
return useQuery<T[]>({
|
|
2974
|
+
const loadingInterval = useMemo(() => createListRefetchInterval(options?.refetchInterval), [options?.refetchInterval])
|
|
2975
|
+
const query = useQuery<ResourceListResult<T>>({
|
|
2913
2976
|
queryKey: ["resources", kind, group, namespace, ...(options?.cacheScope ? [options.cacheScope] : [])],
|
|
2914
|
-
queryFn: () =>
|
|
2915
|
-
fetchJSON(`/resources/${kind}${queryString ? `?${queryString}` : ""}`),
|
|
2977
|
+
queryFn: ({ signal }) => fetchResourceList<T>(kind, { namespaces: namespace ? [namespace] : [], group, signal }),
|
|
2916
2978
|
enabled: (options?.enabled ?? true) && Boolean(kind),
|
|
2917
2979
|
staleTime: 30000, // 30 seconds - matches refetchInterval in ResourcesView
|
|
2918
|
-
refetchInterval:
|
|
2980
|
+
refetchInterval: loadingInterval,
|
|
2919
2981
|
// Kind still completing its initial sync (progressive shell, or a
|
|
2920
2982
|
// deferred kind shortly after connect): keep polling instead of
|
|
2921
2983
|
// surfacing an error.
|
|
2922
2984
|
retry: (failureCount, error) => {
|
|
2923
2985
|
if (isStillLoadingError(error)) return true;
|
|
2924
2986
|
if (isKindSyncFailed(error)) return false;
|
|
2987
|
+
if (isUnretryableReadError(error)) return false;
|
|
2925
2988
|
return failureCount < 1; // one retry, 4xx included, unlike the QueryClient default
|
|
2926
2989
|
},
|
|
2927
2990
|
retryDelay: (failureCount, error) =>
|
|
2928
2991
|
isStillLoadingError(error) ? 2000 : Math.min(1000 * 2 ** failureCount, 30000),
|
|
2929
2992
|
});
|
|
2993
|
+
return { ...query, data: query.data?.items, coverage: query.data?.coverage };
|
|
2930
2994
|
}
|
|
2931
2995
|
|
|
2932
2996
|
// Timeline changes (unified view of changes + K8s events)
|
|
@@ -4354,6 +4418,7 @@ export function useAvailablePorts(
|
|
|
4354
4418
|
// Update a resource with new YAML
|
|
4355
4419
|
export function useUpdateResource() {
|
|
4356
4420
|
const queryClient = useQueryClient();
|
|
4421
|
+
const { segment: emptyNamespaceSegment } = useEmptyNamespaceSegment();
|
|
4357
4422
|
|
|
4358
4423
|
return useMutation({
|
|
4359
4424
|
mutationFn: async ({
|
|
@@ -4374,7 +4439,7 @@ export function useUpdateResource() {
|
|
|
4374
4439
|
reviewedContext?: string
|
|
4375
4440
|
}) => {
|
|
4376
4441
|
const url = new URL(
|
|
4377
|
-
`${getApiBase()}/resources/${kind
|
|
4442
|
+
`${getApiBase()}/resources/${resourcePathSegments(kind, namespace, name, emptyNamespaceSegment)}`,
|
|
4378
4443
|
window.location.origin,
|
|
4379
4444
|
);
|
|
4380
4445
|
if (!force) {
|
|
@@ -4448,8 +4513,8 @@ export function useUpdateResource() {
|
|
|
4448
4513
|
});
|
|
4449
4514
|
}
|
|
4450
4515
|
|
|
4451
|
-
//
|
|
4452
|
-
export interface CascadeDeletePreview {
|
|
4516
|
+
// Cached owner-reference projection and root controller cleanup.
|
|
4517
|
+
export interface CascadeDeletePreview extends CascadeDetail {
|
|
4453
4518
|
root: { kind: string; namespace: string; name: string; group?: string };
|
|
4454
4519
|
rootResolved: boolean;
|
|
4455
4520
|
dependents: {
|
|
@@ -4471,14 +4536,62 @@ export function useCascadeDeletePreview(
|
|
|
4471
4536
|
queryKey: ["cascade-preview", kind, group, namespace, name],
|
|
4472
4537
|
queryFn: () =>
|
|
4473
4538
|
fetchJSON<CascadeDeletePreview>(
|
|
4474
|
-
`/resources/${kind
|
|
4539
|
+
`/resources/${resourcePathSegments(kind, namespace, name)}/cascade-preview${group ? `?group=${encodeURIComponent(group)}` : ""}`,
|
|
4475
4540
|
),
|
|
4476
4541
|
enabled,
|
|
4477
|
-
staleTime:
|
|
4542
|
+
staleTime: 0,
|
|
4478
4543
|
});
|
|
4479
4544
|
}
|
|
4480
4545
|
|
|
4481
4546
|
// Delete a resource
|
|
4547
|
+
interface DeleteResourceResult {
|
|
4548
|
+
deletionTimestamp?: string;
|
|
4549
|
+
pendingFinalizers?: string[];
|
|
4550
|
+
observationError?: string;
|
|
4551
|
+
outcomeUnknown?: boolean;
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
async function readDeleteResult(request: Promise<Response>): Promise<DeleteResourceResult> {
|
|
4555
|
+
let response: Response;
|
|
4556
|
+
try {
|
|
4557
|
+
response = await request;
|
|
4558
|
+
} catch (error) {
|
|
4559
|
+
return { outcomeUnknown: true, observationError: String(error) };
|
|
4560
|
+
}
|
|
4561
|
+
if (!response.ok) {
|
|
4562
|
+
const error = await readErrorBody(response);
|
|
4563
|
+
if (response.status >= 500 || response.status === 408) {
|
|
4564
|
+
return { outcomeUnknown: true, observationError: error.error || `HTTP ${response.status}` };
|
|
4565
|
+
}
|
|
4566
|
+
throw new Error(error.error || `HTTP ${response.status}`);
|
|
4567
|
+
}
|
|
4568
|
+
const unconfirmed = { observationError: "Deletion accepted; the response did not confirm cleanup." };
|
|
4569
|
+
try {
|
|
4570
|
+
const result = JSON.parse(await response.text()) as DeleteResourceResult;
|
|
4571
|
+
if (result === null || typeof result !== "object" || Array.isArray(result)
|
|
4572
|
+
|| (result.deletionTimestamp !== undefined && typeof result.deletionTimestamp !== "string")
|
|
4573
|
+
|| (result.observationError !== undefined && typeof result.observationError !== "string")
|
|
4574
|
+
|| (result.pendingFinalizers !== undefined && (!Array.isArray(result.pendingFinalizers) || result.pendingFinalizers.some(value => typeof value !== "string")))) {
|
|
4575
|
+
return unconfirmed;
|
|
4576
|
+
}
|
|
4577
|
+
return result;
|
|
4578
|
+
} catch {
|
|
4579
|
+
return unconfirmed;
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
|
|
4583
|
+
function deleteResourceNotification(result: DeleteResourceResult): { message: string; type: "info" | "success"; detail?: string } {
|
|
4584
|
+
if (result.outcomeUnknown) return { message: "Deletion outcome unknown; inspect before retrying", type: "info", detail: result.observationError };
|
|
4585
|
+
if (result.observationError) {
|
|
4586
|
+
return { message: "Deletion accepted; completion unconfirmed", type: "info", detail: result.observationError };
|
|
4587
|
+
}
|
|
4588
|
+
if (result.pendingFinalizers?.length) {
|
|
4589
|
+
return { message: `Deleting — waiting on finalizers: ${result.pendingFinalizers.join(", ")}`, type: "info" };
|
|
4590
|
+
}
|
|
4591
|
+
if (result.deletionTimestamp) return { message: "Deleting…", type: "info" };
|
|
4592
|
+
return { message: "Resource deleted", type: "success" };
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4482
4595
|
export function useDeleteResource() {
|
|
4483
4596
|
const queryClient = useQueryClient();
|
|
4484
4597
|
|
|
@@ -4497,7 +4610,7 @@ export function useDeleteResource() {
|
|
|
4497
4610
|
force?: boolean;
|
|
4498
4611
|
}) => {
|
|
4499
4612
|
const url = new URL(
|
|
4500
|
-
|
|
4613
|
+
apiUrl(`/resources/${resourcePathSegments(kind, namespace, name)}`),
|
|
4501
4614
|
window.location.origin,
|
|
4502
4615
|
);
|
|
4503
4616
|
if (group) {
|
|
@@ -4506,21 +4619,18 @@ export function useDeleteResource() {
|
|
|
4506
4619
|
if (force) {
|
|
4507
4620
|
url.searchParams.set("force", "true");
|
|
4508
4621
|
}
|
|
4509
|
-
|
|
4510
|
-
method: "DELETE",
|
|
4511
|
-
});
|
|
4512
|
-
if (!response.ok) {
|
|
4513
|
-
const error = await readErrorBody(response);
|
|
4514
|
-
throw new Error(error.error || `HTTP ${response.status}`);
|
|
4515
|
-
}
|
|
4516
|
-
// DELETE returns 204 No Content, no body to parse
|
|
4517
|
-
return { success: true };
|
|
4622
|
+
return readDeleteResult(apiFetch(url.toString(), { method: "DELETE" }));
|
|
4518
4623
|
},
|
|
4519
4624
|
meta: {
|
|
4520
4625
|
errorMessage: "Failed to delete resource",
|
|
4521
|
-
successMessage: "Resource deleted",
|
|
4522
4626
|
},
|
|
4523
|
-
onSuccess: (
|
|
4627
|
+
onSuccess: (result, variables) => {
|
|
4628
|
+
const { message, detail, type } = deleteResourceNotification(result);
|
|
4629
|
+
if (type === "success") {
|
|
4630
|
+
showApiSuccess(message, detail);
|
|
4631
|
+
} else {
|
|
4632
|
+
showApiNotice(message, detail, type);
|
|
4633
|
+
}
|
|
4524
4634
|
queryClient.invalidateQueries({
|
|
4525
4635
|
queryKey: ["resources", variables.kind],
|
|
4526
4636
|
});
|
|
@@ -4548,32 +4658,60 @@ export function useBulkDeleteResources() {
|
|
|
4548
4658
|
const results = await Promise.allSettled(
|
|
4549
4659
|
items.map(async ({ kind, group, namespace, name }) => {
|
|
4550
4660
|
const url = new URL(
|
|
4551
|
-
|
|
4661
|
+
apiUrl(`/resources/${resourcePathSegments(kind, namespace, name)}`),
|
|
4552
4662
|
window.location.origin,
|
|
4553
4663
|
);
|
|
4554
4664
|
if (group) url.searchParams.set("group", group);
|
|
4555
4665
|
if (force) url.searchParams.set("force", "true");
|
|
4556
|
-
|
|
4557
|
-
if (!response.ok) {
|
|
4558
|
-
const error = await readErrorBody(response);
|
|
4559
|
-
throw new Error(
|
|
4560
|
-
error.error || `Failed to delete ${namespace}/${name}`,
|
|
4561
|
-
);
|
|
4562
|
-
}
|
|
4563
|
-
return { kind, namespace, name };
|
|
4666
|
+
return { kind, namespace, name, result: await readDeleteResult(apiFetch(url.toString(), { method: "DELETE" })) };
|
|
4564
4667
|
}),
|
|
4565
4668
|
);
|
|
4566
4669
|
const failed = results.filter((r) => r.status === "rejected");
|
|
4567
4670
|
if (failed.length > 0) {
|
|
4671
|
+
const unknown = results.filter(result => result.status === "fulfilled" && result.value.result.outcomeUnknown).length;
|
|
4568
4672
|
throw new Error(
|
|
4569
|
-
`Failed to delete ${failed.length} of ${items.length} resources`,
|
|
4673
|
+
`Failed to delete ${failed.length} of ${items.length} ${items.length === 1 ? "resource" : "resources"}${unknown ? `; deletion outcome unknown for ${unknown}; inspect before retrying` : ""}`,
|
|
4570
4674
|
);
|
|
4571
4675
|
}
|
|
4572
|
-
return
|
|
4676
|
+
return results.flatMap((r) => r.status === "fulfilled" ? [r.value] : []);
|
|
4573
4677
|
},
|
|
4574
4678
|
meta: {
|
|
4575
4679
|
errorMessage: "Failed to delete some resources",
|
|
4576
|
-
|
|
4680
|
+
},
|
|
4681
|
+
onSuccess: (deleted) => {
|
|
4682
|
+
const pending = deleted.filter(({ result }) => result.pendingFinalizers?.length);
|
|
4683
|
+
const unknown = deleted.filter(({ result }) => result.outcomeUnknown);
|
|
4684
|
+
const unobserved = deleted.filter(({ result }) => result.observationError);
|
|
4685
|
+
const deleting = deleted.filter(({ result }) => result.deletionTimestamp);
|
|
4686
|
+
const resources = `${deleted.length} ${deleted.length === 1 ? "resource" : "resources"}`;
|
|
4687
|
+
let message = `${resources} deleted`;
|
|
4688
|
+
let type: "info" | "success" = "success";
|
|
4689
|
+
const unread = `completion unconfirmed for ${unobserved.length}`;
|
|
4690
|
+
if (unknown.length) {
|
|
4691
|
+
message = `Deletion outcome unknown for ${unknown.length} ${unknown.length === 1 ? "resource" : "resources"}; inspect before retrying${pending.length ? `; ${pending.length} waiting on finalizers` : ""}`;
|
|
4692
|
+
type = "info";
|
|
4693
|
+
} else if (pending.length) {
|
|
4694
|
+
message = `Deleting — ${pending.length} ${pending.length === 1 ? "resource" : "resources"} waiting on finalizers${unobserved.length ? `; ${unread}` : ""}`;
|
|
4695
|
+
type = "info";
|
|
4696
|
+
} else if (unobserved.length) {
|
|
4697
|
+
message = `Deletion accepted for ${resources}; ${unread}`;
|
|
4698
|
+
type = "info";
|
|
4699
|
+
} else if (deleting.length) {
|
|
4700
|
+
message = `Deleting ${deleting.length} ${deleting.length === 1 ? "resource" : "resources"}…`;
|
|
4701
|
+
type = "info";
|
|
4702
|
+
}
|
|
4703
|
+
const details = deleted.flatMap(({ namespace, name, result }) => {
|
|
4704
|
+
const notification = deleteResourceNotification(result);
|
|
4705
|
+
return result.observationError || result.pendingFinalizers?.length || result.deletionTimestamp
|
|
4706
|
+
? [`${namespace}/${name}: ${notification.message}${notification.detail ? `: ${notification.detail}` : ""}`]
|
|
4707
|
+
: [];
|
|
4708
|
+
});
|
|
4709
|
+
const detail = details.length ? listWithOverflow(details) : undefined;
|
|
4710
|
+
if (type === "success") {
|
|
4711
|
+
showApiSuccess(message, detail);
|
|
4712
|
+
} else {
|
|
4713
|
+
showApiNotice(message, detail, type);
|
|
4714
|
+
}
|
|
4577
4715
|
},
|
|
4578
4716
|
// onSettled, not onSuccess — a partial failure still deleted some
|
|
4579
4717
|
// resources, and the table must refetch to drop them.
|
|
@@ -7091,10 +7229,11 @@ export function useContexts() {
|
|
|
7091
7229
|
|
|
7092
7230
|
// Where a remote Argo Application or Flux object (spec.kubeConfig) deploys:
|
|
7093
7231
|
// the destination's host for display, and the kubeconfig contexts that reach it.
|
|
7094
|
-
export function useGitOpsDestination(kind: string, namespace: string, name: string, enabled: boolean) {
|
|
7232
|
+
export function useGitOpsDestination(kind: string, namespace: string, name: string, enabled: boolean, group?: string) {
|
|
7233
|
+
const queryString = group ? `?group=${encodeURIComponent(group)}` : "";
|
|
7095
7234
|
return useQuery<{ server: string; contexts: string[] }>({
|
|
7096
|
-
queryKey: ["gitops-destination", kind, namespace, name],
|
|
7097
|
-
queryFn: () => fetchJSON(`/gitops/destination/${encodeURIComponent(kind)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`),
|
|
7235
|
+
queryKey: ["gitops-destination", kind, namespace, name, group ?? ""],
|
|
7236
|
+
queryFn: () => fetchJSON(`/gitops/destination/${encodeURIComponent(kind)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}${queryString}`),
|
|
7098
7237
|
enabled,
|
|
7099
7238
|
staleTime: 60000,
|
|
7100
7239
|
retry: false,
|
|
@@ -7873,6 +8012,7 @@ export interface DiagnosticsSnapshot {
|
|
|
7873
8012
|
debugEvents: boolean;
|
|
7874
8013
|
mcpEnabled: boolean;
|
|
7875
8014
|
mcpReadOnly: boolean;
|
|
8015
|
+
pprof?: boolean;
|
|
7876
8016
|
hasPrometheusURL: boolean;
|
|
7877
8017
|
hasPrometheusHeaders: boolean;
|
|
7878
8018
|
};
|
package/src/api/quotas.ts
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fetchJSON } from './client'
|
|
1
|
+
import { useResources } from './client'
|
|
3
2
|
|
|
4
3
|
// useNamespaceQuotas fetches a namespace's ResourceQuota objects via
|
|
5
|
-
// /api/resources/resourcequotas?
|
|
4
|
+
// /api/resources/resourcequotas?namespaces=<ns> (the `{items, coverage}`
|
|
5
|
+
// list envelope; useResources returns the items). Backs the
|
|
6
6
|
// NamespaceRenderer quota-usage section — quota saturation is otherwise
|
|
7
7
|
// surfaced nowhere in the UI, yet it's exactly why a namespace stops
|
|
8
8
|
// admitting new pods.
|
|
9
9
|
export function useNamespaceQuotas(namespace: string, enabled = true) {
|
|
10
|
-
return
|
|
11
|
-
queryKey: ['resourcequotas', namespace],
|
|
12
|
-
queryFn: () => fetchJSON<any[]>(`/resources/resourcequotas?namespace=${encodeURIComponent(namespace)}`),
|
|
13
|
-
enabled: enabled && !!namespace,
|
|
14
|
-
staleTime: 15000,
|
|
15
|
-
})
|
|
10
|
+
return useResources<any>('resourcequotas', namespace, undefined, { enabled: enabled && !!namespace })
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
// useNamespaceLimitRanges fetches a namespace's LimitRange objects
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// only visible by reading the object.
|
|
13
|
+
// useNamespaceLimitRanges fetches a namespace's LimitRange objects the same
|
|
14
|
+
// way. Backs the NamespaceRenderer rules section and the contextual link on
|
|
15
|
+
// Pod/workload details — the defaults and constraints applied at admission
|
|
16
|
+
// are otherwise only visible by reading the object.
|
|
23
17
|
export function useNamespaceLimitRanges(namespace: string, enabled = true) {
|
|
24
|
-
return
|
|
25
|
-
queryKey: ['limitranges', namespace],
|
|
26
|
-
queryFn: () => fetchJSON<any[]>(`/resources/limitranges?namespace=${encodeURIComponent(namespace)}`),
|
|
27
|
-
enabled: enabled && !!namespace,
|
|
28
|
-
staleTime: 15000,
|
|
29
|
-
})
|
|
18
|
+
return useResources<any>('limitranges', namespace, undefined, { enabled: enabled && !!namespace })
|
|
30
19
|
}
|
|
31
20
|
|
|
32
21
|
export function podLimitRangeNames(limitRanges: any[] | undefined): string[] {
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface RadarFeatureSpec {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const RADAR_FEATURES = {
|
|
30
|
+
resourceReadCoverage: { label: 'Resource read coverage', flag: 'resourceReadCoverage', flagShippedWithEndpoint: true },
|
|
31
|
+
searchCoverage: { label: 'Search coverage and object filters', flag: 'searchCoverage', flagShippedWithEndpoint: true },
|
|
30
32
|
resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
|
|
31
33
|
resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
|
|
32
34
|
podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import type { ResourceReadCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
|
|
3
|
+
import { combinedListStatus, createListRefetchInterval, listSyncPending, normalizeResourceList } from './resourceLists'
|
|
4
|
+
|
|
5
|
+
const complete: ResourceReadCoverage = { status: 'complete', gaps: [], scope: { type: 'cluster' }, read: { type: 'cluster' } }
|
|
6
|
+
const partial: ResourceReadCoverage = { ...complete, status: 'partial', gaps: [{ code: 'radar_namespace_not_collected' }] }
|
|
7
|
+
const columns = [{ name: 'State', type: 'string' }]
|
|
8
|
+
|
|
9
|
+
describe('resource-list responses, read by shape', () => {
|
|
10
|
+
it('reads an older Radar array as rows of unknown coverage', () => {
|
|
11
|
+
const rows = [{ metadata: { name: 'api' } }]
|
|
12
|
+
expect(normalizeResourceList(rows)).toEqual({ items: rows, coverage: { status: 'unknown' }, printerTable: null })
|
|
13
|
+
expect(normalizeResourceList([]).coverage).toEqual({ status: 'unknown' })
|
|
14
|
+
})
|
|
15
|
+
it('reads an older Radar table envelope as a printer table of unknown coverage', () => {
|
|
16
|
+
const body = { items: [{ metadata: { uid: 'one' } }], kind: 'widgets', group: 'example.io', columns, cells: { one: ['Ready'] } }
|
|
17
|
+
const result = normalizeResourceList(body)
|
|
18
|
+
expect(result.items).toEqual(body.items)
|
|
19
|
+
expect(result.coverage).toEqual({ status: 'unknown' })
|
|
20
|
+
expect(result.printerTable?.cells).toEqual(body.cells)
|
|
21
|
+
})
|
|
22
|
+
it('reads the coverage envelope without a table, retaining partial metadata with zero rows', () => {
|
|
23
|
+
expect(normalizeResourceList({ items: [], coverage: partial, kind: 'pods', columns: null, cells: null })).toEqual({ items: [], coverage: partial, printerTable: null })
|
|
24
|
+
})
|
|
25
|
+
it('reads the coverage envelope with a table, keeping rows and cells from the same response', () => {
|
|
26
|
+
const body = { items: [{ metadata: { uid: 'one' } }], kind: 'widgets', group: 'example.io', columns, cells: { one: ['Ready'] }, coverage: complete }
|
|
27
|
+
const result = normalizeResourceList(body)
|
|
28
|
+
expect(result.items).toEqual(body.items)
|
|
29
|
+
expect(result.coverage).toEqual(complete)
|
|
30
|
+
expect(result.printerTable?.cells).toEqual(body.cells)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('listSyncPending', () => {
|
|
35
|
+
it('holds only while a partial answer has namespaces still loading', () => {
|
|
36
|
+
expect(listSyncPending({ ...partial, gaps: [{ code: 'radar_forbidden' }, { code: 'kind_sync_pending' }] })).toBe(true)
|
|
37
|
+
expect(listSyncPending(partial)).toBe(false)
|
|
38
|
+
expect(listSyncPending(complete)).toBe(false)
|
|
39
|
+
expect(listSyncPending({ status: 'unknown' })).toBe(false)
|
|
40
|
+
expect(listSyncPending(undefined)).toBe(false)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
describe('combinedListStatus', () => {
|
|
45
|
+
it('is partial when any read failed or was partial', () => {
|
|
46
|
+
expect(combinedListStatus([complete], true, false)).toBe('partial')
|
|
47
|
+
expect(combinedListStatus([complete, partial], false, false)).toBe('partial')
|
|
48
|
+
})
|
|
49
|
+
it("is partial when Radar's collection narrowed a read, since the view shows cluster totals", () => {
|
|
50
|
+
const narrowed = { ...complete, narrowedBy: ['namespace_collection'] }
|
|
51
|
+
expect(combinedListStatus([complete, narrowed], false, false)).toBe('partial')
|
|
52
|
+
expect(combinedListStatus([{ ...complete, narrowedBy: ['user_access'] }], false, false)).toBe('complete')
|
|
53
|
+
})
|
|
54
|
+
it('is complete only when every read was', () => {
|
|
55
|
+
expect(combinedListStatus([complete, complete], false, false)).toBe('complete')
|
|
56
|
+
expect(combinedListStatus([complete, { status: 'unknown' }], false, false)).toBe('unknown')
|
|
57
|
+
})
|
|
58
|
+
it('treats discovery finding nothing to read as complete, and no reads otherwise as unknown', () => {
|
|
59
|
+
expect(combinedListStatus([], false, true)).toBe('complete')
|
|
60
|
+
expect(combinedListStatus([], false, false)).toBe('unknown')
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
describe('loading list backoff', () => {
|
|
65
|
+
it('backs off per response, caps, and resets for coverage or query changes', () => {
|
|
66
|
+
const interval = createListRefetchInterval(120000)
|
|
67
|
+
const pending = { ...partial, gaps: [{ code: 'kind_sync_pending' }] }
|
|
68
|
+
const query = { state: { data: { coverage: pending }, dataUpdateCount: 1 } }
|
|
69
|
+
for (const delay of [5000, 10000, 20000, 30000, 30000]) {
|
|
70
|
+
expect(interval(query)).toBe(delay)
|
|
71
|
+
expect(interval(query)).toBe(delay)
|
|
72
|
+
query.state.dataUpdateCount++
|
|
73
|
+
}
|
|
74
|
+
query.state.data.coverage = complete
|
|
75
|
+
expect(interval(query)).toBe(120000)
|
|
76
|
+
query.state.data.coverage = pending
|
|
77
|
+
expect(interval(query)).toBe(5000)
|
|
78
|
+
query.state.dataUpdateCount++
|
|
79
|
+
expect(interval(query)).toBe(10000)
|
|
80
|
+
const other = { state: { ...query.state } }
|
|
81
|
+
expect(interval(other)).toBe(5000)
|
|
82
|
+
expect(interval(query)).toBe(5000)
|
|
83
|
+
})
|
|
84
|
+
})
|