Skip to content

Commit a095deb

Browse files
fix(ui): resolve module resolution and TypeScript errors
Co-Authored-By: Dan Lynch <[email protected]>
1 parent c3df93d commit a095deb

File tree

4 files changed

+50
-15
lines changed

4 files changed

+50
-15
lines changed

packages/ui/next.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
/** @type {import('next').NextConfig} */
2+
const path = require('path');
3+
24
const nextConfig = {
35
reactStrictMode: true,
46
swcMinify: true,
7+
transpilePackages: ['kubernetesjs'],
8+
webpack: (config) => {
9+
config.resolve.alias = {
10+
...config.resolve.alias,
11+
kubernetesjs: path.resolve(__dirname, '../../kubernetesjs')
12+
};
13+
return config;
14+
},
515
}
616

717
module.exports = nextConfig

packages/ui/src/components/namespace-selector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function NamespaceSelector() {
3232
query: {}
3333
});
3434

35-
const namespaceNames = response.items?.map(ns => ns.metadata.name) || [];
35+
const namespaceNames = response.items?.map((ns: any) => ns.metadata.name) || [];
3636
setNamespaces(namespaceNames);
3737
} catch (error) {
3838
console.error("Failed to fetch namespaces:", error);
@@ -67,7 +67,7 @@ export function NamespaceSelector() {
6767
<CommandItem
6868
key={ns}
6969
value={ns}
70-
onSelect={(currentValue) => {
70+
onSelect={(currentValue: string) => {
7171
setNamespace(currentValue);
7272
setOpen(false);
7373
}}

packages/ui/src/hooks/use-kubernetes.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

3-
import { useState, useEffect, createContext, useContext } from "react";
4-
import { KubernetesClient } from "kubernetesjs";
3+
import React, { useState, useEffect, createContext, useContext } from "react";
4+
import type { KubernetesClient } from "kubernetesjs";
55
import { getKubernetesClient, getCurrentNamespace } from "@/lib/kubernetes";
66

77
interface KubernetesContextType {
@@ -15,9 +15,9 @@ interface KubernetesContextType {
1515
const KubernetesContext = createContext<KubernetesContextType | undefined>(undefined);
1616

1717
export function KubernetesProvider({ children }: { children: React.ReactNode }) {
18-
const [client] = useState<KubernetesClient>(() => getKubernetesClient());
19-
const [namespace, setNamespace] = useState<string>(getCurrentNamespace());
20-
const [isConnected, setIsConnected] = useState<boolean>(false);
18+
const [client] = useState(() => getKubernetesClient());
19+
const [namespace, setNamespace] = useState(getCurrentNamespace());
20+
const [isConnected, setIsConnected] = useState(false);
2121
const [error, setError] = useState<string | null>(null);
2222

2323
useEffect(() => {
@@ -35,18 +35,18 @@ export function KubernetesProvider({ children }: { children: React.ReactNode })
3535
checkConnection();
3636
}, [client]);
3737

38-
return (
39-
<KubernetesContext.Provider
40-
value={{
38+
return React.createElement(
39+
KubernetesContext.Provider,
40+
{
41+
value: {
4142
client,
4243
namespace,
4344
setNamespace,
4445
isConnected,
45-
error,
46-
}}
47-
>
48-
{children}
49-
</KubernetesContext.Provider>
46+
error
47+
}
48+
},
49+
children
5050
);
5151
}
5252

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
declare module 'kubernetesjs' {
2+
export interface KubernetesClient {
3+
getCoreV1APIResources(options: any): Promise<any>;
4+
listCoreV1Namespace(options: any): Promise<any>;
5+
listCoreV1NamespacedPod(options: any): Promise<any>;
6+
listAppsV1NamespacedDeployment(options: any): Promise<any>;
7+
listCoreV1NamespacedService(options: any): Promise<any>;
8+
readNamespacedPodLog(options: any): Promise<any>;
9+
createAppsV1NamespacedDeployment(options: any): Promise<any>;
10+
createCoreV1NamespacedService(options: any): Promise<any>;
11+
patchNamespacedDeployment(options: any): Promise<any>;
12+
deleteNamespacedPod(options: any): Promise<any>;
13+
deleteNamespacedDeployment(options: any): Promise<any>;
14+
deleteNamespacedService(options: any): Promise<any>;
15+
}
16+
17+
export interface KubernetesClientOptions {
18+
basePath?: string;
19+
restEndpoint?: string;
20+
}
21+
22+
export class KubernetesClient {
23+
constructor(options?: KubernetesClientOptions);
24+
}
25+
}

0 commit comments

Comments
 (0)