Skip to content

Commit 93d62a4

Browse files
authored
fix(kiali): Js error and dependency updates (#8492)
* Update packages dependencies Signed-off-by: josunect <jcordoba@redhat.com> * Update packages Signed-off-by: josunect <jcordoba@redhat.com> * Fix JS error Signed-off-by: josunect <jcordoba@redhat.com> * Update changeset Signed-off-by: josunect <jcordoba@redhat.com> * dedupe Signed-off-by: josunect <jcordoba@redhat.com> * Update deps Signed-off-by: josunect <jcordoba@redhat.com> --------- Signed-off-by: josunect <jcordoba@redhat.com>
1 parent b8aae89 commit 93d62a4

10 files changed

Lines changed: 644 additions & 315 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@backstage-community/plugin-kiali-backend': minor
3+
'@backstage-community/plugin-kiali-common': minor
4+
'@backstage-community/plugin-kiali': minor
5+
---
6+
7+
Fix JS error. Update dependencies

workspaces/kiali/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
},
6060
"resolutions": {
6161
"@types/react": "^18",
62-
"@types/react-dom": "^18"
62+
"@types/react-dom": "^18",
63+
"zod": "^3.25.76"
6364
},
6465
"prettier": "@backstage/cli/config/prettier",
6566
"lint-staged": {

workspaces/kiali/packages/backend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
},
2323
"dependencies": {
2424
"@backstage-community/plugin-kiali-backend": "workspace:^",
25-
"@backstage/backend-defaults": "^0.13.0",
25+
"@backstage/backend-defaults": "^0.16.0",
2626
"@backstage/config": "^1.3.5",
2727
"@backstage/plugin-app-backend": "^0.5.7",
28-
"@backstage/plugin-auth-backend": "^0.25.5",
28+
"@backstage/plugin-auth-backend": "^0.27.1",
2929
"@backstage/plugin-auth-backend-module-github-provider": "^0.3.8",
3030
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.13",
3131
"@backstage/plugin-auth-node": "^0.6.8",

workspaces/kiali/plugins/kiali-backend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
},
4444
"configSchema": "config.d.ts",
4545
"dependencies": {
46-
"@backstage/backend-defaults": "^0.13.0",
47-
"@backstage/backend-plugin-api": "^1.4.4",
46+
"@backstage/backend-defaults": "^0.16.0",
47+
"@backstage/backend-plugin-api": "^1.8.0",
4848
"@backstage/catalog-client": "^1.12.0",
4949
"@backstage/catalog-model": "^1.7.5",
5050
"@backstage/config": "^1.3.5",

workspaces/kiali/plugins/kiali-common/src/utils/IstioConfigUtils.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,28 @@ export function getIstioObjectGVK(
224224
apiVersion?: string,
225225
kind?: string,
226226
): GroupVersionKind {
227-
if (!apiVersion || !kind) {
227+
if (!kind) {
228228
return { Group: '', Version: '', Kind: '' };
229229
}
230+
if (!apiVersion?.trim()) {
231+
return (
232+
dicTypeToGVK[kind as gvkType] ?? {
233+
Group: '',
234+
Version: '',
235+
Kind: kind,
236+
}
237+
);
238+
}
230239
const parts = apiVersion.split('/');
231240
if (parts.length !== 2) {
232241
// should not happen, but not the best way, only an alternative
233-
return dicTypeToGVK[kind as gvkType];
242+
return (
243+
dicTypeToGVK[kind as gvkType] ?? {
244+
Group: '',
245+
Version: '',
246+
Kind: kind,
247+
}
248+
);
234249
}
235250
return { Group: parts[0], Version: parts[1], Kind: kind! };
236251
}

workspaces/kiali/plugins/kiali/src/components/Drawers/IstioConfigDetailsDrawer.tsx

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
import { useApi } from '@backstage/core-plugin-api';
2121
import { CircularProgress } from '@material-ui/core';
2222
import { default as React } from 'react';
23-
import { useAsyncFn, useDebounce } from 'react-use';
2423
import { IstioConfigInfo } from '../../pages/IstioConfigDetails/IstioConfigInfo';
2524
import { kialiApiRef } from '../../services/Api';
2625
import { KialiAppState, KialiContext } from '../../store';
@@ -35,15 +34,25 @@ export const IstioConfigDetailsDrawer = (props: Props) => {
3534
const kialiClient = useApi(kialiApiRef);
3635
const kialiState = React.useContext(KialiContext) as KialiAppState;
3736
const [istioConfig, setIstioConfig] = React.useState<IstioConfigDetails>();
37+
const [loading, setLoading] = React.useState(true);
3838

39-
const fetchIstioConfig = async () => {
39+
React.useEffect(() => {
40+
let cancelled = false;
4041
if (!props.namespace || !props.istioType || !props.name) {
41-
return;
42+
setIstioConfig(undefined);
43+
setLoading(false);
44+
return undefined;
4245
}
4346

47+
setLoading(true);
48+
setIstioConfig(undefined);
49+
4450
kialiClient
4551
.getIstioConfigDetail(props.namespace, props.istioType, props.name, true)
4652
.then((istioConfigResponse: IstioConfigDetails) => {
53+
if (cancelled) {
54+
return;
55+
}
4756
if (
4857
istioConfigResponse &&
4958
Object.keys(istioConfigResponse).length > 0
@@ -52,20 +61,28 @@ export const IstioConfigDetailsDrawer = (props: Props) => {
5261
}
5362
})
5463
.catch(err => {
55-
kialiState.alertUtils!.add(
56-
`Error fetching Istio config: ${err.message || 'Unknown error'}`,
57-
);
64+
if (!cancelled) {
65+
kialiState.alertUtils!.add(
66+
`Error fetching Istio config: ${err.message || 'Unknown error'}`,
67+
);
68+
}
69+
})
70+
.finally(() => {
71+
if (!cancelled) {
72+
setLoading(false);
73+
}
5874
});
59-
};
6075

61-
const [{ loading }, refresh] = useAsyncFn(
62-
async () => {
63-
await fetchIstioConfig();
64-
},
65-
[],
66-
{ loading: true },
67-
);
68-
useDebounce(refresh, 10);
76+
return () => {
77+
cancelled = true;
78+
};
79+
}, [
80+
kialiClient,
81+
kialiState.alertUtils,
82+
props.name,
83+
props.namespace,
84+
props.istioType,
85+
]);
6986

7087
if (loading) {
7188
return <CircularProgress />;

workspaces/kiali/plugins/kiali/src/components/VirtualList/Renderers.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ export const item: Renderer<TResource> = (
207207
cluster={resource.cluster}
208208
objectGVK={
209209
config.name === 'istio'
210-
? getIstioObjectGVK('', (resource as IstioConfigItem).kind)
210+
? getIstioObjectGVK(
211+
(resource as IstioConfigItem).apiVersion,
212+
(resource as IstioConfigItem).kind,
213+
)
211214
: undefined
212215
}
213216
key={key}
@@ -412,9 +415,13 @@ export const istioConfiguration: Renderer<IstioConfigItem> = (
412415
style={{ verticalAlign: 'middle' }}
413416
>
414417
{validation ? (
415-
<Link to="">
418+
<Link
419+
to="#"
420+
onClick={(e: React.MouseEvent) => e.preventDefault()}
421+
style={{ color: 'inherit', textDecoration: 'none' }}
422+
>
416423
<ValidationObjectSummary
417-
id={`${item.name}-config-validation`}
424+
id={`${resource.name}-config-validation`}
418425
validations={[validation]}
419426
reconciledCondition={reconciledCondition}
420427
/>

workspaces/kiali/plugins/kiali/src/pages/IstioConfigDetails/IstioConfigInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const IstioConfigInfo = (istioConfigProps: IstioConfigInfoProps) => {
3434
return (
3535
<Grid container spacing={1} style={{ paddingTop: '20px' }}>
3636
<Grid
37-
key={`Card_${istioConfigProps.istioConfig?.resource.kind}`}
37+
key={`Card_${istioConfigProps.istioConfig?.resource?.kind ?? 'loading'}`}
3838
item
3939
xs={size}
4040
>

workspaces/kiali/plugins/kiali/src/utils/IstioConfigUtils.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,28 @@ export function getIstioObjectGVK(
212212
apiVersion?: string,
213213
kind?: string,
214214
): GroupVersionKind {
215-
if (!apiVersion || !kind) {
215+
if (!kind) {
216216
return { Group: '', Version: '', Kind: '' };
217217
}
218+
if (!apiVersion?.trim()) {
219+
return (
220+
dicTypeToGVK[kind as gvkType] ?? {
221+
Group: '',
222+
Version: '',
223+
Kind: kind,
224+
}
225+
);
226+
}
218227
const parts = apiVersion.split('/');
219228
if (parts.length !== 2) {
220229
// should not happen, but not the best way, only an alternative
221-
return dicTypeToGVK[kind as gvkType];
230+
return (
231+
dicTypeToGVK[kind as gvkType] ?? {
232+
Group: '',
233+
Version: '',
234+
Kind: kind,
235+
}
236+
);
222237
}
223238
return { Group: parts[0], Version: parts[1], Kind: kind! };
224239
}

0 commit comments

Comments
 (0)