@skyhook-io/radar-app 1.20.1 → 1.21.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.
Files changed (215) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +65 -16
  3. package/src/api/client.audit-gating.test.tsx +105 -5
  4. package/src/api/client.auditBadgesSync.test.tsx +118 -0
  5. package/src/api/client.capabilitiesPoll.test.ts +61 -0
  6. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  7. package/src/api/client.pauseDeployment.test.tsx +77 -0
  8. package/src/api/client.restartError.test.ts +14 -0
  9. package/src/api/client.revisionRefresh.test.tsx +44 -0
  10. package/src/api/client.rollbackError.test.ts +14 -0
  11. package/src/api/client.ts +347 -16
  12. package/src/api/namespaceScopeRetry.test.ts +14 -0
  13. package/src/api/networkAttachments.test.tsx +120 -0
  14. package/src/api/networkAttachments.ts +30 -0
  15. package/src/api/radarFeatures.test.ts +5 -0
  16. package/src/api/radarFeatures.ts +10 -0
  17. package/src/api/secretsStore.test.ts +33 -0
  18. package/src/api/secretsStore.ts +37 -0
  19. package/src/api/substrateHealth.ts +134 -0
  20. package/src/api/velero.test.ts +60 -0
  21. package/src/api/velero.ts +201 -0
  22. package/src/api/vulnerabilities.ts +255 -0
  23. package/src/components/ConnectionErrorView.test.tsx +11 -0
  24. package/src/components/ConnectionErrorView.tsx +19 -0
  25. package/src/components/ContextSwitcher.tsx +9 -2
  26. package/src/components/NamespaceSwitcher.tsx +3 -1
  27. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  28. package/src/components/applications/ApplicationsView.tsx +8 -11
  29. package/src/components/audit/AuditView.tsx +4 -0
  30. package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
  31. package/src/components/audit/ChecksViewTabs.tsx +11 -1
  32. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  33. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  34. package/src/components/audit/VulnerabilitiesView.tsx +907 -0
  35. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  36. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  37. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  38. package/src/components/cnpg/CNPGView.tsx +43 -117
  39. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  40. package/src/components/cnpg/host.tsx +2 -2
  41. package/src/components/cnpg/routes.ts +3 -1
  42. package/src/components/cnpg/shared.tsx +5 -53
  43. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  44. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  45. package/src/components/community.tsx +42 -0
  46. package/src/components/cost/CostView.tsx +27 -9
  47. package/src/components/diagnose/InvestigationView.tsx +12 -3
  48. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  49. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  50. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
  51. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  52. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  53. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  54. package/src/components/diagnose/investigationMetrics.ts +2 -1
  55. package/src/components/dock/BottomDock.tsx +1 -0
  56. package/src/components/dock/LogsTab.tsx +3 -0
  57. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  58. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  59. package/src/components/dock/TerminalPreferences.tsx +73 -0
  60. package/src/components/gitops/GitOpsView.tsx +2 -10
  61. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  62. package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
  63. package/src/components/helm/HelmView.tsx +25 -19
  64. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  65. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  66. package/src/components/helm/OwnedResources.test.tsx +86 -0
  67. package/src/components/helm/OwnedResources.tsx +69 -11
  68. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  69. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  70. package/src/components/home/ClusterHealthCard.tsx +25 -11
  71. package/src/components/home/HelmSummary.tsx +15 -15
  72. package/src/components/home/HomeAgentBlock.tsx +3 -0
  73. package/src/components/home/HomeView.tsx +7 -0
  74. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  75. package/src/components/home/MCPSetupDialog.tsx +4 -2
  76. package/src/components/home/mcpToolCatalog.ts +17 -4
  77. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  78. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  79. package/src/components/logs/LogsViewer.tsx +3 -1
  80. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  81. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  82. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  83. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  84. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  85. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  86. package/src/components/resource/RightsizingStrip.tsx +53 -4
  87. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  88. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  89. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  90. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  91. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  92. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  93. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  94. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  95. package/src/components/resources/ResourcesView.tsx +12 -6
  96. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  97. package/src/components/resources/pod-file-upload.ts +266 -0
  98. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  99. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  100. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  101. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  102. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  103. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  104. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  105. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  106. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  107. package/src/components/rightsizing/RightsizingScanView.tsx +19 -3
  108. package/src/components/rightsizing/model.test.ts +11 -0
  109. package/src/components/rightsizing/model.ts +3 -1
  110. package/src/components/rightsizing/presentation.test.ts +46 -0
  111. package/src/components/rightsizing/presentation.ts +17 -2
  112. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  113. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  114. package/src/components/timeline/TimelineView.tsx +3 -1
  115. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  116. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  117. package/src/components/traffic/TrafficData.test.tsx +37 -0
  118. package/src/components/traffic/TrafficData.tsx +27 -0
  119. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  120. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  121. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  122. package/src/components/traffic/TrafficGraph.tsx +135 -64
  123. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  124. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  125. package/src/components/traffic/TrafficView.tsx +72 -155
  126. package/src/components/traffic/trafficFilters.test.ts +189 -1
  127. package/src/components/traffic/trafficFilters.ts +169 -1
  128. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  129. package/src/components/ui/Omnibar.tsx +4 -1
  130. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  131. package/src/components/ui/RadarOmnibar.tsx +7 -1
  132. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  133. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  134. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  135. package/src/components/ui/UpdateNotification.test.tsx +54 -3
  136. package/src/components/ui/UpdateNotification.tsx +60 -19
  137. package/src/components/ui/command-items.ts +24 -1
  138. package/src/components/ui/omnibar-match.test.ts +7 -0
  139. package/src/components/ui/omnibar-match.ts +1 -0
  140. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  141. package/src/components/ui/searchCoverageNote.ts +31 -7
  142. package/src/components/useContextSwitchFlow.tsx +9 -1
  143. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  144. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  145. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  146. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  147. package/src/components/velero/VeleroDetailPage.tsx +148 -0
  148. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  149. package/src/components/velero/VeleroKindLists.tsx +43 -0
  150. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  151. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  152. package/src/components/velero/VeleroLocations.tsx +240 -0
  153. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  154. package/src/components/velero/VeleroOverview.tsx +485 -0
  155. package/src/components/velero/VeleroPages.test.tsx +516 -0
  156. package/src/components/velero/VeleroPages.tsx +1056 -0
  157. package/src/components/velero/VeleroRunLists.tsx +309 -0
  158. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  159. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  160. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  161. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  162. package/src/components/velero/VeleroSchedules.tsx +255 -0
  163. package/src/components/velero/VeleroView.tsx +59 -0
  164. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  165. package/src/components/velero/attention.test.ts +178 -0
  166. package/src/components/velero/attention.ts +281 -0
  167. package/src/components/velero/backupDelete.test.tsx +91 -0
  168. package/src/components/velero/backupDelete.tsx +182 -0
  169. package/src/components/velero/coverage.test.ts +87 -0
  170. package/src/components/velero/coverage.ts +150 -0
  171. package/src/components/velero/host.tsx +86 -0
  172. package/src/components/velero/routes.ts +78 -0
  173. package/src/components/velero/runs.tsx +121 -0
  174. package/src/components/velero/shared.test.ts +84 -0
  175. package/src/components/velero/shared.tsx +423 -0
  176. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  177. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  178. package/src/components/velero/velero.fixtures.ts +61 -0
  179. package/src/components/velero/workspaceRoute.ts +21 -0
  180. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
  181. package/src/components/vulnerabilities/parts.test.ts +72 -0
  182. package/src/components/vulnerabilities/parts.tsx +291 -0
  183. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  184. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  185. package/src/components/workload/WorkloadView.tsx +114 -37
  186. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  187. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  188. package/src/components/workspace/coverage.ts +61 -0
  189. package/src/components/workspace/layout.test.tsx +29 -1
  190. package/src/components/workspace/layout.tsx +15 -5
  191. package/src/components/workspace/sidebar.ts +9 -0
  192. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  193. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  194. package/src/context/ConnectionContext.test.ts +1 -0
  195. package/src/context/ConnectionContext.tsx +2 -2
  196. package/src/desktop/AboutDialog.test.ts +12 -0
  197. package/src/desktop/AboutDialog.tsx +151 -0
  198. package/src/desktop/WindowsTitleBar.tsx +359 -0
  199. package/src/desktop/titleBar.test.ts +61 -0
  200. package/src/desktop/titleBar.ts +45 -0
  201. package/src/index.css +19 -0
  202. package/src/integrations/resourceHost.ts +5 -1
  203. package/src/integrations/resourceHosts.test.tsx +15 -3
  204. package/src/integrations/resourceHosts.tsx +26 -6
  205. package/src/integrations/workspaceRoute.ts +1 -1
  206. package/src/integrations/workspaceRoutes.test.ts +11 -0
  207. package/src/integrations/workspaceRoutes.ts +3 -1
  208. package/src/integrations/workspaceScreens.tsx +2 -0
  209. package/src/main.tsx +8 -0
  210. package/src/utils/desktop-zoom.test.ts +53 -0
  211. package/src/utils/desktop-zoom.ts +30 -0
  212. package/src/utils/namespacePick.test.ts +87 -0
  213. package/src/utils/namespacePick.ts +88 -0
  214. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  215. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -13,6 +13,20 @@ import { openFile, openFolder } from '../../utils/desktop-open-folder'
13
13
  import { useToast } from '../ui/Toast'
14
14
  import { Tooltip } from '../ui/Tooltip'
15
15
  import { PodFilePreview, PREVIEW_BYTE_CAP } from './PodFilePreview'
16
+ import { useNamespacedCapabilities } from '../../contexts/CapabilitiesContext'
17
+ import { useRadarFeature } from '../../api/client'
18
+ import {
19
+ canShowUpload,
20
+ fileMountHint,
21
+ isValidUploadName,
22
+ oversizeMessage,
23
+ PodFileUploadError,
24
+ UPLOAD_CANCELLED,
25
+ uploadBlockedHint,
26
+ uploadPodFile,
27
+ uploadTarget,
28
+ } from './pod-file-upload'
29
+ import { isUploadBusy, PodFileUploadButton, PodFileUploadNotices, PodFileUploadStatus, type UploadState } from './PodFileUploadPanel'
16
30
 
17
31
  interface PodFilesystem {
18
32
  root: FileNode
@@ -128,6 +142,8 @@ interface PodFilesystemModalProps {
128
142
  containers: string[]
129
143
  initialContainer?: string
130
144
  onSwitchToImageFiles?: (containerName: string) => void
145
+ /** The pod object; its volume mounts tell where uploads cannot work. */
146
+ pod?: unknown
131
147
  }
132
148
 
133
149
  export function PodFilesystemModal({
@@ -138,30 +154,57 @@ export function PodFilesystemModal({
138
154
  containers,
139
155
  initialContainer,
140
156
  onSwitchToImageFiles,
157
+ pod,
141
158
  }: PodFilesystemModalProps) {
142
159
  const dialogRef = useRef<HTMLDivElement>(null)
143
160
  const [searchQuery, setSearchQuery] = useState('')
144
161
  const [selectedContainer, setSelectedContainer] = useState(initialContainer || containers[0] || '')
145
162
  const [currentPath, setCurrentPath] = useState('/')
146
163
  const [filesystem, setFilesystem] = useState<PodFilesystem | null>(null)
164
+ // The container the shown listing came from; it lags selectedContainer
165
+ // while a switch is loading.
166
+ const [listedContainer, setListedContainer] = useState<string | null>(null)
167
+ const loadSeq = useRef(0)
147
168
  const [isLoading, setIsLoading] = useState(false)
148
169
  const [error, setError] = useState<string | null>(null)
149
170
  // The file being viewed in place of the listing; null shows the directory.
150
171
  const [previewFile, setPreviewFile] = useState<FileNode | null>(null)
151
172
  const toast = useToast()
152
173
 
174
+ const { canExec } = useNamespacedCapabilities(namespace)
175
+ const { support: uploadSupport, guard: guardUpload } = useRadarFeature('podFileUpload')
176
+ const uploadEnabled = canShowUpload({ canExec, featureSupported: uploadSupport === 'supported' })
177
+ const [upload, setUpload] = useState<UploadState>({ phase: 'idle' })
178
+ const [dragging, setDragging] = useState(false)
179
+ const pendingFile = useRef<File | null>(null)
180
+ const uploadAbort = useRef<AbortController | null>(null)
181
+ const fileInputRef = useRef<HTMLInputElement>(null)
182
+ const listRef = useRef<HTMLDivElement>(null)
183
+ const currentPathRef = useRef(currentPath)
184
+ useEffect(() => { currentPathRef.current = currentPath }, [currentPath])
185
+ const uploadRef = useRef(upload)
186
+ useEffect(() => { uploadRef.current = upload }, [upload])
187
+ // Uploads that had sent every byte when the dialog closed or the container
188
+ // changed. The container may already be committing them, so they run on and
189
+ // report through a toast instead of being cancelled.
190
+ const detachedUploads = useRef(new Set<AbortController>())
191
+
153
192
  const loadDirectory = useCallback(async (dirPath: string) => {
193
+ const seq = ++loadSeq.current
154
194
  setPreviewFile(null)
155
195
  setIsLoading(true)
156
196
  setError(null)
157
197
  try {
158
198
  const result = await fetchPodFiles(namespace, podName, selectedContainer, dirPath)
199
+ if (seq !== loadSeq.current) return
159
200
  setFilesystem(result)
160
201
  setCurrentPath(dirPath)
202
+ setListedContainer(selectedContainer)
161
203
  } catch (err) {
204
+ if (seq !== loadSeq.current) return
162
205
  setError(err instanceof Error ? err.message : 'Failed to list files')
163
206
  } finally {
164
- setIsLoading(false)
207
+ if (seq === loadSeq.current) setIsLoading(false)
165
208
  }
166
209
  }, [namespace, podName, selectedContainer])
167
210
 
@@ -177,6 +220,7 @@ export function PodFilesystemModal({
177
220
  if (!open) {
178
221
  setSearchQuery('')
179
222
  setFilesystem(null)
223
+ setListedContainer(null)
180
224
  setError(null)
181
225
  setIsLoading(false)
182
226
  setCurrentPath('/')
@@ -185,6 +229,157 @@ export function PodFilesystemModal({
185
229
  }
186
230
  }, [open, initialContainer, containers])
187
231
 
232
+ // Leaving the dialog or the container abandons an upload that has not
233
+ // finished sending; the server then writes nothing. One that is already
234
+ // saving is left to finish.
235
+ useEffect(() => {
236
+ if (!open) return
237
+ const detached = detachedUploads.current
238
+ return () => {
239
+ const abort = uploadAbort.current
240
+ if (abort && uploadRef.current.phase === 'saving') detached.add(abort)
241
+ else abort?.abort()
242
+ uploadAbort.current = null
243
+ pendingFile.current = null
244
+ setUpload({ phase: 'idle' })
245
+ }
246
+ }, [open, selectedContainer])
247
+
248
+ const blockedHint = useMemo(
249
+ () => (uploadEnabled ? uploadBlockedHint(pod, selectedContainer, currentPath) : null),
250
+ [uploadEnabled, pod, selectedContainer, currentPath],
251
+ )
252
+
253
+ const sendFile = useCallback(async (file: File, dir: string, overwrite: boolean) => {
254
+ const abort = new AbortController()
255
+ uploadAbort.current = abort
256
+ setUpload({ phase: 'uploading', name: file.name, dir, sent: 0, total: file.size })
257
+ try {
258
+ const result = await guardUpload(() => uploadPodFile({
259
+ namespace,
260
+ podName,
261
+ container: selectedContainer,
262
+ dir,
263
+ file,
264
+ name: file.name,
265
+ overwrite,
266
+ signal: abort.signal,
267
+ onProgress: (sent, total) => {
268
+ if (abort.signal.aborted) return
269
+ // Every byte is out; what remains is the container committing it.
270
+ setUpload(sent >= total
271
+ ? { phase: 'saving', name: file.name, dir }
272
+ : { phase: 'uploading', name: file.name, dir, sent, total })
273
+ },
274
+ }))
275
+ if (detachedUploads.current.delete(abort)) {
276
+ toast.showSuccess(result.replaced ? 'File replaced' : 'File uploaded', result.path)
277
+ return
278
+ }
279
+ if (uploadAbort.current !== abort) return
280
+ setUpload({ phase: 'saved', path: result.path, replaced: result.replaced })
281
+ if (dir === currentPathRef.current) loadDirectory(dir)
282
+ } catch (err) {
283
+ if (detachedUploads.current.delete(abort)) {
284
+ toast.showError(`Could not upload ${file.name}`, err instanceof Error ? err.message : String(err))
285
+ return
286
+ }
287
+ if (uploadAbort.current !== abort) return
288
+ if (err instanceof PodFileUploadError && err.code === UPLOAD_CANCELLED) {
289
+ setUpload({ phase: 'idle' })
290
+ return
291
+ }
292
+ setUpload({ phase: 'error', name: file.name, message: err instanceof Error ? err.message : String(err) })
293
+ } finally {
294
+ if (uploadAbort.current === abort) uploadAbort.current = null
295
+ }
296
+ }, [guardUpload, namespace, podName, selectedContainer, loadDirectory, toast])
297
+
298
+ const listingReady = !isLoading && !!filesystem?.root && listedContainer === selectedContainer
299
+
300
+ const startUpload = useCallback((file: File) => {
301
+ if (!listingReady) return
302
+ const dir = currentPath
303
+ if (!isValidUploadName(file.name)) {
304
+ setUpload({ phase: 'error', name: file.name, message: 'That file name cannot be used in the container.' })
305
+ return
306
+ }
307
+ const oversize = oversizeMessage(file.size)
308
+ if (oversize) {
309
+ setUpload({ phase: 'error', name: file.name, message: oversize })
310
+ return
311
+ }
312
+ const filePath = dir === '/' ? `/${file.name}` : `${dir}/${file.name}`
313
+ const mounted = fileMountHint(pod, selectedContainer, filePath)
314
+ if (mounted) {
315
+ setUpload({ phase: 'error', name: file.name, message: mounted.reason })
316
+ return
317
+ }
318
+ const target = uploadTarget(filesystem?.root, file.name)
319
+ if (target.kind === 'refuse') {
320
+ setUpload({ phase: 'error', name: file.name, message: target.reason })
321
+ return
322
+ }
323
+ if (target.kind === 'replace') {
324
+ pendingFile.current = file
325
+ setUpload({ phase: 'confirm', name: file.name, dir, size: file.size })
326
+ return
327
+ }
328
+ sendFile(file, dir, false)
329
+ }, [listingReady, currentPath, pod, selectedContainer, filesystem, sendFile])
330
+
331
+ const confirmReplace = useCallback(() => {
332
+ const file = pendingFile.current
333
+ pendingFile.current = null
334
+ if (file && upload.phase === 'confirm') sendFile(file, upload.dir, true)
335
+ }, [sendFile, upload])
336
+
337
+ const cancelUpload = useCallback(() => {
338
+ pendingFile.current = null
339
+ const abort = uploadAbort.current
340
+ uploadAbort.current = null
341
+ abort?.abort()
342
+ setUpload({ phase: 'idle' })
343
+ }, [])
344
+
345
+ const uploadHere = uploadEnabled && !previewFile && listingReady && !blockedHint && !isUploadBusy(upload)
346
+ // A file dropped anywhere in the dialog must never reach the browser, which
347
+ // would open it in place of Radar; only a drop on the listing uploads it.
348
+ const ownsFileDrag = (e: React.DragEvent) => uploadEnabled && e.dataTransfer.types.includes('Files')
349
+ const overList = (e: React.DragEvent) => !!listRef.current?.contains(e.target as Node)
350
+
351
+ const handleDragOver = (e: React.DragEvent) => {
352
+ if (!ownsFileDrag(e)) return
353
+ e.preventDefault()
354
+ const accept = uploadHere && overList(e)
355
+ e.dataTransfer.dropEffect = accept ? 'copy' : 'none'
356
+ if (accept !== dragging) setDragging(accept)
357
+ }
358
+ const handleDragLeave = (e: React.DragEvent) => {
359
+ if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setDragging(false)
360
+ }
361
+ const handleDrop = (e: React.DragEvent) => {
362
+ setDragging(false)
363
+ if (!ownsFileDrag(e)) return
364
+ e.preventDefault()
365
+ if (!overList(e)) return
366
+ if (!uploadHere) {
367
+ if (blockedHint) setUpload({ phase: 'error', name: 'the file', message: blockedHint.reason })
368
+ return
369
+ }
370
+ const items = Array.from(e.dataTransfer.items ?? [])
371
+ if (items.some((item) => item.webkitGetAsEntry?.()?.isDirectory)) {
372
+ setUpload({ phase: 'error', name: 'folder', message: 'Folders cannot be uploaded; drop a single file.' })
373
+ return
374
+ }
375
+ const files = Array.from(e.dataTransfer.files)
376
+ if (files.length !== 1) {
377
+ setUpload({ phase: 'error', name: `${files.length} files`, message: 'Drop one file at a time.' })
378
+ return
379
+ }
380
+ startUpload(files[0])
381
+ }
382
+
188
383
  // ESC steps back one level: out of a file to its listing, then out of the
189
384
  // dialog. One listener owns both so the two can never race.
190
385
  useEffect(() => {
@@ -225,7 +420,12 @@ export function PodFilesystemModal({
225
420
  }
226
421
 
227
422
  return createPortal(
228
- <div className="fixed inset-0 z-[100] flex items-center justify-center">
423
+ <div
424
+ className="fixed inset-0 z-[100] flex items-center justify-center"
425
+ onDragOver={handleDragOver}
426
+ onDragLeave={handleDragLeave}
427
+ onDrop={handleDrop}
428
+ >
229
429
  {/* Backdrop */}
230
430
  <div className="absolute inset-0 bg-black/60 backdrop-blur-sm" onClick={onClose} />
231
431
 
@@ -272,6 +472,29 @@ export function PodFilesystemModal({
272
472
  </div>
273
473
  )}
274
474
 
475
+ {uploadEnabled && !previewFile && showFilesystem && (
476
+ <>
477
+ <PodFileUploadButton
478
+ blocked={blockedHint}
479
+ busy={isUploadBusy(upload)}
480
+ loading={!listingReady}
481
+ onClick={() => fileInputRef.current?.click()}
482
+ />
483
+ <input
484
+ ref={fileInputRef}
485
+ type="file"
486
+ className="hidden"
487
+ aria-hidden="true"
488
+ tabIndex={-1}
489
+ onChange={(e) => {
490
+ const file = e.target.files?.[0]
491
+ e.target.value = ''
492
+ if (file) startUpload(file)
493
+ }}
494
+ />
495
+ </>
496
+ )}
497
+
275
498
  {/* Container selector */}
276
499
  {!previewFile && containers.length > 1 && (
277
500
  <select
@@ -347,7 +570,27 @@ export function PodFilesystemModal({
347
570
  />
348
571
  </div>
349
572
  ) : (
350
- <div className="flex-1 min-h-0 overflow-y-auto p-4">
573
+ <div
574
+ ref={listRef}
575
+ className={clsx('relative flex-1 min-h-0 overflow-y-auto p-4', dragging && 'ring-2 ring-inset ring-accent')}
576
+ >
577
+ {uploadEnabled && showFilesystem && (
578
+ <>
579
+ <PodFileUploadNotices namespace={namespace} blocked={blockedHint} onNavigateAway={onClose} />
580
+ <PodFileUploadStatus
581
+ state={upload}
582
+ onConfirmReplace={confirmReplace}
583
+ onCancel={cancelUpload}
584
+ onDismiss={() => setUpload({ phase: 'idle' })}
585
+ />
586
+ </>
587
+ )}
588
+ {dragging && (
589
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-theme-base/80 text-sm font-medium text-theme-text-primary">
590
+ Drop to upload into {currentPath}
591
+ </div>
592
+ )}
593
+
351
594
  {/* Loading */}
352
595
  {isLoading && <PaneLoader label="Loading files…" className="h-full" />}
353
596
 
@@ -1,7 +1,7 @@
1
1
  import { useState, useMemo, useCallback } from 'react'
2
2
  import { useLocation, useNavigate } from 'react-router-dom'
3
3
  import { useQuery } from '@tanstack/react-query'
4
- import { fetchJSON, isForbiddenError, isKindSyncFailed, isStillLoadingError, useCapabilities, useNamespaceCapabilities, useResources, useSecretCertExpiry, useTopPodMetrics, useTopNodeMetrics, useBulkDeleteResources, useBulkRestartWorkloads, useBulkScaleWorkloads, useAudit, useIssues, fetchResourceList, isListTooLargeError, isUnretryableReadError } from '../../api/client'
4
+ import { fetchJSON, isForbiddenError, isKindSyncFailed, isStillLoadingError, useCapabilities, useNamespaceCapabilities, useResources, useSecretCertExpiry, useTopPodMetrics, useTopNodeMetrics, useBulkDeleteResources, useBulkRestartWorkloads, useBulkScaleWorkloads, useAuditBadges, useIssues, fetchResourceList, isListTooLargeError, isUnretryableReadError } from '../../api/client'
5
5
  import { isBadgeWorthy } from '../../utils/auditBadges'
6
6
  import { ISSUE_SEVERITY_RANK } from '@skyhook-io/k8s-ui'
7
7
  import type { Issue, AuditBadgeMessage } from '@skyhook-io/k8s-ui'
@@ -13,6 +13,9 @@ import { getSecretStoreProviderType } from '@skyhook-io/k8s-ui'
13
13
  import { usePinnedKinds } from '../../hooks/useFavorites'
14
14
  import { useResourceCounts } from '../../hooks/useResourceCounts'
15
15
  import { useCNPGSidebarWorkspace } from '../cnpg/useCNPGSidebarWorkspace'
16
+ import { useVeleroSidebarWorkspace } from '../velero/useVeleroSidebarWorkspace'
17
+ import { isVeleroBackupKind } from '../velero/routes'
18
+ import { useMergedSidebarWorkspaces } from '../workspace/sidebar'
16
19
  import { renderResourceKindList, resourceKindListMode, useResourceHostFeatures } from '../../integrations/resourceHosts'
17
20
  import { useOpenLogs, useOpenWorkloadLogs } from '../dock'
18
21
  import {
@@ -124,6 +127,8 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
124
127
  return result
125
128
  }, [issuesData])
126
129
  const cnpgSidebarWorkspace = useCNPGSidebarWorkspace({ apiResources, namespaces, withMetrics: selectedKind?.group === 'postgresql.cnpg.io' })
130
+ const veleroSidebarWorkspace = useVeleroSidebarWorkspace({ apiResources })
131
+ const sidebarCategoryWorkspaces = useMergedSidebarWorkspaces(cnpgSidebarWorkspace, veleroSidebarWorkspace)
127
132
  const workloadWrites = namespaces.length === 0
128
133
  ? capabilities?.workloadWrites
129
134
  : namespaces.length === 1
@@ -161,7 +166,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
161
166
  // kind shared across groups doesn't bleed findings across the two lists. Only
162
167
  // "badge-worthy" findings count (reference-integrity / lifecycle) — posture
163
168
  // and best-practice nags fire near-universally and would just be noise.
164
- const audit = useAudit(namespaces)
169
+ const audit = useAuditBadges(namespaces)
165
170
  const auditBadges = useMemo(() => {
166
171
  if (!selectedKind || !audit.data?.findings) return undefined
167
172
  const wantGroup = selectedKind.group
@@ -345,9 +350,9 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
345
350
  const [createDialogYaml, setCreateDialogYaml] = useState('')
346
351
  const [createDialogTitle, setCreateDialogTitle] = useState<string | undefined>()
347
352
 
348
- const handleCreateResource = useCallback((kind: { name: string; kind: string; group: string } | null) => {
353
+ const handleCreateResource = useCallback((kind: SelectedKindInfo, initialYaml?: string) => {
349
354
  if (kind?.kind) {
350
- setCreateDialogYaml(getSkeletonYaml(kind.kind, kind.group))
355
+ setCreateDialogYaml(initialYaml ?? getSkeletonYaml(kind.kind, kind.group))
351
356
  setCreateDialogTitle(`Create ${kind.kind}`)
352
357
  } else {
353
358
  setCreateDialogYaml('')
@@ -395,7 +400,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
395
400
  ? { kind: selectedKind.name, reason: 'too-many', count: typeof selectedKindQuery.error.data?.count === 'number' ? selectedKindQuery.error.data.count : undefined, limit: selectedKindRowLimit, namespaces }
396
401
  : largeListGuard}
397
402
  onSelectedKindChange={setSelectedKind}
398
- sidebarCategoryWorkspaces={cnpgSidebarWorkspace}
403
+ sidebarCategoryWorkspaces={sidebarCategoryWorkspaces}
399
404
  topPodMetrics={topPodMetrics}
400
405
  topNodeMetrics={topNodeMetrics}
401
406
  certExpiry={certExpiry}
@@ -426,7 +431,8 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
426
431
  onCreateResource={handleCreateResource}
427
432
  renderKindView={renderKindView}
428
433
  // Bulk operations
429
- onBulkDelete={(items, options) => bulkDeleteMutation.mutate({ items, force: options?.force }, { onSuccess: results => { if (!results.some(({ result }) => result.outcomeUnknown)) options?.onSuccess?.() } })}
434
+ // A Velero backup is deleted one at a time, through Velero (Delete backup in its drawer).
435
+ onBulkDelete={isVeleroBackupKind(selectedKind?.name, selectedKind?.group) ? undefined : (items, options) => bulkDeleteMutation.mutate({ items, force: options?.force }, { onSuccess: results => { if (!results.some(({ result }) => result.outcomeUnknown)) options?.onSuccess?.() } })}
430
436
  isBulkDeleting={bulkDeleteMutation.isPending}
431
437
  onBulkRestart={canBulkRestartSelectedKind ? (items, options) => bulkRestartMutation.mutate({ items }, { onSuccess: options?.onSuccess }) : undefined}
432
438
  isBulkRestarting={canBulkRestartSelectedKind && bulkRestartMutation.isPending}
@@ -0,0 +1,223 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+ import { MemoryRouter } from 'react-router-dom'
4
+ import type { FileNode } from '../../types'
5
+ import {
6
+ canShowUpload,
7
+ fileMountHint,
8
+ isValidUploadName,
9
+ oversizeMessage,
10
+ POD_FILE_PERSISTENCE_NOTE,
11
+ uploadBlockedHint,
12
+ uploadResponseError,
13
+ uploadTarget,
14
+ } from './pod-file-upload'
15
+ import { PodFileUploadButton, PodFileUploadNotices, PodFileUploadStatus } from './PodFileUploadPanel'
16
+
17
+ describe('canShowUpload', () => {
18
+ it('needs exec and a server that serves the endpoint', () => {
19
+ expect(canShowUpload({ canExec: true, featureSupported: true })).toBe(true)
20
+ expect(canShowUpload({ canExec: false, featureSupported: true })).toBe(false)
21
+ expect(canShowUpload({ canExec: true, featureSupported: false })).toBe(false)
22
+ })
23
+ })
24
+
25
+ const pod = {
26
+ spec: {
27
+ containers: [
28
+ {
29
+ name: 'app',
30
+ volumeMounts: [
31
+ { name: 'cfg', mountPath: '/etc/app' },
32
+ { name: 'tls', mountPath: '/etc/tls/' },
33
+ { name: 'data', mountPath: '/data' },
34
+ { name: 'shared', mountPath: '/shared', readOnly: true },
35
+ { name: 'one', mountPath: '/etc/nginx/nginx.conf' },
36
+ { name: 'proj', mountPath: '/var/run/proj' },
37
+ ],
38
+ },
39
+ { name: 'locked', securityContext: { readOnlyRootFilesystem: true }, volumeMounts: [{ name: 'data', mountPath: '/data' }] },
40
+ ],
41
+ initContainers: [
42
+ { name: 'sidecar', restartPolicy: 'Always', volumeMounts: [{ name: 'cfg', mountPath: '/config' }] },
43
+ ],
44
+ volumes: [
45
+ { name: 'cfg', configMap: { name: 'app-config' } },
46
+ { name: 'tls', secret: { secretName: 'app-tls' } },
47
+ { name: 'data', emptyDir: {} },
48
+ { name: 'shared', persistentVolumeClaim: { claimName: 'shared' } },
49
+ { name: 'one', configMap: { name: 'nginx' } },
50
+ { name: 'proj', projected: { sources: [{ secret: { name: 'only-one' } }] } },
51
+ ],
52
+ },
53
+ }
54
+
55
+ describe('uploadBlockedHint', () => {
56
+ it('blocks ConfigMap and Secret mounts and names their source', () => {
57
+ expect(uploadBlockedHint(pod, 'app', '/etc/app')?.source).toEqual({ kind: 'ConfigMap', name: 'app-config' })
58
+ expect(uploadBlockedHint(pod, 'app', '/etc/app/..data')?.source).toEqual({ kind: 'ConfigMap', name: 'app-config' })
59
+ expect(uploadBlockedHint(pod, 'app', '/etc/tls')?.source).toEqual({ kind: 'Secret', name: 'app-tls' })
60
+ })
61
+
62
+ it('names the single source of a projected volume', () => {
63
+ expect(uploadBlockedHint(pod, 'app', '/var/run/proj')?.source).toEqual({ kind: 'Secret', name: 'only-one' })
64
+ })
65
+
66
+ it('blocks read-only mounts', () => {
67
+ expect(uploadBlockedHint(pod, 'app', '/shared/x')?.reason).toMatch(/read-only/)
68
+ })
69
+
70
+ it('allows writable volumes and an unmounted path on a writable root', () => {
71
+ expect(uploadBlockedHint(pod, 'app', '/data')).toBeNull()
72
+ expect(uploadBlockedHint(pod, 'app', '/tmp')).toBeNull()
73
+ expect(uploadBlockedHint(pod, 'app', '/etc')).toBeNull()
74
+ expect(uploadBlockedHint(pod, 'app', '/etc/application')).toBeNull()
75
+ })
76
+
77
+ it('blocks a read-only root filesystem outside writable volumes', () => {
78
+ expect(uploadBlockedHint(pod, 'locked', '/tmp')?.reason).toMatch(/readOnlyRootFilesystem/)
79
+ expect(uploadBlockedHint(pod, 'locked', '/data/sub')).toBeNull()
80
+ })
81
+
82
+ it('reads mounts of native sidecars', () => {
83
+ expect(uploadBlockedHint(pod, 'sidecar', '/config')?.source).toEqual({ kind: 'ConfigMap', name: 'app-config' })
84
+ })
85
+
86
+ it('gives no hint for an unknown container or missing pod', () => {
87
+ expect(uploadBlockedHint(pod, 'nope', '/etc/app')).toBeNull()
88
+ expect(uploadBlockedHint(undefined, 'app', '/etc/app')).toBeNull()
89
+ })
90
+ })
91
+
92
+ describe('fileMountHint', () => {
93
+ it('flags a file mounted on its own', () => {
94
+ const hint = fileMountHint(pod, 'app', '/etc/nginx/nginx.conf')
95
+ expect(hint?.source).toEqual({ kind: 'ConfigMap', name: 'nginx' })
96
+ expect(fileMountHint(pod, 'app', '/etc/nginx/other.conf')).toBeNull()
97
+ })
98
+ })
99
+
100
+ describe('uploadTarget', () => {
101
+ const listing: FileNode = {
102
+ name: 'etc',
103
+ path: '/etc',
104
+ type: 'dir',
105
+ children: [
106
+ { name: 'a.conf', path: '/etc/a.conf', type: 'file' },
107
+ { name: 'conf.d', path: '/etc/conf.d', type: 'dir' },
108
+ { name: 'link', path: '/etc/link', type: 'symlink', linkTarget: '/x' },
109
+ ],
110
+ }
111
+
112
+ it('asks before replacing an existing file', () => {
113
+ expect(uploadTarget(listing, 'a.conf')).toEqual({ kind: 'replace' })
114
+ })
115
+
116
+ it('uploads a new name straight away', () => {
117
+ expect(uploadTarget(listing, 'b.conf')).toEqual({ kind: 'new' })
118
+ })
119
+
120
+ it('refuses directories and symlinks', () => {
121
+ expect(uploadTarget(listing, 'conf.d').kind).toBe('refuse')
122
+ expect(uploadTarget(listing, 'link').kind).toBe('refuse')
123
+ })
124
+ })
125
+
126
+ describe('isValidUploadName', () => {
127
+ it('matches what the server accepts', () => {
128
+ expect(isValidUploadName('app.conf')).toBe(true)
129
+ expect(isValidUploadName('-rf')).toBe(true)
130
+ for (const bad of ['', '.', '..', 'a/b', 'a\0b', 'x'.repeat(256)]) {
131
+ expect(isValidUploadName(bad)).toBe(false)
132
+ }
133
+ })
134
+ })
135
+
136
+ describe('oversizeMessage', () => {
137
+ it('refuses a file over the advertised cap before sending it', () => {
138
+ expect(oversizeMessage(200 * 1024 * 1024)).toMatch(/limited to 100/)
139
+ expect(oversizeMessage(100 * 1024 * 1024)).toBeNull()
140
+ expect(oversizeMessage(10, 5)).toMatch(/limited to/)
141
+ })
142
+ })
143
+
144
+ describe('upload controls', () => {
145
+ it('disables the button under a known read-only mount and says why', () => {
146
+ const html = renderToStaticMarkup(
147
+ <PodFileUploadButton blocked={{ reason: '/etc/app is a ConfigMap volume.' }} busy={false} onClick={() => {}} />,
148
+ )
149
+ expect(html).toMatch(/<button[^>]* disabled=""/)
150
+ })
151
+
152
+ it('disables the button while the listing for the selected container loads', () => {
153
+ const html = renderToStaticMarkup(<PodFileUploadButton blocked={null} busy={false} loading onClick={() => {}} />)
154
+ expect(html).toMatch(/<button[^>]* disabled=""/)
155
+ })
156
+
157
+ it('enables the button when nothing blocks it', () => {
158
+ const html = renderToStaticMarkup(<PodFileUploadButton blocked={null} busy={false} onClick={() => {}} />)
159
+ expect(html).not.toMatch(/<button[^>]* disabled=""/)
160
+ })
161
+
162
+ it('shows the persistence note verbatim and links to the blocking source', () => {
163
+ const html = renderToStaticMarkup(
164
+ <MemoryRouter>
165
+ <PodFileUploadNotices
166
+ namespace="prod"
167
+ blocked={{ reason: 'ConfigMap volume', source: { kind: 'ConfigMap', name: 'app-config' } }}
168
+ onNavigateAway={() => {}}
169
+ />
170
+ </MemoryRouter>,
171
+ )
172
+ expect(html).toContain(POD_FILE_PERSISTENCE_NOTE.replace(/'/g, '&#x27;'))
173
+ expect(html).toContain('href="/resources/configmaps?resource=prod%2Fapp-config"')
174
+ })
175
+
176
+ it('asks for confirmation before replacing', () => {
177
+ const html = renderToStaticMarkup(
178
+ <PodFileUploadStatus
179
+ state={{ phase: 'confirm', name: 'a.conf', dir: '/etc', size: 10 }}
180
+ onConfirmReplace={() => {}}
181
+ onCancel={() => {}}
182
+ onDismiss={() => {}}
183
+ />,
184
+ )
185
+ expect(html).toContain('Replace a.conf?')
186
+ expect(html).toContain('/etc/a.conf already exists')
187
+ expect(html).toContain('>Replace<')
188
+ })
189
+
190
+ it('keeps uploading and saved distinct', () => {
191
+ const uploading = renderToStaticMarkup(
192
+ <PodFileUploadStatus state={{ phase: 'uploading', name: 'a', dir: '/', sent: 50, total: 100 }} onConfirmReplace={() => {}} onCancel={() => {}} onDismiss={() => {}} />,
193
+ )
194
+ expect(uploading).toContain('aria-valuenow="50"')
195
+ expect(uploading).toContain('>Cancel<')
196
+ const saving = renderToStaticMarkup(
197
+ <PodFileUploadStatus state={{ phase: 'saving', name: 'a', dir: '/' }} onConfirmReplace={() => {}} onCancel={() => {}} onDismiss={() => {}} />,
198
+ )
199
+ expect(saving).toContain('Saving a')
200
+ expect(saving).not.toContain('>Cancel<')
201
+ const saved = renderToStaticMarkup(
202
+ <PodFileUploadStatus state={{ phase: 'saved', path: '/a', replaced: false }} onConfirmReplace={() => {}} onCancel={() => {}} onDismiss={() => {}} />,
203
+ )
204
+ expect(saved).toContain('Saved /a')
205
+ })
206
+ })
207
+
208
+ describe('uploadResponseError', () => {
209
+ it('blames a proxy only when a 413 carries no Radar error body', () => {
210
+ const fromProxy = uploadResponseError(413, null)
211
+ expect(fromProxy.message).toMatch(/proxy/)
212
+ expect(fromProxy.code).toBe('file_too_large')
213
+
214
+ const fromRadar = uploadResponseError(413, { error: 'Uploads are limited to 104857600 bytes', error_code: 'file_too_large' })
215
+ expect(fromRadar.message).toBe('Uploads are limited to 104857600 bytes')
216
+ expect(fromRadar.message).not.toMatch(/proxy/)
217
+ })
218
+
219
+ it('keeps other failures as before', () => {
220
+ expect(uploadResponseError(500, null).message).toBe('Upload failed (HTTP 500)')
221
+ expect(uploadResponseError(409, { error: 'x exists', error_code: 'file_exists' }).code).toBe('file_exists')
222
+ })
223
+ })