Skip to content

Commit e9270e2

Browse files
authored
Merge pull request #3960 from sniok/add-backend-loading-indicator
frontend: Layout: Add loader for backend connection
2 parents 4dcaddd + a7fbe93 commit e9270e2

File tree

14 files changed

+80
-16
lines changed

14 files changed

+80
-16
lines changed

frontend/src/App.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ test('renders without crashing', async () => {
2525
</React.Suspense>
2626
);
2727
await waitFor(() => {
28-
expect(getByText(/Skip to main content/i)).toBeInTheDocument();
28+
expect(getByText(/Connecting/i)).toBeInTheDocument();
2929
});
3030
});

frontend/src/components/App/Layout.tsx

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { Typography } from '@mui/material';
1718
import Box from '@mui/material/Box';
1819
import Button from '@mui/material/Button';
1920
import Container from '@mui/material/Container';
@@ -23,7 +24,7 @@ import { styled } from '@mui/material/styles';
2324
import { Dispatch, UnknownAction } from '@reduxjs/toolkit';
2425
import { useQuery } from '@tanstack/react-query';
2526
import { useEffect } from 'react';
26-
import { useTranslation } from 'react-i18next';
27+
import { Trans, useTranslation } from 'react-i18next';
2728
import { useDispatch } from 'react-redux';
2829
import { getCluster } from '../../lib/cluster';
2930
import { getSelectedClusters } from '../../lib/cluster';
@@ -37,6 +38,7 @@ import store from '../../redux/stores/store';
3738
import { useUIPanelsGroupedBySide } from '../../redux/uiSlice';
3839
import { fetchStatelessClusterKubeConfigs, isEqualClusterConfigs } from '../../stateless/';
3940
import { ActivitiesRenderer } from '../activity/Activity';
41+
import { ErrorPage, Loader } from '../common';
4042
import ActionsNotifier from '../common/ActionsNotifier';
4143
import AlertNotification from '../common/AlertNotification';
4244
import DetailsDrawer from '../common/Resource/DetailsDrawer';
@@ -190,10 +192,14 @@ export default function Layout({}: LayoutProps) {
190192
* indexDB and then sends the backend to parse it and then updates the parsed value into redux
191193
* store on an interval.
192194
* */
193-
useQuery({
195+
const {
196+
data: config,
197+
isLoading,
198+
error,
199+
} = useQuery({
194200
queryKey: ['cluster-fetch'],
195201
queryFn: () => fetchConfig(dispatch),
196-
refetchInterval: CLUSTER_FETCH_INTERVAL,
202+
refetchInterval: query => (query.state.status === 'error' ? false : CLUSTER_FETCH_INTERVAL),
197203
});
198204

199205
// Remove splash screen styles from the body
@@ -214,6 +220,40 @@ export default function Layout({}: LayoutProps) {
214220

215221
const panels = useUIPanelsGroupedBySide();
216222

223+
if (error && !config) {
224+
return <ErrorPage message={<Trans>Failed to connect to the backend</Trans>} error={error} />;
225+
}
226+
227+
if (isLoading) {
228+
return (
229+
<Box
230+
sx={{
231+
position: 'fixed',
232+
top: 0,
233+
left: 0,
234+
width: '100dvw',
235+
height: '100dvh',
236+
display: 'flex',
237+
alignItems: 'center',
238+
justifyContent: 'center',
239+
gap: 2,
240+
animation: 'loader-appear',
241+
animationFillMode: 'both',
242+
animationDelay: '2s',
243+
animationDuration: '0.3s',
244+
245+
'@keyframes loader-appear': {
246+
from: { opacity: 0 },
247+
to: { opacity: 1 },
248+
},
249+
}}
250+
>
251+
<Loader title={t('Connecting to backend...')} />
252+
<Typography>{t('Connecting to backend...')}</Typography>
253+
</Box>
254+
);
255+
}
256+
217257
return (
218258
<>
219259
<Link

frontend/src/i18n/locales/de/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "Cluster laden",
7070
"Something went wrong with cluster {{ cluster }}": "Mit dem Cluster ist etwas schief gelaufen {{ cluster }}",
7171
"Choose another cluster": "Wählen Sie einen anderen Cluster",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "Zum Hauptinhalt springen",
7375
"Menu": "",
7476
"Mark all as read": "Alle als gelesen markieren",
@@ -322,6 +324,7 @@
322324
"Init Containers": "Init-Container",
323325
"Conditions": "Bedingungen",
324326
"Volumes": "Speicher-Volumes",
327+
"Kind": "",
325328
"Restarting {{ itemName }}…": "Starte {{ itemName }} neu…",
326329
"Cancelled restarting {{ itemName }}.": "Der Neustart von {{ itemName }} wurde abgebrochen.",
327330
"Restarted {{ itemName }}.": "{{ itemName }} neu gestartet.",
@@ -438,7 +441,6 @@
438441
"ParentRefs": "",
439442
"No rules data to be shown.": "Keine Regeldaten vorhanden.",
440443
"Namespace": "",
441-
"Kind": "",
442444
"Section Name": "",
443445
"Press<1>/</1>to search": "",
444446
"Search resources, pages, clusters by name": "",

frontend/src/i18n/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "Load cluster",
7070
"Something went wrong with cluster {{ cluster }}": "Something went wrong with cluster {{ cluster }}",
7171
"Choose another cluster": "Choose another cluster",
72+
"Failed to connect to the backend": "Failed to connect to the backend",
73+
"Connecting to backend...": "Connecting to backend...",
7274
"Skip to main content": "Skip to main content",
7375
"Menu": "Menu",
7476
"Mark all as read": "Mark all as read",
@@ -322,6 +324,7 @@
322324
"Init Containers": "Init Containers",
323325
"Conditions": "Conditions",
324326
"Volumes": "Volumes",
327+
"Kind": "Kind",
325328
"Restarting {{ itemName }}…": "Restarting {{ itemName }}…",
326329
"Cancelled restarting {{ itemName }}.": "Cancelled restarting {{ itemName }}.",
327330
"Restarted {{ itemName }}.": "Restarted {{ itemName }}.",
@@ -438,7 +441,6 @@
438441
"ParentRefs": "ParentRefs",
439442
"No rules data to be shown.": "No rules data to be shown.",
440443
"Namespace": "Namespace",
441-
"Kind": "Kind",
442444
"Section Name": "Section Name",
443445
"Press<1>/</1>to search": "Press<1>/</1>to search",
444446
"Search resources, pages, clusters by name": "Search resources, pages, clusters by name",

frontend/src/i18n/locales/es/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "Cargar cluster",
7070
"Something went wrong with cluster {{ cluster }}": "Algo ha fallado en el cluster {{ cluster }}",
7171
"Choose another cluster": "Elegir un otro cluster",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "Avanzar hacia el contenido principal",
7375
"Menu": "",
7476
"Mark all as read": "Marcar todo como leído",
@@ -324,6 +326,7 @@
324326
"Init Containers": "Contenedores de Inicialización",
325327
"Conditions": "Condiciones",
326328
"Volumes": "Volumenes",
329+
"Kind": "Tipo",
327330
"Restarting {{ itemName }}…": "Reiniciando {{ itemName }}…",
328331
"Cancelled restarting {{ itemName }}.": "Se ha cancelado el reinicio de {{ itemName }}.",
329332
"Restarted {{ itemName }}.": "Se ha reiniciado {{ itemName }}.",
@@ -441,7 +444,6 @@
441444
"ParentRefs": "Referencias Padre",
442445
"No rules data to be shown.": "Sin datos de reglas",
443446
"Namespace": "Namespace",
444-
"Kind": "Tipo",
445447
"Section Name": "Nombre de sección",
446448
"Press<1>/</1>to search": "Presione<1>/</1>para buscar",
447449
"Search resources, pages, clusters by name": "Buscar recursos, páginas, clusters por nombre",

frontend/src/i18n/locales/fr/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "Charger cluster",
7070
"Something went wrong with cluster {{ cluster }}": "Quelque chose s'est mal passé avec le cluster {{ cluster }}",
7171
"Choose another cluster": "Choisir un autre cluster",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "Aller au contenu principal",
7375
"Menu": "",
7476
"Mark all as read": "Marquer toutes les notifications comme lues",
@@ -324,6 +326,7 @@
324326
"Init Containers": "Conteneurs d'initialisation",
325327
"Conditions": "Conditions",
326328
"Volumes": "Volumes",
329+
"Kind": "",
327330
"Restarting {{ itemName }}…": "Redémarrage de {{ itemName }}…",
328331
"Cancelled restarting {{ itemName }}.": "Redémarrage de {{ itemName }} annulé.",
329332
"Restarted {{ itemName }}.": "{{ itemName }} redémarré.",
@@ -441,7 +444,6 @@
441444
"ParentRefs": "",
442445
"No rules data to be shown.": "Aucune donnée sur les règles à afficher.",
443446
"Namespace": "",
444-
"Kind": "",
445447
"Section Name": "",
446448
"Press<1>/</1>to search": "",
447449
"Search resources, pages, clusters by name": "",

frontend/src/i18n/locales/hi/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "क्लस्टर लोड करें",
7070
"Something went wrong with cluster {{ cluster }}": "क्लस्टर {{ cluster }} के साथ कुछ गलत हुआ",
7171
"Choose another cluster": "दूसरा क्लस्टर चुनें",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "मुख्य सामग्री पर जाएँ",
7375
"Menu": "",
7476
"Mark all as read": "सभी को पढ़ा हुआ चिह्नित करें",
@@ -322,6 +324,7 @@
322324
"Init Containers": "इनिट कंटेनर्स",
323325
"Conditions": "शर्तें",
324326
"Volumes": "वॉल्यूम्स",
327+
"Kind": "",
325328
"Restarting {{ itemName }}…": "{{ itemName }} पुनरारंभ कर रहे हैं…",
326329
"Cancelled restarting {{ itemName }}.": "{{ itemName }} पुनरारंभ करना रद्द किया गया।",
327330
"Restarted {{ itemName }}.": "{{ itemName }} पुनरारंभ किया गया।",
@@ -438,7 +441,6 @@
438441
"ParentRefs": "",
439442
"No rules data to be shown.": "दिखाने के लिए कोई नियम डेटा नहीं है।",
440443
"Namespace": "",
441-
"Kind": "",
442444
"Section Name": "",
443445
"Press<1>/</1>to search": "खोजने के लिए <1>/</1> दबाएँ",
444446
"Search resources, pages, clusters by name": "नाम से रिसोर्सेज़, पेजेज़ और क्लस्टर खोजें",

frontend/src/i18n/locales/it/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "Carica cluster",
7070
"Something went wrong with cluster {{ cluster }}": "Qualcosa è andato storto con il cluster {{ cluster }}",
7171
"Choose another cluster": "Scegli un altro cluster",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "Salta al contenuto principale",
7375
"Menu": "",
7476
"Mark all as read": "Segna tutto come letto",
@@ -324,6 +326,7 @@
324326
"Init Containers": "Container di Avvio",
325327
"Conditions": "Condizioni",
326328
"Volumes": "Volume",
329+
"Kind": "Kind",
327330
"Restarting {{ itemName }}…": "Riavvio di {{ itemName }}…",
328331
"Cancelled restarting {{ itemName }}.": "Riavvio di {{ itemName }} annullato.",
329332
"Restarted {{ itemName }}.": "{{ itemName }} riavviato.",
@@ -441,7 +444,6 @@
441444
"ParentRefs": "ParentRefs",
442445
"No rules data to be shown.": "Nessun dato sulle regole da mostrare.",
443446
"Namespace": "Namespace",
444-
"Kind": "Kind",
445447
"Section Name": "Nome Sezione",
446448
"Press<1>/</1>to search": "Premi<1>/</1> per cercare",
447449
"Search resources, pages, clusters by name": "Cerca risorse, pagine, cluster per nome",

frontend/src/i18n/locales/ja/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "クラスターの読み込み",
7070
"Something went wrong with cluster {{ cluster }}": "クラスター {{ cluster }} で問題が発生しました",
7171
"Choose another cluster": "別のクラスターを選択",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "メインコンテンツへスキップ",
7375
"Menu": "",
7476
"Mark all as read": "すべて既読にする",
@@ -320,6 +322,7 @@
320322
"Init Containers": "初期化コンテナー",
321323
"Conditions": "条件",
322324
"Volumes": "ボリューム",
325+
"Kind": "種類",
323326
"Restarting {{ itemName }}…": "{{ itemName }} を再起動中…",
324327
"Cancelled restarting {{ itemName }}.": "{{ itemName }} の再起動をキャンセルしました。",
325328
"Restarted {{ itemName }}.": "{{ itemName }} を再起動しました。",
@@ -435,7 +438,6 @@
435438
"ParentRefs": "親参照",
436439
"No rules data to be shown.": "表示するルールデータがありません。",
437440
"Namespace": "ネームスペース",
438-
"Kind": "種類",
439441
"Section Name": "セクション名",
440442
"Press<1>/</1>to search": "<1>/</1>キーを押して検索",
441443
"Search resources, pages, clusters by name": "名前でリソース、ページ、クラスターを検索",

frontend/src/i18n/locales/ko/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"Load cluster": "클러스터 불러오기",
7070
"Something went wrong with cluster {{ cluster }}": "{{ cluster }} 클러스터에서 문제가 발생했습니다.",
7171
"Choose another cluster": "다른 클러스터 선택",
72+
"Failed to connect to the backend": "",
73+
"Connecting to backend...": "",
7274
"Skip to main content": "주요 콘텐츠로 건너뛰기",
7375
"Menu": "",
7476
"Mark all as read": "모두 읽은 것으로 표시",
@@ -320,6 +322,7 @@
320322
"Init Containers": "초기화 컨테이너",
321323
"Conditions": "상태",
322324
"Volumes": "볼륨",
325+
"Kind": "종류",
323326
"Restarting {{ itemName }}…": "{{ itemName }} 재시작 중…",
324327
"Cancelled restarting {{ itemName }}.": "{{ itemName }} 재시작 취소됨.",
325328
"Restarted {{ itemName }}.": "{{ itemName }} 재시작됨.",
@@ -435,7 +438,6 @@
435438
"ParentRefs": "상위 참조",
436439
"No rules data to be shown.": "표시할 규칙 데이터가 없습니다.",
437440
"Namespace": "네임스페이스",
438-
"Kind": "종류",
439441
"Section Name": "섹션 이름",
440442
"Press<1>/</1>to search": "검색하려면 <1>/</1>를 누르세요",
441443
"Search resources, pages, clusters by name": "이름으로 리소스, 페이지, 클러스터 검색",

0 commit comments

Comments
 (0)