@skyhook-io/radar-app 1.17.1 → 1.18.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/README.md +6 -0
- package/package.json +10 -11
- package/src/App.tsx +36 -36
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.gitopsPoll.test.ts +99 -0
- package/src/api/client.helmPreview.test.tsx +48 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAvailability.test.ts +24 -0
- package/src/api/client.ts +396 -105
- package/src/api/client.workloadRuns.test.ts +53 -0
- package/src/api/config.test.ts +23 -1
- package/src/api/config.ts +7 -3
- package/src/api/diagnose.ts +4 -1
- package/src/api/drain-plan.test.ts +70 -40
- package/src/api/policy.ts +5 -5
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +3 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/api/traffic.scope.render.test.tsx +60 -0
- package/src/api/traffic.ts +3 -1
- package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
- package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
- package/src/components/diagnose/InvestigationView.tsx +2 -1
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
- package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +21 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +131 -1
- package/src/components/diagnose/investigationEvidence/types.ts +26 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
- package/src/components/diagnose/investigationState.test.ts +36 -1
- package/src/components/diagnose/investigationState.ts +8 -0
- package/src/components/diagnose/launch.ts +2 -2
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/dock/BottomDock.tsx +6 -3
- package/src/components/dock/WorkloadLogsTab.tsx +3 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
- package/src/components/execution/BatchExecutionView.tsx +28 -11
- package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +69 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +5 -4
- package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
- package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
- package/src/components/helm/HelmReleaseNotes.tsx +26 -0
- package/src/components/helm/OwnedResources.tsx +2 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +295 -50
- package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
- package/src/components/helm/TrackChartSourceDialog.tsx +614 -85
- package/src/components/helm/ValuesDiffPreview.tsx +4 -1
- package/src/components/home/ClusterHealthCard.tsx +4 -4
- package/src/components/home/CostCard.test.tsx +100 -0
- package/src/components/home/CostCard.tsx +2 -2
- package/src/components/home/HelmSummary.tsx +2 -2
- package/src/components/home/HomeView.tsx +15 -6
- package/src/components/home/MCPSetupDialog.test.tsx +30 -0
- package/src/components/home/MCPSetupDialog.tsx +13 -6
- package/src/components/home/ProblemsPanel.test.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +28 -2
- package/src/components/issues/IssuesPane.render.test.tsx +21 -0
- package/src/components/issues/IssuesPane.tsx +31 -7
- package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
- package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
- package/src/components/issues/uncheckedSources.test.ts +43 -0
- package/src/components/issues/uncheckedSources.ts +58 -5
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
- package/src/components/resources/ImageFilesystemModal.tsx +11 -4
- package/src/components/resources/PodFilesystemModal.tsx +2 -2
- package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
- package/src/components/resources/ResourcesView.tsx +46 -69
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/settings/SettingsDialog.tsx +21 -15
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +21 -67
- package/src/components/traffic/trafficFilters.test.ts +20 -1
- package/src/components/traffic/trafficFilters.ts +13 -0
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +89 -14
- package/src/components/ui/RadarOmnibar.test.tsx +183 -0
- package/src/components/ui/RadarOmnibar.tsx +38 -4
- package/src/components/ui/Toast.tsx +1 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +2 -1
- package/src/components/ui/UpdateNotification.tsx +29 -5
- package/src/components/ui/omnibar-match.test.ts +37 -0
- package/src/components/ui/omnibar-match.ts +23 -0
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
- package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
- package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
- package/src/components/workload/NodeDrainStatus.tsx +55 -0
- package/src/components/workload/WorkloadView.tsx +43 -5
- package/src/context/ConnectionContext.test.ts +27 -1
- package/src/context/ConnectionContext.tsx +17 -7
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +2 -4
- package/src/index.ts +7 -0
- package/src/integrations/resourceHosts.test.tsx +1 -0
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
- package/src/utils/navigation.ts +14 -0
- package/src/utils/wails-clipboard.ts +4 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResourceCoverage } from '@skyhook-io/k8s-ui'
|
|
1
2
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
3
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
3
4
|
import { useQuery } from '@tanstack/react-query'
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
formatGitOpsSourceUrl,
|
|
22
23
|
getGitOpsResourceStatus,
|
|
23
24
|
getGitOpsTool,
|
|
25
|
+
gitOpsDetailGroup,
|
|
24
26
|
isDestinationRef,
|
|
25
27
|
isArgoOperationInProgress,
|
|
26
28
|
isArgoSuspendedByRadar,
|
|
@@ -53,7 +55,9 @@ import { useDestinationCluster } from './useDestinationCluster'
|
|
|
53
55
|
import { destinationToast } from './destination-toast'
|
|
54
56
|
|
|
55
57
|
import {
|
|
58
|
+
ApiError,
|
|
56
59
|
fetchJSON,
|
|
60
|
+
fetchResourceList as fetchCoveredResourceList,
|
|
57
61
|
buildArgoResourceSyncVars,
|
|
58
62
|
useApplyResource,
|
|
59
63
|
useArgoRefresh,
|
|
@@ -72,8 +76,8 @@ import {
|
|
|
72
76
|
useResource,
|
|
73
77
|
} from '../../api/client'
|
|
74
78
|
import { useAPIResources, GITOPS_KINDS } from '../../api/apiResources'
|
|
79
|
+
import { combinedListStatus, lowerBound } from '../../api/resourceLists'
|
|
75
80
|
import { useConnection } from '../../context/ConnectionContext'
|
|
76
|
-
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
77
81
|
import { useRegisterShortcut } from '../../hooks/useKeyboardShortcuts'
|
|
78
82
|
import { CodeViewer } from '../ui/CodeViewer'
|
|
79
83
|
import { ArgoResourceDiffLoader } from './ArgoResourceDiffLoader'
|
|
@@ -97,6 +101,7 @@ const GITOPS_ROWS_REFRESH_INTERVAL_MS = 120_000
|
|
|
97
101
|
|
|
98
102
|
interface ResourceCountsResponse {
|
|
99
103
|
counts: Record<string, number>
|
|
104
|
+
coverage?: Record<string, ResourceCoverage>
|
|
100
105
|
forbidden?: string[]
|
|
101
106
|
unavailable?: string[]
|
|
102
107
|
}
|
|
@@ -182,6 +187,19 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
182
187
|
const rowsQuery = useQuery({
|
|
183
188
|
queryKey: ['gitops-rows-main', namespaces, apiResources?.length ?? 0],
|
|
184
189
|
queryFn: async () => {
|
|
190
|
+
const coverage: ResourceCoverage[] = []
|
|
191
|
+
const failures: unknown[] = []
|
|
192
|
+
const fetchResourceList = async (kind: string, group: string, namespacesParam: string): Promise<any[]> => {
|
|
193
|
+
try {
|
|
194
|
+
const result = await fetchCoveredResourceList<any>(kind, { group, namespaces: namespacesParam ? namespacesParam.split(',') : [] })
|
|
195
|
+
coverage.push(result.coverage)
|
|
196
|
+
return result.items
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (error instanceof ApiError && error.status === 401) throw error
|
|
199
|
+
failures.push(error)
|
|
200
|
+
return []
|
|
201
|
+
}
|
|
202
|
+
}
|
|
185
203
|
const hasApplications = hasAPIResource(apiResources, 'applications', 'argoproj.io')
|
|
186
204
|
const hasApplicationSets = hasAPIResource(apiResources, 'applicationsets', 'argoproj.io')
|
|
187
205
|
const hasKustomizations = hasAPIResource(apiResources, 'kustomizations', 'kustomize.toolkit.fluxcd.io')
|
|
@@ -201,13 +219,17 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
201
219
|
hasOCIRepos ? fetchResourceList('ocirepositories', 'source.toolkit.fluxcd.io', '') : Promise.resolve([]),
|
|
202
220
|
hasBuckets ? fetchResourceList('buckets', 'source.toolkit.fluxcd.io', '') : Promise.resolve([]),
|
|
203
221
|
])
|
|
222
|
+
if (coverage.length === 0 && failures.length > 0) throw failures[0]
|
|
204
223
|
const fluxSourceUrls = buildFluxSourceUrlMap([...gitRepos, ...helmRepos, ...ociRepos, ...buckets])
|
|
205
|
-
|
|
224
|
+
// Discovery that finds no row kind is itself a complete answer: nothing
|
|
225
|
+
// was fetched because there is nothing to fetch.
|
|
226
|
+
const rowKindsDiscovered = hasApplications || hasApplicationSets || hasKustomizations || hasHelmReleases
|
|
227
|
+
return { coverageStatus: combinedListStatus(coverage, failures.length > 0, apiResources != null && !rowKindsDiscovered), rows: [
|
|
206
228
|
...applications.map((r) => normalizeArgoApplication(r)),
|
|
207
229
|
...applicationSets.map((r) => normalizeArgoApplicationSet(r)),
|
|
208
230
|
...kustomizations.map((r) => normalizeFluxKustomization(r, fluxSourceUrls)),
|
|
209
231
|
...helmReleases.map((r) => normalizeFluxHelmRelease(r, fluxSourceUrls)),
|
|
210
|
-
]
|
|
232
|
+
] }
|
|
211
233
|
},
|
|
212
234
|
enabled: !apiResourcesLoading,
|
|
213
235
|
staleTime: 30_000,
|
|
@@ -246,7 +268,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
246
268
|
useEffect(() => {
|
|
247
269
|
if (!hasGitOpsRowResource || rowsQuery.error) { setColdRetrying(false); return }
|
|
248
270
|
if (apiResourcesLoading || rowsQuery.isFetching) return
|
|
249
|
-
if ((rowsQuery.data?.length ?? 0) > 0) { setColdRetrying(false); return }
|
|
271
|
+
if ((rowsQuery.data?.rows.length ?? 0) > 0) { setColdRetrying(false); return }
|
|
250
272
|
if (coldRetriesRef.current >= 4) { setColdRetrying(false); return }
|
|
251
273
|
setColdRetrying(true)
|
|
252
274
|
const t = window.setTimeout(() => { coldRetriesRef.current += 1; refetchTable() }, 2000)
|
|
@@ -295,11 +317,13 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
295
317
|
return (
|
|
296
318
|
<>
|
|
297
319
|
<SharedGitOpsTableView
|
|
298
|
-
rows={rowsQuery.data ?? []}
|
|
320
|
+
rows={rowsQuery.data?.rows ?? []}
|
|
321
|
+
coverageStatus={rowsQuery.data?.coverageStatus ?? 'unknown'}
|
|
299
322
|
loading={apiResourcesLoading || countsQuery.isLoading || rowsQuery.isLoading || coldRetrying}
|
|
300
|
-
error={
|
|
323
|
+
error={rowsQuery.error}
|
|
301
324
|
counts={countsQuery.data?.counts ?? {}}
|
|
302
325
|
countsUnavailable={countsQuery.data?.unavailable}
|
|
326
|
+
countsPartial={Object.entries(countsQuery.data?.coverage ?? {}).filter(([, c]) => lowerBound(c)).map(([key]) => key)}
|
|
303
327
|
freshnessSlot={
|
|
304
328
|
<FreshnessControl
|
|
305
329
|
mode="auto"
|
|
@@ -373,20 +397,22 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
373
397
|
const treeQ = useGitOpsTree(kind, namespace, name, group, namespaces)
|
|
374
398
|
const insightsQ = useGitOpsInsights(kind, namespace, name, group, namespaces)
|
|
375
399
|
const switchFlow = useContextSwitchFlow()
|
|
376
|
-
const
|
|
377
|
-
const tool = getGitOpsTool(kind,
|
|
400
|
+
const effectiveGroup = gitOpsDetailGroup(group, resourceQ.data)
|
|
401
|
+
const tool = resourceQ.data ? getGitOpsTool(kind, effectiveGroup) : null
|
|
402
|
+
const isArgoApp = tool === 'argo' && kind === 'applications'
|
|
403
|
+
const status = tool && resourceQ.data ? getGitOpsResourceStatus(kind, resourceQ.data) : null
|
|
378
404
|
// Argo "auto-sync ON" is determined by spec.syncPolicy.automated being set,
|
|
379
405
|
// not by health.status === Suspended (which is Argo's CronJob-style suspend).
|
|
380
406
|
// The toggle button reads from this so the label flips correctly when an
|
|
381
407
|
// app is in Manual mode or suspended via Radar's annotations.
|
|
382
|
-
const argoAutoSyncEnabled =
|
|
408
|
+
const argoAutoSyncEnabled = isArgoApp && Boolean(resourceQ.data?.spec?.syncPolicy?.automated)
|
|
383
409
|
// Radar-driven Argo suspension is signaled by annotations that record the
|
|
384
410
|
// pre-suspend prune/selfHeal state for restoration on resume. When present,
|
|
385
411
|
// the app is in a deliberately-paused state (vs. Manual mode, which is a
|
|
386
412
|
// normal operational choice) and should surface a Suspended chip alongside
|
|
387
413
|
// the other status indicators. Shared with the fleet table's row normalizer
|
|
388
414
|
// (isArgoSuspendedByRadar) so both surfaces agree on what "suspended" means.
|
|
389
|
-
const argoSuspendedByRadar =
|
|
415
|
+
const argoSuspendedByRadar = isArgoApp && isArgoSuspendedByRadar(resourceQ.data)
|
|
390
416
|
const effectiveSuspended = (status?.suspended ?? false) || argoSuspendedByRadar
|
|
391
417
|
// Lifecycle gate: when the resource is pending deletion, mutating
|
|
392
418
|
// actions are futile (the controller is processing finalizers and
|
|
@@ -453,9 +479,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
453
479
|
setSyncDialogTarget(null)
|
|
454
480
|
}
|
|
455
481
|
|
|
456
|
-
const detailRow = resourceQ.data ? normalizeDetailResource(kind,
|
|
482
|
+
const detailRow = tool && resourceQ.data ? normalizeDetailResource(kind, effectiveGroup, tool, resourceQ.data) : null
|
|
457
483
|
const tree = treeQ.data ?? null
|
|
458
|
-
const helmValues = useMemo(() => extractHelmValues(kind, resourceQ.data), [kind, resourceQ.data])
|
|
484
|
+
const helmValues = useMemo(() => (tool ? extractHelmValues(kind, resourceQ.data) : null), [tool, kind, resourceQ.data])
|
|
459
485
|
const graphFilters = useMemo<GitOpsTreeFilters>(() => ({
|
|
460
486
|
kinds: graphKinds,
|
|
461
487
|
sync: graphSync,
|
|
@@ -466,8 +492,8 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
466
492
|
const graphFacets = useMemo(() => buildTreeFacets(tree), [tree])
|
|
467
493
|
// The tree and insights load separately; either one seeing a remote
|
|
468
494
|
// destination is enough to keep its resources from opening here.
|
|
469
|
-
const remoteDestination = !!(tree?.remoteDestination || insightsQ.data?.summary?.remoteDestination)
|
|
470
|
-
const destination = useDestinationCluster(remoteDestination, kind, namespace, name)
|
|
495
|
+
const remoteDestination = tool !== null && !!(tree?.remoteDestination || insightsQ.data?.summary?.remoteDestination)
|
|
496
|
+
const destination = useDestinationCluster(remoteDestination, kind, namespace, name, effectiveGroup)
|
|
471
497
|
|
|
472
498
|
function openResourceFromTree(ref: GitOpsTreeRef | GitOpsInsightRef, node?: GitOpsTreeNode) {
|
|
473
499
|
// Locality comes from the node, not the name: a remote app can deploy a
|
|
@@ -490,6 +516,13 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
490
516
|
})
|
|
491
517
|
return
|
|
492
518
|
}
|
|
519
|
+
if (node?.missing) {
|
|
520
|
+
const nextStep = node.sync === 'Synced'
|
|
521
|
+
? 'Argo reports it as synced. Refresh the application to check its status.'
|
|
522
|
+
: 'Sync the application to create it.'
|
|
523
|
+
showToast(`${ref.kind} ${ref.name} is not present in this cluster. ${nextStep}`, { type: 'info' })
|
|
524
|
+
return
|
|
525
|
+
}
|
|
493
526
|
if (isGitOpsDetailRef(ref) && isValidKubernetesName(ref.name)) {
|
|
494
527
|
const detailKind = kindToPluralWithGroup(ref.kind, ref.group ?? '')
|
|
495
528
|
// The tree's root node is this page's own subject — clicking it must not
|
|
@@ -535,9 +568,11 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
535
568
|
|
|
536
569
|
const isRunning = resourceQ.data?.status?.operationState?.phase === 'Running'
|
|
537
570
|
const operationInProgress = isArgoOperationInProgress(resourceQ.data)
|
|
538
|
-
const isFluxWorkload = kind === 'kustomizations' || kind === 'helmreleases'
|
|
571
|
+
const isFluxWorkload = tool === 'flux' && (kind === 'kustomizations' || kind === 'helmreleases')
|
|
539
572
|
const isFlux = tool === 'flux'
|
|
540
|
-
const
|
|
573
|
+
const notGitOpsError = resourceQ.data && tool === null
|
|
574
|
+
? new Error(notGitOpsMessage(resourceQ.data.kind ?? apiKind?.kind ?? kind, effectiveGroup, namespace, name))
|
|
575
|
+
: null
|
|
541
576
|
|
|
542
577
|
// Detail-page shortcuts. Skip when a modal is already open so a stray "s"
|
|
543
578
|
// in an input field doesn't pop another sync dialog.
|
|
@@ -651,7 +686,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
651
686
|
group,
|
|
652
687
|
namespace,
|
|
653
688
|
name,
|
|
654
|
-
toolLabel: tool === 'argo' ? 'ArgoCD' : 'FluxCD',
|
|
689
|
+
toolLabel: tool === 'argo' ? 'ArgoCD' : tool === 'flux' ? 'FluxCD' : undefined,
|
|
655
690
|
kindLabel: apiKind?.kind ?? kind,
|
|
656
691
|
}}
|
|
657
692
|
parent={parent}
|
|
@@ -659,8 +694,8 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
659
694
|
terminating={terminating}
|
|
660
695
|
terminatingChipTooltip={terminatingChipTooltip}
|
|
661
696
|
terminatingActionTooltip={terminatingActionTooltip}
|
|
662
|
-
detail={detail}
|
|
663
|
-
insight={insightsQ.data ?? null}
|
|
697
|
+
detail={tool ? detail : undefined}
|
|
698
|
+
insight={tool ? insightsQ.data ?? null : null}
|
|
664
699
|
insightLoading={insightsQ.isLoading}
|
|
665
700
|
healthDocsUrl={GITOPS_HEALTH_DOCS_URL}
|
|
666
701
|
remoteDestinationHint={<RemoteDestinationCloudHint />}
|
|
@@ -695,7 +730,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
695
730
|
// Defer the success toast until we know whether the follow-on
|
|
696
731
|
// sync was triggered, so a successful create-namespace + sync
|
|
697
732
|
// failure doesn't yield a misleading "sync triggered" toast.
|
|
698
|
-
if (
|
|
733
|
+
if (isArgoApp) {
|
|
699
734
|
argoSync.mutate(
|
|
700
735
|
{ namespace, name },
|
|
701
736
|
{
|
|
@@ -738,7 +773,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
738
773
|
fullscreen={graphFullscreen}
|
|
739
774
|
onToggleFullscreen={() => setGraphFullscreen(!graphFullscreen)}
|
|
740
775
|
resourceLoading={resourceQ.isLoading}
|
|
741
|
-
resourceError={(resourceQ.error as Error | null) ??
|
|
776
|
+
resourceError={(resourceQ.error as Error | null) ?? notGitOpsError}
|
|
742
777
|
onNavigateRoot={() => navigate('/gitops')}
|
|
743
778
|
onNavigateParent={parent ? () => {
|
|
744
779
|
const params = new URLSearchParams()
|
|
@@ -974,16 +1009,23 @@ function tryParseYaml(value: string): unknown {
|
|
|
974
1009
|
|
|
975
1010
|
|
|
976
1011
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1012
|
+
// notGitOpsMessage matches the tree/insights endpoints' refusal text.
|
|
1013
|
+
function notGitOpsMessage(kind: string, group: string, namespace: string, name: string): string {
|
|
1014
|
+
const kindGroup = group ? `${kind}.${group}` : kind
|
|
1015
|
+
const ref = namespace ? `${namespace}/${name}` : name
|
|
1016
|
+
return `${kindGroup} ${ref} is not a supported Argo CD or Flux resource, so it has no GitOps view`
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
function normalizeDetailResource(kind: string, group: string, tool: 'argo' | 'flux', resource: any): GitOpsRow | null {
|
|
1020
|
+
if (tool === 'argo' && kind === 'applications') return normalizeArgoApplication(resource)
|
|
1021
|
+
if (tool === 'argo' && kind === 'applicationsets') return normalizeArgoApplicationSet(resource)
|
|
1022
|
+
if (tool === 'flux' && kind === 'kustomizations') return normalizeFluxKustomization(resource)
|
|
1023
|
+
if (tool === 'flux' && kind === 'helmreleases') return normalizeFluxHelmRelease(resource)
|
|
982
1024
|
const status = getGitOpsResourceStatus(kind, resource)
|
|
983
1025
|
return {
|
|
984
1026
|
id: `${group}/${kind}/${resource.metadata?.namespace ?? ''}/${resource.metadata?.name ?? ''}`,
|
|
985
1027
|
mode: 'applications',
|
|
986
|
-
tool
|
|
1028
|
+
tool,
|
|
987
1029
|
kindName: kind,
|
|
988
1030
|
kind: resource.kind ?? kind,
|
|
989
1031
|
group,
|
|
@@ -1044,19 +1086,6 @@ function hasAPIResource(resources: APIResource[] | undefined, name: string, grou
|
|
|
1044
1086
|
return (resources ?? []).some((resource) => resource.name === name && resource.group === group)
|
|
1045
1087
|
}
|
|
1046
1088
|
|
|
1047
|
-
async function fetchResourceList(kind: string, group: string, namespacesParam: string): Promise<any[]> {
|
|
1048
|
-
const params = new URLSearchParams()
|
|
1049
|
-
if (namespacesParam) params.set('namespaces', namespacesParam)
|
|
1050
|
-
if (group) params.set('group', group)
|
|
1051
|
-
const res = await fetch(apiUrl(`/resources/${kind}?${params}`), {
|
|
1052
|
-
credentials: getCredentialsMode(),
|
|
1053
|
-
headers: getAuthHeaders(),
|
|
1054
|
-
})
|
|
1055
|
-
if (res.status === 400 || res.status === 403 || res.status === 404) return []
|
|
1056
|
-
if (!res.ok) throw new Error(`Failed to fetch ${kind}: HTTP ${res.status}`)
|
|
1057
|
-
return res.json()
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
1089
|
function isTerminating(resource: any): boolean {
|
|
1061
1090
|
return Boolean(resource?.metadata?.deletionTimestamp)
|
|
1062
1091
|
}
|
|
@@ -17,8 +17,9 @@ export function useDestinationCluster(
|
|
|
17
17
|
kind: string,
|
|
18
18
|
namespace: string,
|
|
19
19
|
name: string,
|
|
20
|
+
group: string,
|
|
20
21
|
): DestinationCluster {
|
|
21
|
-
const destination = useGitOpsDestination(kind, namespace, name, !!remote)
|
|
22
|
+
const destination = useGitOpsDestination(kind, namespace, name, !!remote, group)
|
|
22
23
|
const contexts = useContexts()
|
|
23
24
|
const capabilities = useCapabilities()
|
|
24
25
|
const contextName = destination.data?.contexts[0]
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import type { ArtifactHubChart } from '../../types'
|
|
7
|
+
import { ArtifactHubSourceSearch, artifactHubChartSource } from './ArtifactHubSourceSearch'
|
|
8
|
+
|
|
9
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
10
|
+
|
|
11
|
+
const chart: ArtifactHubChart = { packageId: 'chart', name: 'podinfo', version: '6.15.0', stars: 0, repository: { name: 'podinfo', url: 'https://charts.example.test' } }
|
|
12
|
+
const fetchMock = vi.fn<typeof fetch>()
|
|
13
|
+
const add = vi.fn()
|
|
14
|
+
const configured = vi.fn()
|
|
15
|
+
let root: Root
|
|
16
|
+
let queries: QueryClient
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
fetchMock.mockReset()
|
|
20
|
+
add.mockReset()
|
|
21
|
+
configured.mockReset()
|
|
22
|
+
vi.stubGlobal('fetch', fetchMock)
|
|
23
|
+
queries = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
24
|
+
const container = document.createElement('div')
|
|
25
|
+
document.body.appendChild(container)
|
|
26
|
+
root = createRoot(container)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterEach(async () => {
|
|
30
|
+
await act(async () => root.unmount())
|
|
31
|
+
queries.clear()
|
|
32
|
+
document.body.replaceChildren()
|
|
33
|
+
vi.unstubAllGlobals()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
async function render() {
|
|
37
|
+
await act(async () => root.render(<QueryClientProvider client={queries}><ArtifactHubSourceSearch chartName="podinfo" disabled={false} isConfigured={() => false} onAdd={add} onConfigured={configured} manualAction={<button>Add manually</button>} /></QueryClientProvider>))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function click(text: string) {
|
|
41
|
+
const button = Array.from(document.querySelectorAll('button')).find(button => button.textContent === text)
|
|
42
|
+
expect(button).toBeDefined()
|
|
43
|
+
await act(async () => button?.click())
|
|
44
|
+
await act(async () => { await new Promise(resolve => setTimeout(resolve, 20)) })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
it('sends only the chart name after a click and never downloads or selects a result automatically', async () => {
|
|
48
|
+
fetchMock.mockResolvedValue(new Response(JSON.stringify({ charts: [chart, { ...chart, name: 'another-chart' }], total: 2 })))
|
|
49
|
+
await render()
|
|
50
|
+
expect(fetchMock).not.toHaveBeenCalled()
|
|
51
|
+
expect(document.body.textContent).not.toContain('Add repository')
|
|
52
|
+
await click('Search ArtifactHub')
|
|
53
|
+
expect(fetchMock).toHaveBeenCalledTimes(1)
|
|
54
|
+
const url = new URL(String(fetchMock.mock.calls[0][0]), 'http://localhost')
|
|
55
|
+
expect(url.pathname).toBe('/api/helm/artifacthub/search')
|
|
56
|
+
expect(Object.fromEntries(url.searchParams)).toEqual({ query: 'podinfo', limit: '60' })
|
|
57
|
+
expect(document.querySelectorAll('button[aria-label^="Choose source:"]')).toHaveLength(1)
|
|
58
|
+
expect(add).not.toHaveBeenCalled()
|
|
59
|
+
await click('podinfohttps://charts.example.test')
|
|
60
|
+
await click('Add repository')
|
|
61
|
+
expect(add).toHaveBeenCalledWith(chart, { type: 'repository', url: 'https://charts.example.test' })
|
|
62
|
+
expect(fetchMock).toHaveBeenCalledTimes(1)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('shows failures and allows retry while preserving manual-source guidance', async () => {
|
|
66
|
+
fetchMock.mockRejectedValueOnce(new Error('offline')).mockResolvedValueOnce(new Response(JSON.stringify({ charts: [], total: 0 })))
|
|
67
|
+
await render()
|
|
68
|
+
await click('Search ArtifactHub')
|
|
69
|
+
expect(document.body.textContent).toContain('You can still add a source manually.')
|
|
70
|
+
await click('Retry search')
|
|
71
|
+
expect(document.body.textContent).toContain('No exact chart-name matches on this page.')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('paginates unfiltered search results even when a page has no exact matches', async () => {
|
|
75
|
+
fetchMock.mockResolvedValueOnce(new Response(JSON.stringify({ charts: Array.from({ length: 60 }, () => ({ ...chart, name: 'different' })), total: 60 })))
|
|
76
|
+
.mockResolvedValueOnce(new Response(JSON.stringify({ charts: [chart], total: 1 })))
|
|
77
|
+
await render()
|
|
78
|
+
await click('Search ArtifactHub')
|
|
79
|
+
expect(document.body.textContent).toContain('No exact chart-name matches on this page.')
|
|
80
|
+
await click('Next results')
|
|
81
|
+
expect(String(fetchMock.mock.calls[1][0])).toContain('offset=60')
|
|
82
|
+
expect(document.body.textContent).toContain('Search page 2')
|
|
83
|
+
expect(document.querySelectorAll('button[aria-label^="Choose source:"]')).toHaveLength(1)
|
|
84
|
+
await click('Previous results')
|
|
85
|
+
expect(document.body.textContent).toContain('Search page 1')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('filters unsafe addresses and maps OCI chart references to their parent prefix', () => {
|
|
89
|
+
const source = (url: string) => artifactHubChartSource({ ...chart, repository: { name: 'example', url } }, 'podinfo')
|
|
90
|
+
expect(source('oci://registry.example.test/team/podinfo/')).toEqual({ type: 'oci', url: 'oci://registry.example.test/team/podinfo', prefix: 'oci://registry.example.test/team' })
|
|
91
|
+
expect(source('oci://REGISTRY.example.test/Team/podinfo')).toEqual({ type: 'oci', url: 'oci://registry.example.test/Team/podinfo', prefix: 'oci://registry.example.test/Team' })
|
|
92
|
+
expect(source('https://CHARTS.example.test/Team/')).toEqual({ type: 'repository', url: 'https://charts.example.test/Team' })
|
|
93
|
+
expect(source('https://charts.example.test/team')).toEqual({ type: 'repository', url: 'https://charts.example.test/team' })
|
|
94
|
+
for (const url of ['file:///tmp/chart', 'javascript:alert(1)', 'https://user:password@example.test/charts', 'https://example.test/charts?token=secret', 'https://example.test/#secret', 'oci://registry.example.test/team/other']) {
|
|
95
|
+
expect(source(url)).toBeUndefined()
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it.each([false, true])('keeps one representative publisher, badge and repository name together regardless of response order (%s)', async reverse => {
|
|
100
|
+
const ordinary = { ...chart, packageId: 'ordinary', repository: { ...chart.repository, name: 'ordinary', organizationDisplayName: 'Other Publisher' } }
|
|
101
|
+
const official = { ...chart, packageId: 'official', official: true, repository: { ...chart.repository, name: 'official-charts', displayName: 'Official Charts', organizationDisplayName: 'Publisher Team' } }
|
|
102
|
+
fetchMock.mockResolvedValue(new Response(JSON.stringify({ charts: reverse ? [official, ordinary] : [ordinary, official] })))
|
|
103
|
+
await render()
|
|
104
|
+
await click('Search ArtifactHub')
|
|
105
|
+
expect(document.querySelectorAll('button[aria-label^="Choose source:"]')).toHaveLength(1)
|
|
106
|
+
expect(document.body.textContent).toContain('Publisher Team')
|
|
107
|
+
expect(document.body.textContent).not.toContain('Other Publisher')
|
|
108
|
+
expect(document.body.textContent).toContain('ArtifactHub official package')
|
|
109
|
+
expect(document.body.textContent).not.toContain('ArtifactHub official repository')
|
|
110
|
+
expect(add).not.toHaveBeenCalled()
|
|
111
|
+
await act(async () => document.querySelector<HTMLButtonElement>('button[aria-label^="Choose source:"]')?.click())
|
|
112
|
+
await click('Add repository')
|
|
113
|
+
expect(add).toHaveBeenCalledWith(official, { type: 'repository', url: chart.repository.url })
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it.each([false, true])('uses a stable listing identity when duplicate badges tie (%s)', async reverse => {
|
|
117
|
+
const first = { ...chart, packageId: 'a', repository: { ...chart.repository, name: 'first', userAlias: 'first-account', verifiedPublisher: true } }
|
|
118
|
+
const second = { ...chart, packageId: 'b', repository: { ...chart.repository, name: 'second', userAlias: 'second-account', verifiedPublisher: true } }
|
|
119
|
+
fetchMock.mockResolvedValue(new Response(JSON.stringify({ charts: reverse ? [second, first] : [first, second] })))
|
|
120
|
+
await render()
|
|
121
|
+
await click('Search ArtifactHub')
|
|
122
|
+
expect(document.body.textContent).toContain('first-account')
|
|
123
|
+
expect(document.body.textContent).not.toContain('second-account')
|
|
124
|
+
})
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { useState, type ReactNode } from 'react'
|
|
2
|
+
import { Badge, Input } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useArtifactHubSearch } from '../../api/client'
|
|
4
|
+
import type { ArtifactHubChart } from '../../types'
|
|
5
|
+
import { artifactHubPublisher, isArtifactHubOfficial } from '../../utils/artifacthub'
|
|
6
|
+
|
|
7
|
+
export type PublicChartSource = { type: 'repository'; url: string } | { type: 'oci'; url: string; prefix: string }
|
|
8
|
+
|
|
9
|
+
export function publicChartSourceURL(raw: string): string | undefined {
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(raw)
|
|
12
|
+
if (
|
|
13
|
+
!['http:', 'https:', 'oci:'].includes(url.protocol) ||
|
|
14
|
+
!url.hostname ||
|
|
15
|
+
url.username ||
|
|
16
|
+
url.password ||
|
|
17
|
+
url.search ||
|
|
18
|
+
url.hash
|
|
19
|
+
)
|
|
20
|
+
return
|
|
21
|
+
url.hostname = url.hostname.toLowerCase()
|
|
22
|
+
return url.toString().replace(/\/+$/, '')
|
|
23
|
+
} catch {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function artifactHubChartSource(chart: ArtifactHubChart, chartName: string): PublicChartSource | undefined {
|
|
29
|
+
if (chart.name !== chartName) return
|
|
30
|
+
const address = publicChartSourceURL(chart.repository.url)
|
|
31
|
+
if (!address) return
|
|
32
|
+
if (!address.startsWith('oci://')) return { type: 'repository', url: address }
|
|
33
|
+
if (address.endsWith(`/${chartName}`))
|
|
34
|
+
return { type: 'oci', url: address, prefix: address.slice(0, -(chartName.length + 1)) }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ArtifactHubSourceSearchProps {
|
|
38
|
+
chartName: string
|
|
39
|
+
disabled: boolean
|
|
40
|
+
isConfigured: (source: PublicChartSource) => boolean
|
|
41
|
+
onAdd: (chart: ArtifactHubChart, source: PublicChartSource) => void
|
|
42
|
+
onConfigured: (source: PublicChartSource) => void
|
|
43
|
+
manualAction: ReactNode
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const PAGE_SIZE = 60
|
|
47
|
+
|
|
48
|
+
function listingPriority(chart: ArtifactHubChart) {
|
|
49
|
+
return Number(isArtifactHubOfficial(chart)) * 2 + Number(Boolean(chart.repository.verifiedPublisher))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function listingKey(chart: ArtifactHubChart) {
|
|
53
|
+
return JSON.stringify([
|
|
54
|
+
chart.packageId,
|
|
55
|
+
chart.repository.organizationName,
|
|
56
|
+
chart.repository.userAlias,
|
|
57
|
+
chart.repository.name,
|
|
58
|
+
chart.repository.organizationDisplayName,
|
|
59
|
+
chart.repository.displayName,
|
|
60
|
+
chart.version,
|
|
61
|
+
])
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function ArtifactHubSourceSearch({
|
|
65
|
+
chartName,
|
|
66
|
+
disabled,
|
|
67
|
+
isConfigured,
|
|
68
|
+
onAdd,
|
|
69
|
+
onConfigured,
|
|
70
|
+
manualAction,
|
|
71
|
+
}: ArtifactHubSourceSearchProps) {
|
|
72
|
+
const [started, setStarted] = useState(false)
|
|
73
|
+
const [offset, setOffset] = useState(0)
|
|
74
|
+
const [selectedURL, setSelectedURL] = useState('')
|
|
75
|
+
const [filter, setFilter] = useState('')
|
|
76
|
+
const search = useArtifactHubSearch(chartName, { offset, limit: PAGE_SIZE }, started)
|
|
77
|
+
const listings = new Map<string, { chart: ArtifactHubChart; source: PublicChartSource }>()
|
|
78
|
+
for (const chart of search.data?.charts ?? []) {
|
|
79
|
+
const source = artifactHubChartSource(chart, chartName)
|
|
80
|
+
if (!source) continue
|
|
81
|
+
const current = listings.get(source.url)
|
|
82
|
+
if (
|
|
83
|
+
!current ||
|
|
84
|
+
listingPriority(chart) > listingPriority(current.chart) ||
|
|
85
|
+
(listingPriority(chart) === listingPriority(current.chart) && listingKey(chart) < listingKey(current.chart))
|
|
86
|
+
) {
|
|
87
|
+
listings.set(source.url, { chart, source })
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const matches = [...listings.values()]
|
|
91
|
+
|
|
92
|
+
const selected = matches.find((item) => item.source.url === selectedURL)
|
|
93
|
+
const filtered = matches.filter(({ chart, source }) =>
|
|
94
|
+
`${chart.repository.name} ${chart.repository.displayName ?? ''} ${artifactHubPublisher(chart.repository)} ${chart.repository.organizationName ?? ''} ${chart.repository.userAlias ?? ''} ${source.url}`
|
|
95
|
+
.toLowerCase()
|
|
96
|
+
.includes(filter.trim().toLowerCase()),
|
|
97
|
+
)
|
|
98
|
+
const changePage = (nextOffset: number) => {
|
|
99
|
+
setOffset(nextOffset)
|
|
100
|
+
setSelectedURL('')
|
|
101
|
+
setFilter('')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<section className="flex flex-col flex-1 min-h-0" aria-label="Public chart sources">
|
|
106
|
+
{!started ? (
|
|
107
|
+
<div className="flex-1 flex flex-col items-center justify-center gap-3 p-6 text-center">
|
|
108
|
+
<p className="text-sm text-theme-text-secondary">
|
|
109
|
+
Find public repositories for <span className="font-medium text-theme-text-primary">{chartName}</span>.
|
|
110
|
+
</p>
|
|
111
|
+
<button type="button" onClick={() => setStarted(true)} className="btn-brand px-3 py-2 text-sm">
|
|
112
|
+
Search ArtifactHub
|
|
113
|
+
</button>
|
|
114
|
+
<p className="text-xs text-theme-text-tertiary">Only the chart name is sent.</p>
|
|
115
|
+
</div>
|
|
116
|
+
) : (
|
|
117
|
+
<>
|
|
118
|
+
<div className="shrink-0 px-4 py-3 border-b border-theme-border space-y-2" aria-live="polite">
|
|
119
|
+
<p className="text-xs text-theme-text-secondary">
|
|
120
|
+
Matching names and ArtifactHub badges do not prove where this release was installed from.
|
|
121
|
+
</p>
|
|
122
|
+
{matches.length > 6 && (
|
|
123
|
+
<Input
|
|
124
|
+
aria-label="Filter public sources on this page"
|
|
125
|
+
value={filter}
|
|
126
|
+
onChange={(event) => {
|
|
127
|
+
setFilter(event.target.value)
|
|
128
|
+
setSelectedURL('')
|
|
129
|
+
}}
|
|
130
|
+
placeholder="Filter this page by publisher or address"
|
|
131
|
+
className="w-full"
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
{search.isFetching && <p className="text-xs text-theme-text-secondary">Searching ArtifactHub...</p>}
|
|
135
|
+
{search.error && (
|
|
136
|
+
<div role="alert" className="text-sm text-theme-text-secondary">
|
|
137
|
+
<p>Could not search ArtifactHub. You can still add a source manually.</p>
|
|
138
|
+
<button
|
|
139
|
+
type="button"
|
|
140
|
+
onClick={() => void search.refetch()}
|
|
141
|
+
disabled={search.isFetching}
|
|
142
|
+
className="text-accent hover:underline disabled:opacity-50"
|
|
143
|
+
>
|
|
144
|
+
Retry search
|
|
145
|
+
</button>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
<div className="flex-1 min-h-0 overflow-y-auto" aria-label="Public source results">
|
|
150
|
+
{!search.isFetching && !search.error && search.data && filtered.length === 0 && (
|
|
151
|
+
<p className="p-4 text-sm text-theme-text-secondary">
|
|
152
|
+
{filter
|
|
153
|
+
? 'No matching sources on this page.'
|
|
154
|
+
: 'No exact chart-name matches on this page. Try another page or add a source manually.'}
|
|
155
|
+
</p>
|
|
156
|
+
)}
|
|
157
|
+
{filtered.map(({ chart, source }) => (
|
|
158
|
+
<button
|
|
159
|
+
key={source.url}
|
|
160
|
+
type="button"
|
|
161
|
+
aria-label={`Choose source: ${source.url}`}
|
|
162
|
+
aria-pressed={selectedURL === source.url}
|
|
163
|
+
onClick={() => setSelectedURL(source.url)}
|
|
164
|
+
className={`w-full text-left px-4 py-3 border-b border-theme-border hover:bg-theme-hover ${selectedURL === source.url ? 'bg-theme-active' : ''}`}
|
|
165
|
+
>
|
|
166
|
+
<span className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
|
167
|
+
<span className="text-sm font-medium">{chart.repository.displayName || chart.repository.name}</span>
|
|
168
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
169
|
+
{artifactHubPublisher(chart.repository) !==
|
|
170
|
+
(chart.repository.displayName || chart.repository.name) && artifactHubPublisher(chart.repository)}
|
|
171
|
+
</span>
|
|
172
|
+
{isConfigured(source) && (
|
|
173
|
+
<Badge tone="note" size="sm">
|
|
174
|
+
Configured
|
|
175
|
+
</Badge>
|
|
176
|
+
)}
|
|
177
|
+
{isArtifactHubOfficial(chart) && (
|
|
178
|
+
<Badge tone="note" size="sm">
|
|
179
|
+
{chart.official ? 'ArtifactHub official package' : 'ArtifactHub official repository'}
|
|
180
|
+
</Badge>
|
|
181
|
+
)}
|
|
182
|
+
{chart.repository.verifiedPublisher && (
|
|
183
|
+
<Badge tone="note" size="sm">
|
|
184
|
+
ArtifactHub verified publisher
|
|
185
|
+
</Badge>
|
|
186
|
+
)}
|
|
187
|
+
</span>
|
|
188
|
+
<span className="block font-mono text-xs text-theme-text-secondary break-all mt-1">{source.url}</span>
|
|
189
|
+
</button>
|
|
190
|
+
))}
|
|
191
|
+
</div>
|
|
192
|
+
{search.data && (
|
|
193
|
+
<div className="shrink-0 flex items-center justify-between gap-3 px-4 py-2 border-t border-theme-border text-xs">
|
|
194
|
+
<button
|
|
195
|
+
type="button"
|
|
196
|
+
onClick={() => changePage(offset - PAGE_SIZE)}
|
|
197
|
+
disabled={offset === 0 || search.isFetching}
|
|
198
|
+
className="text-accent hover:underline disabled:opacity-50"
|
|
199
|
+
>
|
|
200
|
+
Previous results
|
|
201
|
+
</button>
|
|
202
|
+
<span className="text-theme-text-tertiary">Search page {offset / PAGE_SIZE + 1}</span>
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
onClick={() => changePage(offset + PAGE_SIZE)}
|
|
206
|
+
disabled={search.data.charts.length < PAGE_SIZE || search.isFetching}
|
|
207
|
+
className="text-accent hover:underline disabled:opacity-50"
|
|
208
|
+
>
|
|
209
|
+
Next results
|
|
210
|
+
</button>
|
|
211
|
+
</div>
|
|
212
|
+
)}
|
|
213
|
+
</>
|
|
214
|
+
)}
|
|
215
|
+
<div className="shrink-0 flex items-center justify-between gap-3 px-4 py-3 border-t border-theme-border">
|
|
216
|
+
{manualAction}
|
|
217
|
+
{started && (
|
|
218
|
+
<button
|
|
219
|
+
type="button"
|
|
220
|
+
disabled={
|
|
221
|
+
!selected || search.isFetching || Boolean(search.error) || (!isConfigured(selected.source) && disabled)
|
|
222
|
+
}
|
|
223
|
+
onClick={() => {
|
|
224
|
+
if (!selected) return
|
|
225
|
+
if (isConfigured(selected.source)) onConfigured(selected.source)
|
|
226
|
+
else onAdd(selected.chart, selected.source)
|
|
227
|
+
}}
|
|
228
|
+
className="btn-brand px-3 py-2 text-sm disabled:opacity-50"
|
|
229
|
+
>
|
|
230
|
+
{selected && isConfigured(selected.source)
|
|
231
|
+
? 'Show in My Repos'
|
|
232
|
+
: selected?.source.type === 'oci'
|
|
233
|
+
? 'Register OCI source'
|
|
234
|
+
: 'Add repository'}
|
|
235
|
+
</button>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
</section>
|
|
239
|
+
)
|
|
240
|
+
}
|