Skip to content

Commit 0a04992

Browse files
authored
fix(kiali): show username when auth is anonymous (#1139)
* fix(kiali): show username when auth is anonymous * Fix render first time metrics * Align toolbar * Align kiali head
1 parent 48b2958 commit 0a04992

File tree

3 files changed

+27
-38
lines changed

3 files changed

+27
-38
lines changed

plugins/kiali/src/pages/Kiali/Header/Header.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const KialiHeader = (props: { title: string }) => {
4242

4343
const title = props.title.charAt(0).toUpperCase() + props.title.slice(1);
4444
return (
45-
<>
45+
<div style={{ marginLeft: '20px' }}>
4646
<Select
4747
label="Namespaces Selected"
4848
placeholder="Select namespaces"
@@ -65,8 +65,9 @@ export const KialiHeader = (props: { title: string }) => {
6565

6666
<ContentHeader title={title}>
6767
<Grid container spacing={1}>
68+
<Grid item xs={homeCluster ? 2 : 3} />
6869
{homeCluster && (
69-
<Grid item>
70+
<Grid item xs={3}>
7071
<Tooltip
7172
title={<div>Kiali home cluster: {homeCluster?.name}</div>}
7273
>
@@ -78,12 +79,12 @@ export const KialiHeader = (props: { title: string }) => {
7879
</Tooltip>
7980
</Grid>
8081
)}
81-
<Grid item>
82-
<Button onClick={handleClick}>
82+
<Grid item xs={1}>
83+
<Button onClick={handleClick} style={{ marginTop: '5px' }}>
8384
<QuestionCircleIcon />
8485
</Button>
8586
</Grid>
86-
<Grid item>
87+
<Grid item xs={1}>
8788
<MessageCenter />
8889
</Grid>
8990
<Grid item>
@@ -94,8 +95,8 @@ export const KialiHeader = (props: { title: string }) => {
9495
<MenuItem onClick={openAbout}>About</MenuItem>
9596
</Menu>
9697
</Grid>
97-
<Grid item>
98-
{kialiState.authentication.session && (
98+
{kialiState.authentication.session && (
99+
<Grid item>
99100
<div
100101
style={{
101102
display: 'flex',
@@ -105,11 +106,11 @@ export const KialiHeader = (props: { title: string }) => {
105106
>
106107
<span style={{ margin: '10px' }}>
107108
<b>User : </b>
108-
{kialiState.authentication.session.username}
109+
{kialiState.authentication.session.username || 'anonymous'}
109110
</span>
110111
</div>
111-
)}
112-
</Grid>
112+
</Grid>
113+
)}
113114
</Grid>
114115
</ContentHeader>
115116
<AboutUIModal
@@ -124,6 +125,6 @@ export const KialiHeader = (props: { title: string }) => {
124125
showDebug={showDebug}
125126
setShowDebug={setShowDebug}
126127
/>
127-
</>
128+
</div>
128129
);
129130
};

plugins/kiali/src/pages/Overview/OverviewPage.tsx

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { useAsyncFn, useDebounce } from 'react-use';
32

43
import { Content, Page } from '@backstage/core-components';
54
import { useApi } from '@backstage/core-plugin-api';
@@ -78,7 +77,7 @@ export const OverviewPage = () => {
7877
return nss;
7978
};
8079

81-
const fetchHealthChunk = (chunk: NamespaceInfo[]): Promise<void> => {
80+
const fetchHealthChunk = async (chunk: NamespaceInfo[]): Promise<void> => {
8281
const apiFunc = switchType(
8382
overviewType,
8483
kialiClient.getNamespaceAppHealth,
@@ -87,7 +86,7 @@ export const OverviewPage = () => {
8786
);
8887

8988
return Promise.all(
90-
chunk.map(nsInfo => {
89+
chunk.map(async nsInfo => {
9190
const healthPromise: Promise<
9291
NamespaceAppHealth | NamespaceWorkloadHealth | NamespaceServiceHealth
9392
> = apiFunc(nsInfo.name, duration, nsInfo.cluster);
@@ -161,9 +160,9 @@ export const OverviewPage = () => {
161160
});
162161
};
163162

164-
const fetchTLSChunk = (chunk: NamespaceInfo[]): Promise<void> => {
163+
const fetchTLSChunk = async (chunk: NamespaceInfo[]): Promise<void> => {
165164
return Promise.all(
166-
chunk.map(nsInfo => {
165+
chunk.map(async nsInfo => {
167166
return kialiClient
168167
.getNamespaceTls(nsInfo.name, nsInfo.cluster)
169168
.then(rs => ({ status: rs, nsInfo: nsInfo }));
@@ -226,7 +225,7 @@ export const OverviewPage = () => {
226225
});
227226
};
228227

229-
const fetchCanariesStatus = async () =>
228+
const fetchCanariesStatus = () =>
230229
kialiClient
231230
.getCanaryUpgradeStatus()
232231
.then(response => {
@@ -260,7 +259,7 @@ export const OverviewPage = () => {
260259
});
261260
};
262261

263-
const fetchValidationResultForCluster = (
262+
const fetchValidationResultForCluster = async (
264263
nss: NamespaceInfo[],
265264
cluster: string,
266265
) => {
@@ -377,7 +376,7 @@ export const OverviewPage = () => {
377376
};
378377

379378
const load = async () => {
380-
kialiClient.getNamespaces().then(namespacesResponse => {
379+
await kialiClient.getNamespaces().then(namespacesResponse => {
381380
const allNamespaces: NamespaceInfo[] = namespacesResponse.map(ns => {
382381
const previous = namespaces.find(prev => prev.name === ns.name);
383382
return {
@@ -405,31 +404,20 @@ export const OverviewPage = () => {
405404
fetchTLS(sortNs, isAscending, sortField);
406405
fetchValidations(sortNs, isAscending, sortField);
407406
fetchMetrics(sortNs);
408-
409407
fetchOutboundTrafficPolicyMode();
410408
fetchCanariesStatus();
411409
fetchIstiodResourceThresholds();
412-
410+
promises.waitAll();
413411
setNamespaces(sortNs);
414412
});
415413
};
416414

417-
const [{ loading }, refresh] = useAsyncFn(
418-
async () => {
419-
// Check if the config is loaded
420-
await load();
421-
},
422-
[],
423-
{ loading: true },
424-
);
425-
useDebounce(refresh, 10);
426-
427415
React.useEffect(() => {
428416
load();
429417
// eslint-disable-next-line react-hooks/exhaustive-deps
430418
}, [duration, overviewType, directionType]);
431419

432-
if (loading) {
420+
if (namespaces.length === 0) {
433421
return <CircularProgress />;
434422
}
435423

plugins/kiali/src/pages/Overview/OverviewToolbar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,34 +100,34 @@ export const OverviewToolbar = (props: OverviewToolbarProps) => {
100100
};
101101

102102
return (
103-
<Grid container spacing={3} direction="row">
104-
<Grid item xs={3}>
103+
<Grid container spacing={1} direction="row">
104+
<Grid item xs={1}>
105105
<Select
106106
onChange={e => updateOverviewType(e as String)}
107107
label="Health for"
108108
items={healthTypeItems}
109109
selected={props.overviewType}
110110
/>
111111
</Grid>
112-
<Grid item xs={3}>
112+
<Grid item xs={1}>
113113
<Select
114114
onChange={e => updateDirectionType(e as String)}
115115
label="Traffic"
116116
items={directionTypeItems}
117117
selected={props.directionType}
118118
/>
119119
</Grid>
120-
<Grid item xs={3}>
120+
<Grid item xs={1}>
121121
<Select
122122
onChange={e => updateDurationType(e as number)}
123123
label="Metrics from"
124124
items={getDurationType()}
125125
selected={props.duration.toString()}
126126
/>
127127
</Grid>
128-
<Grid item xs={2} />
128+
<Grid item xs={8} />
129129
<Grid item xs={1}>
130-
<Tooltip title="Refresh" style={{ marginTop: '20px' }}>
130+
<Tooltip title="Refresh" style={{ marginTop: '35px', float: 'right' }}>
131131
<IconButton
132132
color="primary"
133133
aria-label="upload picture"

0 commit comments

Comments
 (0)