Skip to content

Commit 42fb5cc

Browse files
committed
wip
1 parent 4e43c33 commit 42fb5cc

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

packages/kubernetes-dashboard/components/resources/pods.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
XCircle
1818
} from 'lucide-react'
1919
import { type Pod as K8sPod } from 'kubernetesjs'
20-
import { usePods, useDeletePod, usePodLogs } from '@/hooks'
20+
import { usePods, useDeletePod, usePodLogs, useKubernetes } from '@/hooks'
2121

2222
interface Pod {
2323
name: string
@@ -34,6 +34,7 @@ export function PodsView() {
3434
const [selectedPod, setSelectedPod] = useState<Pod | null>(null)
3535

3636
// Use TanStack Query hooks
37+
const { namespace } = useKubernetes()
3738
const { data, isLoading, error, refetch } = usePods()
3839
const deletePodMutation = useDeletePod()
3940

@@ -230,7 +231,7 @@ export function PodsView() {
230231
</div>
231232
) : pods.length === 0 ? (
232233
<div className="flex flex-col items-center justify-center py-8 text-muted-foreground">
233-
<p className="text-sm">No pods found in the default namespace</p>
234+
<p className="text-sm">No pods found {namespace === '_all' ? 'in any namespace' : `in the ${namespace} namespace`}</p>
234235
<Button variant="outline" size="sm" onClick={handleRefresh} className="mt-4">
235236
<RefreshCw className="h-4 w-4 mr-2" />
236237
Refresh

packages/kubernetes-dashboard/components/templates/template-dialog.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import { Input } from '@/components/ui/input'
1414
import { Label } from '@/components/ui/label'
1515
import { Alert, AlertDescription } from '@/components/ui/alert'
1616
import { Loader2, CheckCircle, XCircle } from 'lucide-react'
17-
import { KubernetesClient, type Deployment, type Service } from 'kubernetesjs'
18-
19-
// Create APIClient instance
20-
const k8sClient = new KubernetesClient({ restEndpoint: '/api/k8s' })
17+
import { type Deployment, type Service } from 'kubernetesjs'
18+
import { useKubernetes } from '@/hooks'
2119

2220
interface Template {
2321
id: string
@@ -38,6 +36,7 @@ interface TemplateDialogProps {
3836
}
3937

4038
export function TemplateDialog({ template, open, onOpenChange }: TemplateDialogProps) {
39+
const { client: k8sClient, namespace: contextNamespace } = useKubernetes()
4140

4241
// Deploy template function
4342
const deployTemplate = async (params: {
@@ -138,7 +137,7 @@ export function TemplateDialog({ template, open, onOpenChange }: TemplateDialogP
138137
}
139138
}
140139
const [deploymentName, setDeploymentName] = useState(`${template.id}-deployment`)
141-
const [namespace, setNamespace] = useState('default')
140+
const [namespace, setNamespace] = useState(contextNamespace === '_all' ? 'default' : contextNamespace)
142141
const [isDeploying, setIsDeploying] = useState(false)
143142
const [deploymentStatus, setDeploymentStatus] = useState<'idle' | 'success' | 'error'>('idle')
144143
const [errorMessage, setErrorMessage] = useState('')
@@ -150,7 +149,7 @@ export function TemplateDialog({ template, open, onOpenChange }: TemplateDialogP
150149
useEffect(() => {
151150
if (open) {
152151
setDeploymentName(`${template.id}-deployment`)
153-
setNamespace('default')
152+
setNamespace(contextNamespace === '_all' ? 'default' : contextNamespace)
154153
setDeploymentStatus('idle')
155154
setErrorMessage('')
156155
}

packages/kubernetes-dashboard/hooks/usePods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function usePods(namespace?: string) {
1313
queryKey: [...PODS_KEY, ns],
1414
queryFn: async () => {
1515
if (ns === '_all') {
16-
const result = await client.listCoreV1PodForAllNamespaces({
16+
const result = await client.listPods({
1717
query: {},
1818
})
1919
return result

0 commit comments

Comments
 (0)