@skyhook-io/radar-app 1.18.2 → 1.20.0
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 +1 -1
- package/package.json +7 -7
- package/src/App.tsx +31 -6
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +97 -3
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +41 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/diagnose/AIMarkdown.tsx +4 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
- package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
- package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
- package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
- package/src/components/diagnose/AnalysisStory.tsx +17 -4
- package/src/components/diagnose/AssessmentCard.tsx +39 -8
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
- package/src/components/diagnose/DiagnoseContext.tsx +272 -10
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +208 -5
- package/src/components/diagnose/Home.tsx +187 -36
- package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
- package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
- package/src/components/diagnose/InvestigationView.tsx +249 -54
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +495 -0
- package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
- package/src/components/diagnose/QuestionFocus.tsx +123 -0
- package/src/components/diagnose/ResourcePicker.tsx +206 -0
- package/src/components/diagnose/StoryExcerpt.tsx +12 -3
- package/src/components/diagnose/assessmentCopy.ts +5 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
- package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
- package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/index.ts +1 -1
- package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +7 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/parts.test.tsx +20 -0
- package/src/components/diagnose/questionSuggestions.test.ts +111 -0
- package/src/components/diagnose/questionSuggestions.ts +150 -0
- package/src/components/diagnose/storyParts.test.tsx +13 -0
- package/src/components/diagnose/target.test.ts +143 -2
- package/src/components/diagnose/target.ts +109 -7
- package/src/components/diagnose/testdata/story-runs.json +474 -0
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/diagnose/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/home/ClusterHealthCard.tsx +13 -39
- package/src/components/home/HomeAgentBlock.test.tsx +141 -0
- package/src/components/home/HomeAgentBlock.tsx +103 -0
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +86 -47
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
- package/src/components/ui/Omnibar.tsx +47 -3
- package/src/components/ui/RadarOmnibar.test.tsx +1 -0
- package/src/components/ui/RadarOmnibar.tsx +11 -0
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +18 -4
- package/src/components/whats-new/releaseNotes.ts +136 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +6 -4
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
- package/src/hooks/useElementSize.ts +30 -0
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +12 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
// The free-form way into an investigation: the engineer says what they are
|
|
2
|
+
// seeing, where to start and since when, and optionally pins the resource it
|
|
3
|
+
// is about. It starts the same investigation, with the same Findings page, as
|
|
4
|
+
// Investigate on a resource; it is not a chat.
|
|
5
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import {
|
|
7
|
+
AlertOctagon,
|
|
8
|
+
AlertTriangle,
|
|
9
|
+
ArrowRight,
|
|
10
|
+
AtSign,
|
|
11
|
+
CornerDownLeft,
|
|
12
|
+
X,
|
|
13
|
+
} from "lucide-react";
|
|
14
|
+
import {
|
|
15
|
+
Collapse,
|
|
16
|
+
ISSUE_SEVERITY_LABEL,
|
|
17
|
+
ISSUE_SEVERITY_TEXT_CLASS,
|
|
18
|
+
} from "@skyhook-io/k8s-ui";
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
useContexts,
|
|
22
|
+
useIssues,
|
|
23
|
+
useNamespaceScope,
|
|
24
|
+
useResourceIssues,
|
|
25
|
+
} from "../../api/client";
|
|
26
|
+
import { kindToPluralWithGroup } from "../../utils/navigation";
|
|
27
|
+
import { useDiagnose } from "./DiagnoseContext";
|
|
28
|
+
import {
|
|
29
|
+
suggestionsForPin,
|
|
30
|
+
suggestionsFromIssues,
|
|
31
|
+
type QuestionPin,
|
|
32
|
+
type QuestionSuggestion,
|
|
33
|
+
} from "./questionSuggestions";
|
|
34
|
+
import { ResourcePicker } from "./ResourcePicker";
|
|
35
|
+
import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
|
|
36
|
+
import { Tooltip } from "../ui/Tooltip";
|
|
37
|
+
import { formatInvestigationTarget } from "./target";
|
|
38
|
+
|
|
39
|
+
export const LOOK_BACKS = ["15m", "1h", "6h", "24h"] as const;
|
|
40
|
+
const DEFAULT_LOOK_BACK = "1h";
|
|
41
|
+
const MAX_START_NAMESPACES = 20;
|
|
42
|
+
// Radar refuses a longer question; a pasted or handed-over one can arrive
|
|
43
|
+
// past the box's own limit.
|
|
44
|
+
const MAX_QUESTION_LENGTH = 2000;
|
|
45
|
+
|
|
46
|
+
// Chips state what the question carries; actions change it. They must not
|
|
47
|
+
// look alike, or a scope chip reads as a menu and an action as a value.
|
|
48
|
+
const chipClass =
|
|
49
|
+
"inline-flex max-w-full items-center gap-1 rounded-md border border-theme-border bg-theme-elevated px-2 py-0.5 text-xs text-theme-text-secondary";
|
|
50
|
+
const actionClass =
|
|
51
|
+
"inline-flex items-center gap-1 rounded-md border border-dashed border-theme-border px-2 py-0.5 text-xs text-theme-text-tertiary hover:border-theme-text-tertiary hover:text-theme-text-primary";
|
|
52
|
+
|
|
53
|
+
export function QuestionComposer({
|
|
54
|
+
onBrowseIssues,
|
|
55
|
+
onOpenExample,
|
|
56
|
+
}: {
|
|
57
|
+
onBrowseIssues?: () => void;
|
|
58
|
+
onOpenExample?: () => void;
|
|
59
|
+
}) {
|
|
60
|
+
const { openInvestigation, agentLabel, questionDraft, saveQuestionDraft } =
|
|
61
|
+
useDiagnose();
|
|
62
|
+
// The draft outlives this component: it starts from it, and gives back
|
|
63
|
+
// whatever is unsent when it unmounts (opening a run, a resource).
|
|
64
|
+
const [text, setText] = useState(questionDraft?.text ?? "");
|
|
65
|
+
const [pin, setPin] = useState<QuestionPin | null>(
|
|
66
|
+
questionDraft?.pin ?? null,
|
|
67
|
+
);
|
|
68
|
+
const [lookBack, setLookBack] = useState<string>(
|
|
69
|
+
questionDraft?.lookBack ?? DEFAULT_LOOK_BACK,
|
|
70
|
+
);
|
|
71
|
+
// A handed-over question keeps when it was first asked until it is edited.
|
|
72
|
+
const [inherited, setInherited] = useState(
|
|
73
|
+
questionDraft?.askedAt && questionDraft.text
|
|
74
|
+
? { text: questionDraft.text.trim(), askedAt: questionDraft.askedAt }
|
|
75
|
+
: null,
|
|
76
|
+
);
|
|
77
|
+
const [pickerOpen, setPickerOpen] = useState(!!questionDraft?.pickResource);
|
|
78
|
+
const textRef = useRef<HTMLTextAreaElement>(null);
|
|
79
|
+
const pickerInputRef = useRef<HTMLInputElement>(null);
|
|
80
|
+
// Focus now so typing straight away lands in the box; once new text has
|
|
81
|
+
// rendered, put the caret after it so the engineer can keep writing.
|
|
82
|
+
const focusText = () => {
|
|
83
|
+
const caretToEnd = () => {
|
|
84
|
+
const box = textRef.current;
|
|
85
|
+
box?.setSelectionRange(box.value.length, box.value.length);
|
|
86
|
+
};
|
|
87
|
+
textRef.current?.focus();
|
|
88
|
+
caretToEnd();
|
|
89
|
+
requestAnimationFrame(caretToEnd);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// A pin and chosen namespaces name things in one cluster. After a cluster
|
|
93
|
+
// switch they would name same-named things somewhere else, so they go; the
|
|
94
|
+
// words stay.
|
|
95
|
+
const { data: contexts } = useContexts();
|
|
96
|
+
const currentContext = contexts?.find((context) => context.isCurrent)?.name;
|
|
97
|
+
const [chosenIn, setChosenIn] = useState(questionDraft?.context);
|
|
98
|
+
const [droppedForCluster, setDroppedForCluster] = useState(false);
|
|
99
|
+
|
|
100
|
+
// Where to start follows the namespace picker until the engineer edits it.
|
|
101
|
+
const { data: scope } = useNamespaceScope();
|
|
102
|
+
const [namespaces, setNamespaces] = useState<string[] | null>(
|
|
103
|
+
questionDraft?.namespaces ?? null,
|
|
104
|
+
);
|
|
105
|
+
const picked = namespaces ?? scope?.actives ?? [];
|
|
106
|
+
// Past a handful of namespaces, the whole cluster is the honest place to
|
|
107
|
+
// start, and the backend accepts at most MAX_START_NAMESPACES.
|
|
108
|
+
const tooMany = picked.length > MAX_START_NAMESPACES;
|
|
109
|
+
const startIn = tooMany ? [] : picked;
|
|
110
|
+
|
|
111
|
+
// Suggestions follow what the question is about: the pinned resource's
|
|
112
|
+
// own issues, or the issues where the namespaces say to start.
|
|
113
|
+
const { data: issuesData } = useIssues(startIn, !pin);
|
|
114
|
+
const { data: pinIssues } = useResourceIssues(
|
|
115
|
+
pin ? kindToPluralWithGroup(pin.kind, pin.group) : "",
|
|
116
|
+
pin?.group || undefined,
|
|
117
|
+
pin?.namespace ?? "",
|
|
118
|
+
pin?.name ?? "",
|
|
119
|
+
!!pin,
|
|
120
|
+
);
|
|
121
|
+
const asked = text.trim();
|
|
122
|
+
const suggestions = useMemo(
|
|
123
|
+
() =>
|
|
124
|
+
(pin
|
|
125
|
+
? suggestionsForPin(pinIssues ?? [], pin)
|
|
126
|
+
: suggestionsFromIssues(issuesData?.issues ?? [])
|
|
127
|
+
).filter((suggestion) => !asked.includes(suggestion.question)),
|
|
128
|
+
[pin, pinIssues, issuesData, asked],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (pickerOpen) pickerInputRef.current?.focus();
|
|
133
|
+
}, [pickerOpen]);
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!currentContext) return;
|
|
137
|
+
if (chosenIn && chosenIn !== currentContext && (pin || namespaces)) {
|
|
138
|
+
setPin(null);
|
|
139
|
+
setNamespaces(null);
|
|
140
|
+
setDroppedForCluster(true);
|
|
141
|
+
}
|
|
142
|
+
if (chosenIn !== currentContext) setChosenIn(currentContext);
|
|
143
|
+
}, [currentContext, chosenIn, pin, namespaces]);
|
|
144
|
+
|
|
145
|
+
const unsent = useRef({
|
|
146
|
+
text,
|
|
147
|
+
pin,
|
|
148
|
+
namespaces,
|
|
149
|
+
lookBack,
|
|
150
|
+
inherited,
|
|
151
|
+
chosenIn,
|
|
152
|
+
});
|
|
153
|
+
unsent.current = { text, pin, namespaces, lookBack, inherited, chosenIn };
|
|
154
|
+
// A submitted question belongs to its start, not the draft; the start gives
|
|
155
|
+
// it back if it never becomes a run.
|
|
156
|
+
const submitted = useRef(false);
|
|
157
|
+
useEffect(
|
|
158
|
+
() => () => {
|
|
159
|
+
if (submitted.current) {
|
|
160
|
+
saveQuestionDraft({});
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const draft = unsent.current;
|
|
164
|
+
saveQuestionDraft({
|
|
165
|
+
askedAt:
|
|
166
|
+
draft.inherited?.text === draft.text.trim()
|
|
167
|
+
? draft.inherited.askedAt
|
|
168
|
+
: undefined,
|
|
169
|
+
text: draft.text,
|
|
170
|
+
pin: draft.pin ?? undefined,
|
|
171
|
+
namespaces: draft.namespaces ?? undefined,
|
|
172
|
+
lookBack: draft.lookBack,
|
|
173
|
+
context: draft.chosenIn,
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
[saveQuestionDraft],
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
// A new hand-off (Ask about a resource, a start that never became a run)
|
|
180
|
+
// replaces what is here; the draft this composer started from does not.
|
|
181
|
+
const appliedSeq = useRef(questionDraft?.seq);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!questionDraft || questionDraft.seq === appliedSeq.current) return;
|
|
184
|
+
appliedSeq.current = questionDraft.seq;
|
|
185
|
+
if (questionDraft.restore && unsent.current.text.trim()) return;
|
|
186
|
+
submitted.current = false;
|
|
187
|
+
if (!questionDraft.keepWords) {
|
|
188
|
+
setText(questionDraft.text ?? "");
|
|
189
|
+
setInherited(
|
|
190
|
+
questionDraft.askedAt && questionDraft.text
|
|
191
|
+
? { text: questionDraft.text.trim(), askedAt: questionDraft.askedAt }
|
|
192
|
+
: null,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
setPin(questionDraft.pin ?? null);
|
|
196
|
+
setNamespaces(questionDraft.namespaces ?? null);
|
|
197
|
+
setChosenIn(questionDraft.context ?? currentContext);
|
|
198
|
+
setDroppedForCluster(false);
|
|
199
|
+
setLookBack(questionDraft.lookBack ?? DEFAULT_LOOK_BACK);
|
|
200
|
+
setPickerOpen(!!questionDraft.pickResource);
|
|
201
|
+
if (!questionDraft.pickResource) focusText();
|
|
202
|
+
}, [questionDraft, currentContext]);
|
|
203
|
+
|
|
204
|
+
// A hand-off that mounts this composer (the Omnibar row, Ask about a
|
|
205
|
+
// resource, Back to your question) lands in the box, ready for Enter.
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (questionDraft?.seq && !questionDraft.pickResource) focusText();
|
|
208
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- mount only
|
|
209
|
+
}, []);
|
|
210
|
+
|
|
211
|
+
const question = text.trim();
|
|
212
|
+
const tooLong = [...question].length > MAX_QUESTION_LENGTH;
|
|
213
|
+
const submit = () => {
|
|
214
|
+
if (!question || tooLong) return;
|
|
215
|
+
submitted.current = true;
|
|
216
|
+
openInvestigation({
|
|
217
|
+
fromComposer: true,
|
|
218
|
+
kind: pin?.kind ?? "",
|
|
219
|
+
group: pin?.group ?? "",
|
|
220
|
+
namespace: pin?.namespace ?? "",
|
|
221
|
+
name: pin?.name ?? "",
|
|
222
|
+
question,
|
|
223
|
+
namespaces: pin ? [] : startIn,
|
|
224
|
+
lookBack,
|
|
225
|
+
askedAt: inherited?.text === question ? inherited.askedAt : undefined,
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// What the engineer already typed is their question; a suggestion then only
|
|
230
|
+
// says where to start.
|
|
231
|
+
const applySuggestion = (suggestion: QuestionSuggestion) => {
|
|
232
|
+
if (!text.trim()) setText(suggestion.question);
|
|
233
|
+
setPin(suggestion.pin ?? null);
|
|
234
|
+
setNamespaces(suggestion.namespaces);
|
|
235
|
+
focusText();
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const addable =
|
|
239
|
+
startIn.length >= MAX_START_NAMESPACES
|
|
240
|
+
? []
|
|
241
|
+
: (scope?.accessibleNamespaces ?? []).filter(
|
|
242
|
+
(ns) => !startIn.includes(ns),
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<section className="mx-auto w-full max-w-2xl">
|
|
247
|
+
<h1 className="text-xl font-semibold text-theme-text-primary">
|
|
248
|
+
What are you seeing?
|
|
249
|
+
</h1>
|
|
250
|
+
<p className="mt-1 text-sm text-theme-text-tertiary">
|
|
251
|
+
Describe a problem, or ask whether something looks right. {agentLabel}{" "}
|
|
252
|
+
investigates it with Radar’s read-only tools and shows what it found,
|
|
253
|
+
with the evidence.
|
|
254
|
+
</p>
|
|
255
|
+
|
|
256
|
+
<form
|
|
257
|
+
className="mt-4 rounded-lg border border-theme-border bg-theme-surface shadow-theme-sm focus-within:border-accent"
|
|
258
|
+
onSubmit={(event) => {
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
submit();
|
|
261
|
+
}}
|
|
262
|
+
>
|
|
263
|
+
<textarea
|
|
264
|
+
ref={textRef}
|
|
265
|
+
value={text}
|
|
266
|
+
onChange={(event) => setText(event.target.value)}
|
|
267
|
+
onKeyDown={(event) => {
|
|
268
|
+
// "@" starting a word opens the picker; one inside a word (an
|
|
269
|
+
// email, an image digest) is just text.
|
|
270
|
+
if (event.key === "@" && !pin && !pickerOpen) {
|
|
271
|
+
const box = event.currentTarget;
|
|
272
|
+
const before = box.value.slice(0, box.selectionStart ?? 0);
|
|
273
|
+
if (before === "" || /\s$/.test(before)) {
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
setPickerOpen(true);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (
|
|
280
|
+
event.key === "Enter" &&
|
|
281
|
+
!event.shiftKey &&
|
|
282
|
+
!event.nativeEvent.isComposing
|
|
283
|
+
) {
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
submit();
|
|
286
|
+
}
|
|
287
|
+
}}
|
|
288
|
+
rows={3}
|
|
289
|
+
maxLength={MAX_QUESTION_LENGTH}
|
|
290
|
+
aria-label="What are you seeing?"
|
|
291
|
+
placeholder={
|
|
292
|
+
"e.g. checkout returns 502s since the last deploy\ne.g. is catalog's memory use normal?"
|
|
293
|
+
}
|
|
294
|
+
className="block w-full resize-none rounded-t-lg bg-transparent px-3 py-2.5 text-sm text-theme-text-primary placeholder:text-theme-text-tertiary focus:outline-none"
|
|
295
|
+
/>
|
|
296
|
+
<div className="flex flex-wrap items-center gap-1.5 border-t border-theme-border-subtle px-3 py-2">
|
|
297
|
+
{pin ? (
|
|
298
|
+
<span className={chipClass}>
|
|
299
|
+
<span className="text-theme-text-tertiary">About</span>
|
|
300
|
+
<span className="truncate font-medium text-theme-text-primary">
|
|
301
|
+
{formatInvestigationTarget(pin)}
|
|
302
|
+
</span>
|
|
303
|
+
<button
|
|
304
|
+
type="button"
|
|
305
|
+
onClick={() => setPin(null)}
|
|
306
|
+
aria-label="Unpin resource"
|
|
307
|
+
className="rounded text-theme-text-tertiary hover:text-theme-text-primary"
|
|
308
|
+
>
|
|
309
|
+
<X className="h-3 w-3" />
|
|
310
|
+
</button>
|
|
311
|
+
</span>
|
|
312
|
+
) : (
|
|
313
|
+
<>
|
|
314
|
+
<span className="text-xs text-theme-text-tertiary">Start in</span>
|
|
315
|
+
{startIn.length === 0 ? (
|
|
316
|
+
<Tooltip
|
|
317
|
+
disabled={!tooMany}
|
|
318
|
+
content={`${picked.length} namespaces are selected; investigations start across the cluster past ${MAX_START_NAMESPACES}.`}
|
|
319
|
+
>
|
|
320
|
+
<span className={chipClass}>
|
|
321
|
+
All namespaces
|
|
322
|
+
{tooMany ? ` (${picked.length} selected)` : ""}
|
|
323
|
+
</span>
|
|
324
|
+
</Tooltip>
|
|
325
|
+
) : (
|
|
326
|
+
startIn.map((ns) => (
|
|
327
|
+
<span key={ns} className={chipClass}>
|
|
328
|
+
<span className="truncate">{ns}</span>
|
|
329
|
+
<button
|
|
330
|
+
type="button"
|
|
331
|
+
onClick={() =>
|
|
332
|
+
setNamespaces(startIn.filter((n) => n !== ns))
|
|
333
|
+
}
|
|
334
|
+
aria-label={`Remove namespace ${ns}`}
|
|
335
|
+
className="rounded text-theme-text-tertiary hover:text-theme-text-primary"
|
|
336
|
+
>
|
|
337
|
+
<X className="h-3 w-3" />
|
|
338
|
+
</button>
|
|
339
|
+
</span>
|
|
340
|
+
))
|
|
341
|
+
)}
|
|
342
|
+
{addable.length > 0 && (
|
|
343
|
+
<select
|
|
344
|
+
value=""
|
|
345
|
+
onChange={(event) =>
|
|
346
|
+
event.target.value &&
|
|
347
|
+
setNamespaces([...startIn, event.target.value])
|
|
348
|
+
}
|
|
349
|
+
aria-label="Add a namespace to start in"
|
|
350
|
+
className="w-28 cursor-pointer rounded-md border border-dashed border-theme-border bg-transparent px-1.5 py-0.5 text-xs text-theme-text-tertiary hover:border-theme-text-tertiary hover:text-theme-text-primary"
|
|
351
|
+
>
|
|
352
|
+
<option value="">+ namespace</option>
|
|
353
|
+
{addable.map((ns) => (
|
|
354
|
+
<option key={ns} value={ns}>
|
|
355
|
+
{ns}
|
|
356
|
+
</option>
|
|
357
|
+
))}
|
|
358
|
+
</select>
|
|
359
|
+
)}
|
|
360
|
+
<button
|
|
361
|
+
type="button"
|
|
362
|
+
onClick={() => setPickerOpen((open) => !open)}
|
|
363
|
+
aria-expanded={pickerOpen}
|
|
364
|
+
className={actionClass}
|
|
365
|
+
>
|
|
366
|
+
<AtSign className="h-3 w-3" />
|
|
367
|
+
Pin a resource
|
|
368
|
+
</button>
|
|
369
|
+
</>
|
|
370
|
+
)}
|
|
371
|
+
<span className="ml-auto flex items-center gap-1">
|
|
372
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
373
|
+
Started within
|
|
374
|
+
</span>
|
|
375
|
+
<span
|
|
376
|
+
role="group"
|
|
377
|
+
aria-label="Started within"
|
|
378
|
+
className="inline-flex rounded-md border border-theme-border"
|
|
379
|
+
>
|
|
380
|
+
{LOOK_BACKS.map((value) => (
|
|
381
|
+
<button
|
|
382
|
+
key={value}
|
|
383
|
+
type="button"
|
|
384
|
+
aria-pressed={lookBack === value}
|
|
385
|
+
onClick={() => setLookBack(value)}
|
|
386
|
+
className={`px-1.5 py-0.5 text-xs first:rounded-l-md last:rounded-r-md ${
|
|
387
|
+
lookBack === value
|
|
388
|
+
? "bg-accent-muted text-accent-text"
|
|
389
|
+
: "text-theme-text-tertiary hover:bg-theme-hover"
|
|
390
|
+
}`}
|
|
391
|
+
>
|
|
392
|
+
{value}
|
|
393
|
+
</button>
|
|
394
|
+
))}
|
|
395
|
+
</span>
|
|
396
|
+
<button
|
|
397
|
+
type="submit"
|
|
398
|
+
disabled={!question || tooLong}
|
|
399
|
+
className="btn-brand ml-1 inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium disabled:opacity-50"
|
|
400
|
+
>
|
|
401
|
+
Investigate
|
|
402
|
+
<ArrowRight className="h-3.5 w-3.5" />
|
|
403
|
+
</button>
|
|
404
|
+
</span>
|
|
405
|
+
</div>
|
|
406
|
+
{tooLong && (
|
|
407
|
+
<p className="border-t border-theme-border-subtle px-3 py-1.5 text-[11px] text-theme-text-tertiary">
|
|
408
|
+
Questions can be up to {MAX_QUESTION_LENGTH} characters; this one
|
|
409
|
+
has {[...question].length}.
|
|
410
|
+
</p>
|
|
411
|
+
)}
|
|
412
|
+
{droppedForCluster && !pin && namespaces === null && (
|
|
413
|
+
<p className="border-t border-theme-border-subtle px-3 py-1.5 text-[11px] text-theme-text-tertiary">
|
|
414
|
+
The cluster changed, so the pinned resource and chosen namespaces
|
|
415
|
+
were cleared. Your words are kept.
|
|
416
|
+
</p>
|
|
417
|
+
)}
|
|
418
|
+
<Collapse open={pickerOpen && !pin} unmountOnExit>
|
|
419
|
+
<ResourcePicker
|
|
420
|
+
inputRef={pickerInputRef}
|
|
421
|
+
onPick={(picked) => {
|
|
422
|
+
setPin(picked);
|
|
423
|
+
setPickerOpen(false);
|
|
424
|
+
textRef.current?.focus();
|
|
425
|
+
}}
|
|
426
|
+
onCancel={() => {
|
|
427
|
+
setPickerOpen(false);
|
|
428
|
+
textRef.current?.focus();
|
|
429
|
+
}}
|
|
430
|
+
/>
|
|
431
|
+
</Collapse>
|
|
432
|
+
</form>
|
|
433
|
+
|
|
434
|
+
{suggestions.length > 0 && (
|
|
435
|
+
<div className="mt-5">
|
|
436
|
+
<h2 className="text-xs font-medium text-theme-text-tertiary">
|
|
437
|
+
From what Radar sees now
|
|
438
|
+
</h2>
|
|
439
|
+
<ul className="mt-1.5 divide-y divide-theme-border-subtle overflow-hidden rounded-lg border border-theme-border bg-theme-surface">
|
|
440
|
+
{suggestions.map((suggestion) => {
|
|
441
|
+
const SeverityIcon =
|
|
442
|
+
suggestion.severity === "critical"
|
|
443
|
+
? AlertOctagon
|
|
444
|
+
: AlertTriangle;
|
|
445
|
+
return (
|
|
446
|
+
<li key={suggestion.key}>
|
|
447
|
+
<button
|
|
448
|
+
type="button"
|
|
449
|
+
onClick={() => applySuggestion(suggestion)}
|
|
450
|
+
aria-label={`${ISSUE_SEVERITY_LABEL[suggestion.severity]}: ${suggestion.title}, ${suggestion.where}. ${text.trim() ? "Pins it to your question." : `Puts “${suggestion.question}” in the box.`}`}
|
|
451
|
+
className="group flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm hover:bg-theme-hover focus-visible:bg-theme-hover focus-visible:outline-none"
|
|
452
|
+
>
|
|
453
|
+
<SeverityIcon
|
|
454
|
+
aria-hidden
|
|
455
|
+
className={`h-4 w-4 shrink-0 ${ISSUE_SEVERITY_TEXT_CLASS[suggestion.severity]}`}
|
|
456
|
+
/>
|
|
457
|
+
<span className="min-w-0 flex-1 truncate">
|
|
458
|
+
<span className="font-medium text-theme-text-primary">
|
|
459
|
+
{suggestion.title}
|
|
460
|
+
</span>
|
|
461
|
+
<span className="ml-2 text-theme-text-tertiary">
|
|
462
|
+
{suggestion.where}
|
|
463
|
+
</span>
|
|
464
|
+
</span>
|
|
465
|
+
<span className="flex shrink-0 items-center gap-1 text-xs text-theme-text-tertiary group-hover:text-theme-text-secondary group-focus-visible:text-theme-text-secondary">
|
|
466
|
+
<span className="opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100">
|
|
467
|
+
Use
|
|
468
|
+
</span>
|
|
469
|
+
<CornerDownLeft aria-hidden className="h-3.5 w-3.5" />
|
|
470
|
+
</span>
|
|
471
|
+
</button>
|
|
472
|
+
</li>
|
|
473
|
+
);
|
|
474
|
+
})}
|
|
475
|
+
</ul>
|
|
476
|
+
</div>
|
|
477
|
+
)}
|
|
478
|
+
{onBrowseIssues && (
|
|
479
|
+
<button
|
|
480
|
+
type="button"
|
|
481
|
+
onClick={onBrowseIssues}
|
|
482
|
+
className="mt-4 inline-flex items-center gap-1 text-xs text-theme-text-tertiary hover:text-theme-text-primary"
|
|
483
|
+
>
|
|
484
|
+
Or pick a problem from Issues
|
|
485
|
+
<ArrowRight className="h-3 w-3" />
|
|
486
|
+
</button>
|
|
487
|
+
)}
|
|
488
|
+
{onOpenExample && (
|
|
489
|
+
<div className="mt-3">
|
|
490
|
+
<ExampleInvestigationLink onOpen={onOpenExample} />
|
|
491
|
+
</div>
|
|
492
|
+
)}
|
|
493
|
+
</section>
|
|
494
|
+
);
|
|
495
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { QuestionFocus } from "./QuestionFocus";
|
|
5
|
+
|
|
6
|
+
const focus = [
|
|
7
|
+
{ kind: "Deployment", group: "apps", namespace: "shop", name: "api" },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
describe("QuestionFocus", () => {
|
|
11
|
+
it("offers to investigate the resource or choose another", () => {
|
|
12
|
+
const html = renderToStaticMarkup(
|
|
13
|
+
<QuestionFocus
|
|
14
|
+
focus={focus}
|
|
15
|
+
onOpenResource={vi.fn()}
|
|
16
|
+
onInvestigate={vi.fn()}
|
|
17
|
+
onChooseResource={vi.fn()}
|
|
18
|
+
/>,
|
|
19
|
+
);
|
|
20
|
+
expect(html).toContain("Investigate this resource");
|
|
21
|
+
expect(html).toContain("Choose another resource");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("offers nothing to act on for a run about another cluster", () => {
|
|
25
|
+
const html = renderToStaticMarkup(
|
|
26
|
+
<QuestionFocus
|
|
27
|
+
focus={focus}
|
|
28
|
+
stale
|
|
29
|
+
onOpenResource={vi.fn()}
|
|
30
|
+
onInvestigate={vi.fn()}
|
|
31
|
+
onChooseResource={vi.fn()}
|
|
32
|
+
/>,
|
|
33
|
+
);
|
|
34
|
+
expect(html).toContain("Deployment shop/api");
|
|
35
|
+
expect(html).not.toContain("<button");
|
|
36
|
+
expect(html).toContain("connect to that cluster and find");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ArrowRight } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import type { DiagnosisResourceRef } from "./diagnoseEvidenceTypes";
|
|
4
|
+
import {
|
|
5
|
+
formatInvestigationTarget,
|
|
6
|
+
type InvestigationTargetIdentity,
|
|
7
|
+
} from "./target";
|
|
8
|
+
|
|
9
|
+
// Where a question-only investigation came to rest. Investigating one of these
|
|
10
|
+
// starts a run about that resource with the same question, which is where a
|
|
11
|
+
// fix can be confirmed and applied. The earlier verdict is not carried over:
|
|
12
|
+
// it was written from cluster data, and the new run's question must stay the
|
|
13
|
+
// engineer's own words.
|
|
14
|
+
export function QuestionFocus({
|
|
15
|
+
focus,
|
|
16
|
+
onOpenResource,
|
|
17
|
+
onInvestigate,
|
|
18
|
+
onChooseResource,
|
|
19
|
+
disabled,
|
|
20
|
+
stale = false,
|
|
21
|
+
}: {
|
|
22
|
+
focus: InvestigationTargetIdentity[];
|
|
23
|
+
onOpenResource?: (ref: DiagnosisResourceRef) => void;
|
|
24
|
+
onInvestigate: (resource: InvestigationTargetIdentity) => void;
|
|
25
|
+
/** Ask the same question about a resource the engineer picks. */
|
|
26
|
+
onChooseResource: () => void;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** The run is about another cluster: its resources can't be opened or
|
|
29
|
+
* investigated from this one. */
|
|
30
|
+
stale?: boolean;
|
|
31
|
+
}) {
|
|
32
|
+
if (stale) {
|
|
33
|
+
return focus.length > 0 ? (
|
|
34
|
+
<section aria-label="Focused on" className="card-inner px-3 py-2">
|
|
35
|
+
<h3 className="text-xs font-medium text-theme-text-tertiary">
|
|
36
|
+
Focused on
|
|
37
|
+
</h3>
|
|
38
|
+
<ul className="mt-1 space-y-1 text-sm text-theme-text-primary">
|
|
39
|
+
{focus.map((resource) => (
|
|
40
|
+
<li key={formatInvestigationTarget(resource)} className="truncate">
|
|
41
|
+
{formatInvestigationTarget(resource)}
|
|
42
|
+
</li>
|
|
43
|
+
))}
|
|
44
|
+
</ul>
|
|
45
|
+
<p className="mt-1.5 text-[11px] text-theme-text-tertiary">
|
|
46
|
+
In the cluster this investigation ran against. This investigation
|
|
47
|
+
ended when Radar switched clusters; connect to that cluster and find
|
|
48
|
+
them there to investigate one.
|
|
49
|
+
</p>
|
|
50
|
+
</section>
|
|
51
|
+
) : null;
|
|
52
|
+
}
|
|
53
|
+
const choose = (
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
disabled={disabled}
|
|
57
|
+
onClick={onChooseResource}
|
|
58
|
+
className="text-xs text-accent-text hover:underline disabled:opacity-50"
|
|
59
|
+
>
|
|
60
|
+
{focus.length > 0
|
|
61
|
+
? "Choose another resource…"
|
|
62
|
+
: "Choose a resource to investigate…"}
|
|
63
|
+
</button>
|
|
64
|
+
);
|
|
65
|
+
if (focus.length === 0) {
|
|
66
|
+
return (
|
|
67
|
+
<section aria-label="Focused on" className="card-inner px-3 py-2">
|
|
68
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
69
|
+
This assessment didn’t single out one resource Radar read. A fix is
|
|
70
|
+
applied from an investigation of the resource it changes.
|
|
71
|
+
</p>
|
|
72
|
+
<div className="mt-1">{choose}</div>
|
|
73
|
+
</section>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return (
|
|
77
|
+
<section aria-label="Focused on" className="card-inner px-3 py-2">
|
|
78
|
+
<h3 className="text-xs font-medium text-theme-text-tertiary">
|
|
79
|
+
Focused on
|
|
80
|
+
</h3>
|
|
81
|
+
<ul className="mt-1 space-y-1">
|
|
82
|
+
{focus.map((resource) => {
|
|
83
|
+
const label = formatInvestigationTarget(resource);
|
|
84
|
+
return (
|
|
85
|
+
<li
|
|
86
|
+
key={label}
|
|
87
|
+
className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm"
|
|
88
|
+
>
|
|
89
|
+
{onOpenResource ? (
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
onClick={() => onOpenResource(resource)}
|
|
93
|
+
className="min-w-0 truncate text-left text-theme-text-primary hover:underline"
|
|
94
|
+
>
|
|
95
|
+
{label}
|
|
96
|
+
</button>
|
|
97
|
+
) : (
|
|
98
|
+
<span className="min-w-0 truncate text-theme-text-primary">
|
|
99
|
+
{label}
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
onClick={() => onInvestigate(resource)}
|
|
106
|
+
className="inline-flex shrink-0 items-center gap-1 text-xs text-accent-text hover:underline disabled:opacity-50"
|
|
107
|
+
>
|
|
108
|
+
Investigate this resource
|
|
109
|
+
<ArrowRight className="h-3 w-3" />
|
|
110
|
+
</button>
|
|
111
|
+
</li>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</ul>
|
|
115
|
+
<div className="mt-1.5 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">
|
|
116
|
+
<p className="text-[11px] text-theme-text-tertiary">
|
|
117
|
+
A fix is applied from an investigation of the resource it changes.
|
|
118
|
+
</p>
|
|
119
|
+
{choose}
|
|
120
|
+
</div>
|
|
121
|
+
</section>
|
|
122
|
+
);
|
|
123
|
+
}
|