@skyhook-io/radar-app 1.22.2 → 1.23.1
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/package.json +8 -8
- package/src/App.tsx +49 -13
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +151 -27
- package/src/api/client.updateResource.secretExpiry.test.tsx +47 -0
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/poll.ts +78 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +16 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +315 -0
- package/src/api/workloadSource.ts +128 -12
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +128 -32
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/helm/HelmDrawerRouting.test.tsx +34 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -4
- package/src/components/helm/HelmView.tsx +4 -3
- package/src/components/helm/ObservedHelmNotice.tsx +39 -17
- package/src/components/helm/ObservedHelmRelease.test.tsx +62 -3
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +18 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +4 -2
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/issues/uncheckedSources.test.ts +8 -0
- package/src/components/issues/uncheckedSources.ts +3 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/nudges/activeNudges.test.ts +39 -0
- package/src/components/nudges/activeNudges.ts +76 -0
- package/src/components/poll/OssPoll.tsx +871 -0
- package/src/components/poll/mount.test.ts +12 -0
- package/src/components/poll/pollCloud.test.ts +23 -0
- package/src/components/poll/pollCloud.ts +6 -0
- package/src/components/poll/pollDefinition.ts +93 -0
- package/src/components/poll/pollFlow.test.ts +140 -0
- package/src/components/poll/pollFlow.ts +137 -0
- package/src/components/poll/pollSender.test.ts +137 -0
- package/src/components/poll/pollSender.ts +76 -0
- package/src/components/poll/pollStorage.test.ts +53 -0
- package/src/components/poll/pollStorage.ts +77 -0
- package/src/components/poll/round.json +350 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +2 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ImageFilesystemModal.test.tsx +21 -1
- package/src/components/resources/ImageFilesystemModal.tsx +42 -3
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +24 -11
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/ui/UpdateNotification.tsx +2 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +2 -0
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/whats-new/WhatsNew.tsx +2 -0
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +52 -13
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
import { Link, useNavigate, useSearchParams } from "react-router-dom";
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { Link, useLocation, useNavigate, useSearchParams } from "react-router-dom";
|
|
3
3
|
import { useApplications, useIssues, useSubjectIssues, type SubjectIssuesResponse } from "../../api/client";
|
|
4
4
|
import {
|
|
5
5
|
useAPIResources,
|
|
@@ -9,6 +9,7 @@ import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
|
|
|
9
9
|
import { useConnection } from "../../context/ConnectionContext";
|
|
10
10
|
import type { SelectedResource } from "../../types";
|
|
11
11
|
import {
|
|
12
|
+
Badge,
|
|
12
13
|
EmptyState,
|
|
13
14
|
IssuesView,
|
|
14
15
|
PaneLoader,
|
|
@@ -20,17 +21,43 @@ import {
|
|
|
20
21
|
type Issue,
|
|
21
22
|
type IssueResourceRef,
|
|
22
23
|
type IssueSeverity,
|
|
24
|
+
type SchedulingBlockerSummary,
|
|
23
25
|
type SummaryTone,
|
|
26
|
+
formatRelativeAgeTime,
|
|
24
27
|
} from "@skyhook-io/k8s-ui";
|
|
28
|
+
import { Tooltip } from "../ui/Tooltip";
|
|
25
29
|
import { buildIssueAppIndex } from "@skyhook-io/k8s-ui/components/issues";
|
|
30
|
+
import { gapReasonText } from "@skyhook-io/k8s-ui/utils/read-actions";
|
|
26
31
|
import { builtinGroupForKind } from "@skyhook-io/k8s-ui/utils/api-resources";
|
|
27
32
|
import { AlertTriangle } from "lucide-react";
|
|
28
33
|
import { IssueDiagnoseButton } from "../diagnose/LocalDiagnoseAction";
|
|
34
|
+
import { SharedInstallAiLine } from "../cloudHints/SharedInstallAiLine";
|
|
35
|
+
import { useDiagnose } from "../diagnose/DiagnoseContext";
|
|
36
|
+
import { useCloudHintsEnabled } from "../cloudHints/cloudHints";
|
|
29
37
|
import { recordUsageEvent } from "../../api/usage-data";
|
|
30
38
|
import { uncheckedSourceLines, uncheckedSubjectWhy } from "./uncheckedSources";
|
|
31
39
|
import { UncheckedSourceHelp } from "./UncheckedSourceHelp";
|
|
32
40
|
import { useClearLinkedIssue } from "../../utils/page-links";
|
|
33
41
|
import { useIssueExpansion, useIssueRowNotes } from "./useIssueExpansion";
|
|
42
|
+
import {
|
|
43
|
+
advanceVisit,
|
|
44
|
+
formatVisitTime,
|
|
45
|
+
lastLookAt,
|
|
46
|
+
noteListed,
|
|
47
|
+
sinceRowShowsCloudLine,
|
|
48
|
+
startedSince,
|
|
49
|
+
turnSinceRowOff,
|
|
50
|
+
cloudSentenceAllowed,
|
|
51
|
+
noteCloudSentence,
|
|
52
|
+
updateVisit,
|
|
53
|
+
useSinceLastVisit,
|
|
54
|
+
useTrackVisit,
|
|
55
|
+
visibilityKey,
|
|
56
|
+
} from "./sinceLastVisit";
|
|
57
|
+
import { ClusterSchedulingBlockerRow } from "./ClusterSchedulingBlockerRow";
|
|
58
|
+
import { SinceLastVisitRow } from "./SinceLastVisitRow";
|
|
59
|
+
import { ShareLinkButton } from "../share/ShareLinkButton";
|
|
60
|
+
import { issueSharePath } from "../share/shareLink";
|
|
34
61
|
|
|
35
62
|
// A capacity-relevant issue links to its Karpenter diagnosis. Karpenter is
|
|
36
63
|
// always single-cluster (unlike Argo hub-and-spoke), so the issue and the
|
|
@@ -173,6 +200,8 @@ interface IssuesPaneProps {
|
|
|
173
200
|
showNamespace?: { mode: "add" | "switch"; show: (namespace: string) => void };
|
|
174
201
|
}
|
|
175
202
|
|
|
203
|
+
const NO_BLOCKERS: readonly SchedulingBlockerSummary[] = [];
|
|
204
|
+
|
|
176
205
|
// The per-cluster Issues surface. Renders the same shared triage queue
|
|
177
206
|
// (IssuesView) the Hub fleet view uses — single cluster here, so no cluster
|
|
178
207
|
// label and in-app (client-side) resource navigation. Classification +
|
|
@@ -190,8 +219,10 @@ export function IssuesPane({
|
|
|
190
219
|
const clearLinkedIssue = useClearLinkedIssue();
|
|
191
220
|
const linkedIssueId = searchParams.get("issue") || undefined;
|
|
192
221
|
const subject = useMemo(() => issueSubjectFromParams(searchParams), [searchParams]);
|
|
222
|
+
// A subjectless issue link addresses a workload issue ID the blocker view may have folded.
|
|
223
|
+
const view = linkedIssueId ? undefined : "blockers";
|
|
193
224
|
const { data, isLoading, isFetching, error, dataUpdatedAt, refetch } =
|
|
194
|
-
useIssues(namespaces, !subject);
|
|
225
|
+
useIssues(namespaces, !subject, undefined, view);
|
|
195
226
|
const canGroup = !subject && (data?.issues.length ?? 0) > 1;
|
|
196
227
|
const { data: inventory } = useApplications(namespaces, { enabled: canGroup });
|
|
197
228
|
const appForIssue = useMemo(() => canGroup && inventory
|
|
@@ -199,6 +230,13 @@ export function IssuesPane({
|
|
|
199
230
|
: undefined, [canGroup, inventory, namespaces.length]);
|
|
200
231
|
const { connection } = useConnection();
|
|
201
232
|
const navigate = useNavigate();
|
|
233
|
+
const location = useLocation();
|
|
234
|
+
const cloudHints = useCloudHintsEnabled();
|
|
235
|
+
const diagnose = useDiagnose();
|
|
236
|
+
const sharedInstallAi =
|
|
237
|
+
cloudHints &&
|
|
238
|
+
diagnose.setupState === "off" &&
|
|
239
|
+
diagnose.unavailableReason === "shared";
|
|
202
240
|
const apiResources = useAPIResources();
|
|
203
241
|
const hasKarpenter = karpenterCapacityAvailable(
|
|
204
242
|
useCapabilitiesContext().karpenter,
|
|
@@ -231,16 +269,77 @@ export function IssuesPane({
|
|
|
231
269
|
? subjectHidden ? undefined : related.data?.visibility
|
|
232
270
|
: data?.visibility;
|
|
233
271
|
const pageIssues = useMemo(() => data?.issues ?? [], [data]);
|
|
272
|
+
const blockers = subject ? NO_BLOCKERS : data?.scheduling_blockers ?? NO_BLOCKERS;
|
|
273
|
+
const pageRowCount = pageIssues.length + blockers.length;
|
|
274
|
+
const capped = data?.total_matched != null && data.total_matched > pageRowCount;
|
|
275
|
+
const singleNamespace = namespaces.length === 1 ? namespaces[0] : undefined;
|
|
276
|
+
const visitRows = useMemo(() => [...pageIssues, ...blockers.map(blocker => ({
|
|
277
|
+
id: blocker.id,
|
|
278
|
+
first_seen: blocker.first_seen,
|
|
279
|
+
namespace: singleNamespace,
|
|
280
|
+
}))], [pageIssues, blockers, singleNamespace]);
|
|
281
|
+
|
|
282
|
+
// Issues that started since this person last looked at this list. Counted
|
|
283
|
+
// from the list this page shows, so the namespace filter and the caller's
|
|
284
|
+
// RBAC already apply.
|
|
285
|
+
const since = useSinceLastVisit();
|
|
286
|
+
useTrackVisit(subject ? null : since.key);
|
|
287
|
+
// Each refresh the person is shown counts as a look at this list; one that
|
|
288
|
+
// lands in a hidden tab counts once the tab is back.
|
|
289
|
+
const namespaceKey = namespaces.join(",");
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (!since.key || subject || !data || document.visibilityState !== "visible") return;
|
|
292
|
+
const complete =
|
|
293
|
+
!capped &&
|
|
294
|
+
!(data.unchecked_sources?.length);
|
|
295
|
+
const listed = { namespaces: namespaceKey ? namespaceKey.split(",") : [], complete, visibility: visibilityKey(data.visibility) };
|
|
296
|
+
const ids = visitRows.map((i) => i.id);
|
|
297
|
+
const now = Date.now();
|
|
298
|
+
updateVisit(since.key, (r) => noteListed(advanceVisit(r, now), ids, Math.min(dataUpdatedAt || now, now), listed));
|
|
299
|
+
// dataUpdatedAt too: an unchanged refresh keeps the same data object.
|
|
300
|
+
// since.now moves when the tab comes back into view.
|
|
301
|
+
}, [since.key, subject, data, dataUpdatedAt, namespaceKey, since.now, capped, visitRows]);
|
|
302
|
+
const anchor = subject ? undefined : since.record?.anchor;
|
|
303
|
+
const previouslyListed = since.record?.prev;
|
|
304
|
+
const previousCover = since.record?.prevCover;
|
|
305
|
+
const currentVisibility = visibilityKey(data?.visibility);
|
|
306
|
+
const newIds = useMemo(() => {
|
|
307
|
+
if (anchor === undefined) return new Set<string>();
|
|
308
|
+
const last = { listed: new Set(previouslyListed ?? []), cover: previousCover, visibility: currentVisibility };
|
|
309
|
+
return new Set(visitRows.filter((i) => startedSince(i, last)).map((i) => i.id));
|
|
310
|
+
}, [anchor, previouslyListed, previousCover, currentVisibility, visitRows]);
|
|
311
|
+
// The row's time holds for every issue it counts: the earliest of their last looks.
|
|
312
|
+
const lookedAt = (issue: Pick<Issue, "namespace">) => lastLookAt(issue, previousCover, currentVisibility);
|
|
313
|
+
const rowLookAt = Math.min(...visitRows.filter((i) => newIds.has(i.id)).map((i) => lookedAt(i) ?? Infinity));
|
|
314
|
+
const lastVisit = Number.isFinite(rowLookAt) ? formatVisitTime(rowLookAt, since.now) : "";
|
|
315
|
+
const sinceRowVisible =
|
|
316
|
+
anchor !== undefined && newIds.size > 0 && !since.turnedOff && since.record?.closedAnchor !== anchor;
|
|
317
|
+
// At most one Radar Cloud line on this page: while this row shows its
|
|
318
|
+
// sentence, the shared-install AI line waits.
|
|
319
|
+
const cloudLine =
|
|
320
|
+
sinceRowShowsCloudLine({ rowVisible: sinceRowVisible, cloudEnabled: cloudHints }) &&
|
|
321
|
+
anchor !== undefined &&
|
|
322
|
+
cloudSentenceAllowed(since.user, anchor);
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
if (cloudLine && anchor !== undefined) noteCloudSentence(since.user, anchor);
|
|
325
|
+
}, [cloudLine, anchor, since.user]);
|
|
326
|
+
const [onlyNew, setOnlyNew] = useState(false);
|
|
327
|
+
// The filter lives in the row: once the row is gone, so is the filter.
|
|
328
|
+
const filterNew = onlyNew && sinceRowVisible;
|
|
234
329
|
const uncheckedLines = subject ? [] : uncheckedSourceLines(data?.unchecked_sources);
|
|
235
330
|
// With a subject set, the tiles and the list both describe the subject.
|
|
236
331
|
const scopeIssues = subjectState
|
|
237
332
|
? subjectState.state === "found" ? subjectState.issues : []
|
|
238
333
|
: pageIssues;
|
|
334
|
+
const issueCount = scopeIssues.length + blockers.length;
|
|
239
335
|
const totals: Record<IssueSeverity, number> = { critical: 0, warning: 0 };
|
|
240
336
|
for (const i of scopeIssues) totals[i.severity] = (totals[i.severity] ?? 0) + 1;
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
337
|
+
for (const blocker of blockers) totals[blocker.severity]++;
|
|
338
|
+
const matchesFilters = (i: { severity: IssueSeverity; id: string }) =>
|
|
339
|
+
(!severityFilter.size || severityFilter.has(i.severity)) && (!filterNew || newIds.has(i.id));
|
|
340
|
+
const shown = scopeIssues.filter(matchesFilters);
|
|
341
|
+
const shownBlockers = blockers.filter(matchesFilters);
|
|
342
|
+
const shownCount = shown.length + shownBlockers.length;
|
|
244
343
|
const clearSubject = () =>
|
|
245
344
|
setSearchParams(
|
|
246
345
|
(prev) => {
|
|
@@ -303,11 +402,11 @@ export function IssuesPane({
|
|
|
303
402
|
}}
|
|
304
403
|
connectionState={connection.state}
|
|
305
404
|
/>}
|
|
306
|
-
{
|
|
405
|
+
{issueCount > 0 && (
|
|
307
406
|
<>
|
|
308
407
|
<SummaryTile
|
|
309
|
-
label={
|
|
310
|
-
value={
|
|
408
|
+
label={issueCount === 1 ? "issue" : "issues"}
|
|
409
|
+
value={issueCount}
|
|
311
410
|
/>
|
|
312
411
|
{ISSUE_SEVERITIES.map((s) =>
|
|
313
412
|
totals[s] > 0 || severityFilter.has(s) ? (
|
|
@@ -327,6 +426,29 @@ export function IssuesPane({
|
|
|
327
426
|
}
|
|
328
427
|
/>
|
|
329
428
|
|
|
429
|
+
{sinceRowVisible && anchor !== undefined && (
|
|
430
|
+
<SinceLastVisitRow
|
|
431
|
+
count={newIds.size}
|
|
432
|
+
atLeast={capped}
|
|
433
|
+
lastVisit={lastVisit}
|
|
434
|
+
showingOnlyNew={filterNew}
|
|
435
|
+
onToggleOnlyNew={() => {
|
|
436
|
+
clearLinkedIssue();
|
|
437
|
+
setOnlyNew(!filterNew);
|
|
438
|
+
}}
|
|
439
|
+
cloud={cloudLine}
|
|
440
|
+
onClose={() => {
|
|
441
|
+
setOnlyNew(false);
|
|
442
|
+
if (since.key) updateVisit(since.key, (r) => ({ ...advanceVisit(r, Date.now()), closedAnchor: anchor }));
|
|
443
|
+
}}
|
|
444
|
+
onTurnOff={() => {
|
|
445
|
+
setOnlyNew(false);
|
|
446
|
+
turnSinceRowOff(since.user);
|
|
447
|
+
}}
|
|
448
|
+
/>
|
|
449
|
+
)}
|
|
450
|
+
{sharedInstallAi && !cloudLine && <SharedInstallAiLine />}
|
|
451
|
+
|
|
330
452
|
{!subject && linkedIssueId && data && !pageIssues.some((issue) => issue.id === linkedIssueId) && (
|
|
331
453
|
<p className="text-sm text-theme-text-secondary">The linked issue is outside the current results.</p>
|
|
332
454
|
)}
|
|
@@ -354,7 +476,7 @@ export function IssuesPane({
|
|
|
354
476
|
{/* Unchecked-source honesty: the rows can't include issues from a
|
|
355
477
|
source Radar couldn't check. With no rows the empty state below says
|
|
356
478
|
it instead. */}
|
|
357
|
-
{
|
|
479
|
+
{issueCount > 0 && uncheckedLines.length > 0 && (
|
|
358
480
|
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
|
|
359
481
|
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-500" />
|
|
360
482
|
<div className="min-w-0 flex-1">
|
|
@@ -366,13 +488,17 @@ export function IssuesPane({
|
|
|
366
488
|
|
|
367
489
|
{/* Truncation honesty: when more issues matched than were returned, say
|
|
368
490
|
so — don't present a capped list as the complete picture. */}
|
|
369
|
-
{!subject && data?.
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
491
|
+
{!subject && data?.scheduling_node_gap && (
|
|
492
|
+
<p className="text-xs text-theme-text-secondary">
|
|
493
|
+
Node inventory unavailable ({gapReasonText(data.scheduling_node_gap)}). Scheduling issues are shown by workload.
|
|
494
|
+
</p>
|
|
495
|
+
)}
|
|
496
|
+
{!subject && capped && (
|
|
497
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
498
|
+
Showing {pageRowCount} of {data?.total_matched} issues
|
|
499
|
+
(capped) — narrow by namespace to see the rest.
|
|
500
|
+
</p>
|
|
501
|
+
)}
|
|
376
502
|
|
|
377
503
|
{subject && subjectState && (
|
|
378
504
|
<div className="flex flex-wrap items-center gap-2 text-xs text-theme-text-secondary">
|
|
@@ -421,18 +547,18 @@ export function IssuesPane({
|
|
|
421
547
|
{/* Filtered-empty is NOT the healthy empty state: when a severity filter
|
|
422
548
|
hides every row but issues still exist, say "no matches" rather than
|
|
423
549
|
letting IssuesView render its "nothing broken" terminal state. */}
|
|
424
|
-
{subject &&
|
|
550
|
+
{subject && issueCount === 0 ? null : (severityFilter.size > 0 || filterNew) && issueCount > 0 && shownCount === 0 ? (
|
|
425
551
|
<div className="flex flex-col items-center gap-2 py-12 text-center text-sm text-theme-text-secondary">
|
|
426
|
-
<p>No issues match the selected severity
|
|
552
|
+
<p>{filterNew ? "No issue that started since your last visit has the selected severity." : "No issues match the selected severity."}</p>
|
|
427
553
|
<button
|
|
428
554
|
type="button"
|
|
429
|
-
onClick={() => { clearLinkedIssue(); setSeverityFilter(new Set()); }}
|
|
555
|
+
onClick={() => { clearLinkedIssue(); setSeverityFilter(new Set()); setOnlyNew(false); }}
|
|
430
556
|
className="text-xs text-skyhook-600 hover:text-skyhook-500 dark:text-skyhook-400"
|
|
431
557
|
>
|
|
432
558
|
Clear filter
|
|
433
559
|
</button>
|
|
434
560
|
</div>
|
|
435
|
-
) : uncheckedLines.length > 0 &&
|
|
561
|
+
) : uncheckedLines.length > 0 && issueCount === 0 ? (
|
|
436
562
|
<EmptyState
|
|
437
563
|
tone="neutral"
|
|
438
564
|
variant="card"
|
|
@@ -440,7 +566,7 @@ export function IssuesPane({
|
|
|
440
566
|
body={uncheckedLines.join(" ")}
|
|
441
567
|
action={<UncheckedSourceHelp onRetry={() => { void refetch({ cancelRefetch: false }); }} isRefreshing={isFetching} />}
|
|
442
568
|
/>
|
|
443
|
-
) : !subject && error &&
|
|
569
|
+
) : !subject && error && issueCount === 0 ? (
|
|
444
570
|
<EmptyState
|
|
445
571
|
tone="neutral"
|
|
446
572
|
variant="card"
|
|
@@ -452,6 +578,19 @@ export function IssuesPane({
|
|
|
452
578
|
list then means "nothing broken" rather than "not connected". */
|
|
453
579
|
<IssuesView
|
|
454
580
|
issues={shown}
|
|
581
|
+
blockerRows={shownBlockers.map((blocker) => ({
|
|
582
|
+
id: blocker.id,
|
|
583
|
+
severity: blocker.severity,
|
|
584
|
+
content: (
|
|
585
|
+
<ClusterSchedulingBlockerRow
|
|
586
|
+
key={`${connection.connectionId ?? connection.context ?? ""}:${namespaceKey}`}
|
|
587
|
+
blocker={blocker}
|
|
588
|
+
namespaces={namespaces}
|
|
589
|
+
onResourceClick={onResourceClick}
|
|
590
|
+
isNew={newIds.has(blocker.id)}
|
|
591
|
+
/>
|
|
592
|
+
),
|
|
593
|
+
}))}
|
|
455
594
|
appForIssue={appForIssue}
|
|
456
595
|
renderAppLink={(key, label) => {
|
|
457
596
|
const params = new URLSearchParams({ app: key });
|
|
@@ -466,11 +605,30 @@ export function IssuesPane({
|
|
|
466
605
|
expandedIssue={expansion.expandedIssue}
|
|
467
606
|
timelineLinks={expansion.timelineLinks}
|
|
468
607
|
rowChanges={rowNotes.rowChanges}
|
|
608
|
+
renderBadges={({ issue }) =>
|
|
609
|
+
newIds.has(issue.id) ? (
|
|
610
|
+
<Tooltip
|
|
611
|
+
content={`Started ${formatRelativeAgeTime(issue.first_seen)}, after you last checked (${formatVisitTime(lookedAt(issue) ?? 0, since.now)})`}
|
|
612
|
+
delay={200}
|
|
613
|
+
wrapperClassName="shrink-0 self-center"
|
|
614
|
+
>
|
|
615
|
+
<Badge tone="note" size="sm">New</Badge>
|
|
616
|
+
</Tooltip>
|
|
617
|
+
) : null
|
|
618
|
+
}
|
|
469
619
|
onVisibleIssuesChange={rowNotes.onVisibleIssuesChange}
|
|
470
|
-
renderActions={({ issue }) => {
|
|
620
|
+
renderActions={({ issue, open }) => {
|
|
471
621
|
const capacityHref = capacityHrefForIssue(issue, hasKarpenter);
|
|
472
622
|
return (
|
|
473
623
|
<div className="flex items-center gap-2">
|
|
624
|
+
{/* Only on the open issue: a link icon on every row would be noise. */}
|
|
625
|
+
{open && issue.id && (
|
|
626
|
+
<ShareLinkButton
|
|
627
|
+
path={issueSharePath(issue.id, location, issue)}
|
|
628
|
+
subject={{ kind: issue.kind, group: issue.group, namespace: issue.namespace, name: issue.name }}
|
|
629
|
+
size="sm"
|
|
630
|
+
/>
|
|
631
|
+
)}
|
|
474
632
|
{capacityHref && (
|
|
475
633
|
<button
|
|
476
634
|
type="button"
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
6
|
+
import type { IssuesResponse } from '../../api/client'
|
|
7
|
+
import { getApiBase } from '../../api/config'
|
|
8
|
+
import { IssuesPane } from './IssuesPane'
|
|
9
|
+
import { ONSET_MARGIN_MS, hashId, readVisit, resetVisitMemory, sinceRowTurnedOff, updateVisit } from './sinceLastVisit'
|
|
10
|
+
|
|
11
|
+
const state = vi.hoisted(() => ({
|
|
12
|
+
issues: { data: undefined as IssuesResponse | undefined, isLoading: false, isFetching: false, error: null, dataUpdatedAt: 0, refetch: () => {} },
|
|
13
|
+
useIssues: vi.fn(),
|
|
14
|
+
cloudConnect: true as boolean,
|
|
15
|
+
embedded: false,
|
|
16
|
+
openCloudFunnel: vi.fn(),
|
|
17
|
+
version: '1.22.1' as string | undefined,
|
|
18
|
+
aiSetup: 'ready' as 'ready' | 'off',
|
|
19
|
+
authFailed: false,
|
|
20
|
+
}))
|
|
21
|
+
vi.mock('../../api/client', () => ({
|
|
22
|
+
useApplications: () => ({}),
|
|
23
|
+
useIssues: (...args: unknown[]) => { state.useIssues(...args); return state.issues },
|
|
24
|
+
useSubjectIssues: () => ({ data: undefined, isLoading: false, error: null, dataUpdatedAt: 0, refetch: () => {} }),
|
|
25
|
+
useIssueCorrelation: () => ({ data: undefined, error: null, isFetching: false, dataUpdatedAt: 0, refetch: () => {} }),
|
|
26
|
+
useIssueRowChanges: () => undefined,
|
|
27
|
+
useCapabilities: () => ({ data: state.cloudConnect ? { cloudConnect: { lane: 'wizard' } } : {} }),
|
|
28
|
+
useAuthMe: () => (state.authFailed
|
|
29
|
+
? { isPending: false, isError: true, data: undefined }
|
|
30
|
+
: { isPending: false, data: { authEnabled: true, username: 'ana' } }),
|
|
31
|
+
useClusterInfo: () => ({ data: { context: 'kind-a' } }),
|
|
32
|
+
useRadarVersion: () => state.version,
|
|
33
|
+
}))
|
|
34
|
+
vi.mock('../../context/NavCustomization', () => ({ useNavCustomization: () => ({ embedded: state.embedded }) }))
|
|
35
|
+
vi.mock('../cloudHints/cloudHints', async (importOriginal) => ({
|
|
36
|
+
...(await importOriginal<typeof import('../cloudHints/cloudHints')>()),
|
|
37
|
+
openCloudFunnel: state.openCloudFunnel,
|
|
38
|
+
}))
|
|
39
|
+
vi.mock('../diagnose/DiagnoseContext', () => ({ useDiagnose: () => ({ setupState: state.aiSetup, unavailableReason: 'shared' }) }))
|
|
40
|
+
vi.mock('../../api/apiResources', () => ({ useAPIResources: () => ({ data: undefined }), karpenterCapacityAvailable: () => false }))
|
|
41
|
+
vi.mock('../../contexts/CapabilitiesContext', () => ({ useCapabilitiesContext: () => ({}) }))
|
|
42
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
43
|
+
vi.mock('../diagnose/LocalDiagnoseAction', () => ({ IssueDiagnoseButton: () => null }))
|
|
44
|
+
|
|
45
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
46
|
+
|
|
47
|
+
const key = () => JSON.stringify([getApiBase(), 'kind-a', 'ana', state.version])
|
|
48
|
+
const anchor = Date.now() - 3 * 3600_000
|
|
49
|
+
const after = new Date(anchor + ONSET_MARGIN_MS + 3600_000).toISOString()
|
|
50
|
+
const before = new Date(anchor - 3600_000).toISOString()
|
|
51
|
+
|
|
52
|
+
function issue(id: string, extra: Record<string, unknown>) {
|
|
53
|
+
return {
|
|
54
|
+
id, severity: 'critical' as const, source: 'problem', category: 'workload', category_group: 'workload', grouping_scope: 'resource',
|
|
55
|
+
kind: 'Pod', group: '', namespace: 'db', name: id, reason: 'CrashLoopBackOff', message: `${id} keeps crashing`, ...extra,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fresh = [issue('new-a', { first_seen: after }), issue('new-b', { first_seen: after, severity: 'warning' })]
|
|
60
|
+
const notNew = [
|
|
61
|
+
issue('unknown', { onset_unknown: true }),
|
|
62
|
+
issue('partial', { first_seen: after, onset_coverage: { known: 1, unknown: 1 } }),
|
|
63
|
+
issue('older', { first_seen: before }),
|
|
64
|
+
issue('listed-before', { first_seen: after }),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
let root: Root
|
|
68
|
+
let container: HTMLDivElement
|
|
69
|
+
|
|
70
|
+
async function render(url = '/issues', namespaces: string[] = []) {
|
|
71
|
+
container = document.createElement('div')
|
|
72
|
+
document.body.append(container)
|
|
73
|
+
root = createRoot(container)
|
|
74
|
+
await act(async () => {
|
|
75
|
+
root.render(<MemoryRouter initialEntries={[url]}><IssuesPane namespaces={namespaces} onNavigateToResource={() => {}} /></MemoryRouter>)
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const row = () => container.querySelector('[aria-label="Issues since your last visit"]')
|
|
80
|
+
const rowIds = () => [...container.querySelectorAll('[data-app-issue-row]')].map((el) => el.getAttribute('data-app-issue-row')!.replace(/^:/, ''))
|
|
81
|
+
const newBadges = () => [...container.querySelectorAll('[data-app-issue-row]')].filter((el) => [...el.querySelectorAll('span')].some((s) => s.textContent === 'New')).map((el) => el.getAttribute('data-app-issue-row')!.replace(/^:/, ''))
|
|
82
|
+
const button = (text: string) => [...container.querySelectorAll('button')].find((b) => b.textContent === text)
|
|
83
|
+
|
|
84
|
+
beforeEach(() => {
|
|
85
|
+
window.localStorage.clear()
|
|
86
|
+
resetVisitMemory()
|
|
87
|
+
state.issues = { ...state.issues, data: { issues: [...fresh, ...notNew] }, error: null, dataUpdatedAt: 0 }
|
|
88
|
+
state.useIssues.mockClear()
|
|
89
|
+
state.openCloudFunnel.mockClear()
|
|
90
|
+
state.cloudConnect = true
|
|
91
|
+
state.embedded = false
|
|
92
|
+
state.version = '1.22.1'
|
|
93
|
+
state.aiSetup = 'ready'
|
|
94
|
+
state.authFailed = false
|
|
95
|
+
updateVisit(key(), () => ({ lastActiveAt: Date.now(), anchor, prev: [hashId('listed-before')], prevCover: { allAt: anchor } }))
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
afterEach(async () => {
|
|
99
|
+
await act(async () => root.unmount())
|
|
100
|
+
container.remove()
|
|
101
|
+
vi.restoreAllMocks()
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
describe('issues started since the last visit', () => {
|
|
105
|
+
it('counts only issues whose known onset is after the last visit and marks their rows', async () => {
|
|
106
|
+
await render()
|
|
107
|
+
expect(row()?.textContent).toContain('2 issues started since you last checked')
|
|
108
|
+
expect(newBadges().sort()).toEqual(['new-a', 'new-b'])
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('shows nothing on a first visit', async () => {
|
|
112
|
+
window.localStorage.clear()
|
|
113
|
+
resetVisitMemory()
|
|
114
|
+
await render()
|
|
115
|
+
expect(row()).toBeNull()
|
|
116
|
+
expect(newBadges()).toEqual([])
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('shows nothing when no issue is known to be new', async () => {
|
|
120
|
+
state.issues = { ...state.issues, data: { issues: notNew } }
|
|
121
|
+
await render()
|
|
122
|
+
expect(row()).toBeNull()
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('counts from the list the page shows, which carries the namespace filter and RBAC', async () => {
|
|
126
|
+
// The server answers only what this person may see in these namespaces;
|
|
127
|
+
// an issue it withholds can't be counted.
|
|
128
|
+
state.issues = { ...state.issues, data: { issues: [fresh[0], ...notNew] } }
|
|
129
|
+
await render('/issues', ['db'])
|
|
130
|
+
expect(state.useIssues).toHaveBeenCalledWith(['db'], true, undefined, 'blockers')
|
|
131
|
+
expect(row()?.textContent).toContain('1 issue started since')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('counts only namespaces the last list covered', async () => {
|
|
135
|
+
updateVisit(key(), (r) => ({ ...r!, prevCover: { nsAt: { web: anchor } } }))
|
|
136
|
+
await render()
|
|
137
|
+
expect(row()).toBeNull()
|
|
138
|
+
updateVisit(key(), (r) => ({ ...r!, prevCover: { nsAt: { db: anchor } } }))
|
|
139
|
+
await act(async () => root.unmount())
|
|
140
|
+
await render()
|
|
141
|
+
expect(row()?.textContent).toContain('2 issues started since')
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('compares a return visit with the previous one, not with itself', async () => {
|
|
145
|
+
// Last look three hours ago; Radar closed since. The page records this
|
|
146
|
+
// visit's list before the app-wide tracker runs.
|
|
147
|
+
const lookedAt = anchor
|
|
148
|
+
updateVisit(key(), () => ({ lastActiveAt: lookedAt + 60_000, cur: [hashId('listed-before')], curCover: { allAt: lookedAt }, curListedAt: lookedAt }))
|
|
149
|
+
await render()
|
|
150
|
+
expect(row()?.textContent).toContain('2 issues started since')
|
|
151
|
+
expect(readVisit(key())?.anchor).toBe(lookedAt)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('starts over after a Radar upgrade', async () => {
|
|
155
|
+
state.version = '1.23.0'
|
|
156
|
+
await render()
|
|
157
|
+
expect(row()).toBeNull()
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it('compares nothing while the Radar version is unknown', async () => {
|
|
161
|
+
state.version = undefined
|
|
162
|
+
await render()
|
|
163
|
+
expect(row()).toBeNull()
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('compares and records nothing when the signed-in user is unknown', async () => {
|
|
167
|
+
state.authFailed = true
|
|
168
|
+
await render()
|
|
169
|
+
expect(row()).toBeNull()
|
|
170
|
+
expect(readVisit(JSON.stringify([getApiBase(), 'kind-a', '', state.version]))).toBeFalsy()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('does not count a list that loaded in a hidden tab as seen', async () => {
|
|
174
|
+
const visibility = vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('hidden')
|
|
175
|
+
await render()
|
|
176
|
+
expect(readVisit(key())?.cur ?? []).toEqual([])
|
|
177
|
+
visibility.mockReturnValue('visible')
|
|
178
|
+
await act(async () => { document.dispatchEvent(new Event('visibilitychange')) })
|
|
179
|
+
expect(readVisit(key())?.cur).toContain(hashId('new-a'))
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('does not move the last look forward while refreshes fail', async () => {
|
|
183
|
+
const fetchedAt = Date.now() - 20 * 60_000
|
|
184
|
+
state.issues = { ...state.issues, dataUpdatedAt: fetchedAt, error: new Error('refresh failed') as never }
|
|
185
|
+
await render()
|
|
186
|
+
expect(readVisit(key())?.curListedAt).toBe(fetchedAt)
|
|
187
|
+
expect(readVisit(key())?.curCover?.allAt).toBe(fetchedAt)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it('keeps the visit going while the list is on screen', async () => {
|
|
191
|
+
await render()
|
|
192
|
+
expect(readVisit(key())?.lastActiveAt).toBeGreaterThan(Date.now() - 5000)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('does not count issues that permissions hid during the last look', async () => {
|
|
196
|
+
state.issues = { ...state.issues, data: { issues: [...fresh, ...notNew], visibility: { state: 'limited', impact: 'Some namespaces are hidden.' } } }
|
|
197
|
+
await render()
|
|
198
|
+
expect(row()).toBeNull()
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('says "at least" when the list is capped', async () => {
|
|
202
|
+
state.issues = { ...state.issues, data: { issues: [...fresh, ...notNew], total_matched: 40 } }
|
|
203
|
+
await render()
|
|
204
|
+
expect(row()?.textContent).toContain('At least 2 issues started since')
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('does not show on a single resource\'s issues', async () => {
|
|
208
|
+
await render('/issues?kind=Pod&resource=db%2Fnew-a')
|
|
209
|
+
expect(row()).toBeNull()
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('filters the list to the new issues and back', async () => {
|
|
213
|
+
await render()
|
|
214
|
+
await act(async () => button('Show only these')!.click())
|
|
215
|
+
expect(rowIds().sort()).toEqual(['new-a', 'new-b'])
|
|
216
|
+
await act(async () => button('Show all issues')!.click())
|
|
217
|
+
expect(rowIds()).toHaveLength(6)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('remembers the issues listed this visit for the next one', async () => {
|
|
221
|
+
await render()
|
|
222
|
+
const cur = readVisit(key())?.cur ?? []
|
|
223
|
+
expect(cur).toContain(hashId('new-a'))
|
|
224
|
+
expect(cur).toContain(hashId('unknown'))
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
describe('Radar Cloud sentence', () => {
|
|
228
|
+
it('opens the Radar Cloud dialog when Cloud is on and Radar runs standalone', async () => {
|
|
229
|
+
await render()
|
|
230
|
+
expect(row()?.textContent).toContain('Radar Cloud can alert you when an issue starts.')
|
|
231
|
+
await act(async () => button('Radar Cloud')!.click())
|
|
232
|
+
expect(state.openCloudFunnel).toHaveBeenCalledWith('since-last-visit')
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
it('is the only Radar Cloud line on the page while it shows', async () => {
|
|
236
|
+
state.aiSetup = 'off'
|
|
237
|
+
await render()
|
|
238
|
+
expect(container.textContent).not.toContain('AI investigations')
|
|
239
|
+
|
|
240
|
+
// Once the row is closed, the shared-install line comes back.
|
|
241
|
+
await act(async () => container.querySelector<HTMLButtonElement>('[aria-label="Hide until your next visit"]')!.click())
|
|
242
|
+
expect(container.textContent).toContain('AI investigations')
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('is left out when Cloud is off, keeping the count and the filter', async () => {
|
|
246
|
+
state.cloudConnect = false
|
|
247
|
+
await render()
|
|
248
|
+
expect(row()?.textContent).toContain('2 issues started since')
|
|
249
|
+
expect(row()?.textContent).not.toContain('Radar Cloud')
|
|
250
|
+
expect(button('Show only these')).toBeTruthy()
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('is left out when embedded', async () => {
|
|
254
|
+
state.embedded = true
|
|
255
|
+
await render()
|
|
256
|
+
expect(row()?.textContent).toContain('2 issues started since')
|
|
257
|
+
expect(row()?.textContent).not.toContain('Radar Cloud')
|
|
258
|
+
})
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
describe('dismissal', () => {
|
|
262
|
+
it('X hides the row for this visit and leaves the markers', async () => {
|
|
263
|
+
await render()
|
|
264
|
+
await act(async () => button('Show only these')!.click())
|
|
265
|
+
await act(async () => container.querySelector<HTMLButtonElement>('[aria-label="Hide until your next visit"]')!.click())
|
|
266
|
+
expect(row()).toBeNull()
|
|
267
|
+
expect(rowIds()).toHaveLength(6)
|
|
268
|
+
expect(newBadges().sort()).toEqual(['new-a', 'new-b'])
|
|
269
|
+
expect(readVisit(key())?.closedAnchor).toBe(anchor)
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
it('"Don\'t show again" hides the row for good and leaves the markers', async () => {
|
|
273
|
+
await render()
|
|
274
|
+
await act(async () => button("Don't show again")!.click())
|
|
275
|
+
expect(row()).toBeNull()
|
|
276
|
+
expect(sinceRowTurnedOff('ana')).toBe(true)
|
|
277
|
+
expect(newBadges().sort()).toEqual(['new-a', 'new-b'])
|
|
278
|
+
// Next visit: still off.
|
|
279
|
+
updateVisit(key(), (r) => ({ ...r!, closedAnchor: undefined }))
|
|
280
|
+
await act(async () => root.unmount())
|
|
281
|
+
await render()
|
|
282
|
+
expect(row()).toBeNull()
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
it('still hides when storage is blocked', async () => {
|
|
286
|
+
const seeded = readVisit(key())!
|
|
287
|
+
vi.spyOn(window, 'localStorage', 'get').mockImplementation(() => {
|
|
288
|
+
throw new DOMException('denied', 'SecurityError')
|
|
289
|
+
})
|
|
290
|
+
resetVisitMemory()
|
|
291
|
+
// Blocked storage keeps the record in memory for the page.
|
|
292
|
+
updateVisit(key(), () => seeded)
|
|
293
|
+
await render()
|
|
294
|
+
expect(row()).not.toBeNull()
|
|
295
|
+
await act(async () => container.querySelector<HTMLButtonElement>('[aria-label="Hide until your next visit"]')!.click())
|
|
296
|
+
expect(row()).toBeNull()
|
|
297
|
+
await act(async () => root.unmount())
|
|
298
|
+
await render()
|
|
299
|
+
expect(row()).toBeNull()
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
})
|