Skip to content

Commit b41a6bd

Browse files
committed
debezium/dbz#1725 fix: Improve loading state management in Platform UI
Signed-off-by: Aravind <gmarav005@gmail.com>
1 parent 1760bc1 commit b41a6bd

11 files changed

Lines changed: 25 additions & 19 deletions

File tree

debezium-platform-stage/src/main.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ import { StrictMode, Suspense } from 'react';
88
import './i18n';
99

1010
// Create a client
11-
const queryClient = new QueryClient();
11+
const queryClient = new QueryClient({
12+
defaultOptions: {
13+
queries: {
14+
retry: 3,
15+
},
16+
},
17+
});
1218

1319
ReactDOM.createRoot(document.getElementById('root')!).render(
1420
<QueryClientProvider client={queryClient}>
15-
<Suspense fallback="loading">
21+
<Suspense fallback={null}>
1622
<StrictMode>
1723
<App />
1824
</StrictMode>

debezium-platform-stage/src/pages/Connection/Connections.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe("Connections", () => {
8181
return { data: undefined, error: null, isLoading: false } as any;
8282
});
8383
render(<Connections />);
84-
expect(screen.getByText("Loading...")).toBeInTheDocument();
84+
expect(screen.getByRole("progressbar")).toBeInTheDocument();
8585
});
8686

8787
it("shows API error when connections query fails", () => {

debezium-platform-stage/src/pages/Connection/Connections.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const Connections: React.FunctionComponent<IConnectionsProps> = () => {
7575
data: connectionsList = [],
7676
error,
7777
isLoading: isConnectionsLoading,
78+
failureCount: connectionsFailureCount,
7879
} = useQuery<Connection[], Error>(
7980
"connections",
8081
() => fetchData<Connection[]>(`${API_URL}/api/connections`),
@@ -155,7 +156,7 @@ const Connections: React.FunctionComponent<IConnectionsProps> = () => {
155156
return (
156157
<div data-tour="connection-page" style={{ flex: 1, display: "flex", flexDirection: "column" }}>
157158

158-
{error ? (
159+
{(!!error || connectionsFailureCount >= 3) ? (
159160
<ApiError
160161
errorType="large"
161162
errorMsg={error.message}
@@ -177,7 +178,6 @@ const Connections: React.FunctionComponent<IConnectionsProps> = () => {
177178
<>
178179
{isConnectionsLoading ? (
179180
<EmptyState
180-
titleText={t("Loading...")}
181181
headingLevel="h4"
182182
icon={Spinner}
183183
/>

debezium-platform-stage/src/pages/Destination/Destinations.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("Destinations", () => {
7272
isLoading: true,
7373
} as any);
7474
render(<Destinations />);
75-
expect(screen.getByText("Loading...")).toBeInTheDocument();
75+
expect(screen.getByRole("progressbar")).toBeInTheDocument();
7676
});
7777

7878
it("displays error message when API fails", async () => {

debezium-platform-stage/src/pages/Destination/Destinations.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const Destinations: React.FunctionComponent = () => {
6363
data: destinationsList = [],
6464
error,
6565
isLoading: isDestinationLoading,
66+
failureCount: destinationsFailureCount,
6667
} = useQuery<Destination[], Error>(
6768
"destinations",
6869
() => fetchData<Destination[]>(`${API_URL}/api/destinations`),
@@ -109,7 +110,7 @@ const Destinations: React.FunctionComponent = () => {
109110

110111
return (
111112
<div data-tour="destination-page" style={{ flex: 1, display: "flex", flexDirection: "column" }}>
112-
{error ? (
113+
{(!!error || destinationsFailureCount >= 3) ? (
113114
<ApiError
114115
errorType="large"
115116
errorMsg={error.message}
@@ -128,7 +129,6 @@ const Destinations: React.FunctionComponent = () => {
128129
<>
129130
{isDestinationLoading ? (
130131
<EmptyState
131-
titleText={t("loading")}
132132
headingLevel="h4"
133133
icon={Spinner}
134134
/>
@@ -184,8 +184,8 @@ const Destinations: React.FunctionComponent = () => {
184184
</ToolbarContent>
185185
</Toolbar>
186186
<div data-tour="destination-table">
187-
<SourceSinkTable
188-
data={searchResult}
187+
<SourceSinkTable
188+
data={searchResult}
189189
tableType="destination"
190190
onClear={onClear}
191191
/>

debezium-platform-stage/src/pages/Pipeline/Pipelines.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("Pipelines", () => {
6969

7070
render(<Pipelines />);
7171

72-
expect(screen.getByText("Loading...")).toBeInTheDocument();
72+
expect(screen.getByRole("progressbar")).toBeInTheDocument();
7373
});
7474

7575
it("filters pipelines based on search input", async () => {

debezium-platform-stage/src/pages/Pipeline/Pipelines.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const Pipelines: React.FunctionComponent = () => {
9191
data: pipelinesList = [],
9292
error: pipelinesError,
9393
isLoading: pipelinesLoading,
94+
failureCount: pipelinesFailureCount,
9495
} = useQuery<Pipeline[], Error>(
9596
"pipelines",
9697
() => fetchData<Pipeline[]>(`${API_URL}/api/pipelines`),
@@ -263,7 +264,7 @@ const Pipelines: React.FunctionComponent = () => {
263264

264265
return (
265266
<>
266-
{pipelinesError ? (
267+
{(!!pipelinesError || pipelinesFailureCount >= 3) ? (
267268
<PageSection isWidthLimited>
268269
<ApiError
269270
errorType="large"
@@ -287,7 +288,6 @@ const Pipelines: React.FunctionComponent = () => {
287288
<>
288289
{pipelinesLoading ? (
289290
<EmptyState
290-
titleText={t("loading")}
291291
headingLevel="h4"
292292
icon={Spinner}
293293
/>

debezium-platform-stage/src/pages/Source/Sources.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("Sources", () => {
7070
isLoading: true,
7171
} as any);
7272
render(<Sources />);
73-
expect(screen.getByText("Loading...")).toBeInTheDocument();
73+
expect(screen.getByRole("progressbar")).toBeInTheDocument();
7474
});
7575

7676
it("displays error message when API fails", async () => {

debezium-platform-stage/src/pages/Source/Sources.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const Sources: React.FunctionComponent<ISourceProps> = () => {
6868
data: sourcesList = [],
6969
error,
7070
isLoading: isSourceLoading,
71+
failureCount: sourcesFailureCount,
7172
} = useQuery<Source[], Error>(
7273
"sources",
7374
() => fetchData<Source[]>(`${API_URL}/api/sources`),
@@ -111,7 +112,7 @@ const Sources: React.FunctionComponent<ISourceProps> = () => {
111112
);
112113
return (
113114
<div data-tour="source-page" style={{ flex: 1, display: "flex", flexDirection: "column" }}>
114-
{error ? (
115+
{(!!error || sourcesFailureCount >= 3) ? (
115116
<ApiError
116117
errorType="large"
117118
errorMsg={error.message}
@@ -130,7 +131,6 @@ const Sources: React.FunctionComponent<ISourceProps> = () => {
130131
<>
131132
{isSourceLoading ? (
132133
<EmptyState
133-
titleText="Loading..."
134134
headingLevel="h4"
135135
icon={Spinner}
136136
/>

debezium-platform-stage/src/pages/Transforms/Transforms.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("Transforms", () => {
7070
isLoading: true,
7171
} as any);
7272
render(<Transforms />);
73-
expect(screen.getByText("Loading...")).toBeInTheDocument();
73+
expect(screen.getByRole("progressbar")).toBeInTheDocument();
7474
});
7575

7676
it("displays error message when API fails", async () => {

0 commit comments

Comments
 (0)