Skip to content

Commit 8e078fd

Browse files
committed
ui: Latency page UI improvements
- use connectivity endpoint as a source of connection statuses and latency; - remove popup with disconnected peers, instead it will be shown on latency matrix; Release note: None
1 parent 0099578 commit 8e078fd

File tree

15 files changed

+630
-556
lines changed

15 files changed

+630
-556
lines changed

pkg/ui/workspaces/db-console/src/app.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ describe("Routing to", () => {
585585
screen.getByText(NETWORK_DIAGNOSTICS_REPORT_HEADER, {
586586
selector: "h3",
587587
});
588+
expect(history.location.pathname).toBe("/reports/network/region");
588589
});
589590
});
590591

pkg/ui/workspaces/db-console/src/app.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ export const App: React.FC<AppProps> = (props: AppProps) => {
408408
path={`/reports/network/:${nodeIDAttr}`}
409409
component={Network}
410410
/>
411-
<Route exact path="/reports/network" component={Network} />
411+
<Redirect
412+
from={`/reports/network`}
413+
to={`/reports/network/region`}
414+
/>
412415
<Route exact path="/reports/nodes" component={Nodes} />
413416
<Route
414417
exact

pkg/ui/workspaces/db-console/src/redux/apiReducers.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,15 @@ const tenantsListObj = new CachedDataReducer(
528528

529529
export const refreshTenantsList = tenantsListObj.refresh;
530530

531+
const connectivityObj = new CachedDataReducer(
532+
api.getNetworkConnectivity,
533+
"connectivity",
534+
moment.duration(30, "s"),
535+
moment.duration(1, "minute"),
536+
);
537+
538+
export const refreshConnectivity = connectivityObj.refresh;
539+
531540
export interface APIReducersState {
532541
cluster: CachedDataReducerState<api.ClusterResponseMessage>;
533542
events: CachedDataReducerState<
@@ -592,6 +601,7 @@ export interface APIReducersState {
592601
snapshot: KeyedCachedDataReducerState<clusterUiApi.GetTracingSnapshotResponse>;
593602
rawTrace: KeyedCachedDataReducerState<clusterUiApi.GetTraceResponse>;
594603
tenants: CachedDataReducerState<api.ListTenantsResponseMessage>;
604+
connectivity: CachedDataReducerState<api.NetworkConnectivityResponse>;
595605
}
596606

597607
export const apiReducersReducer = combineReducers<APIReducersState>({
@@ -647,6 +657,7 @@ export const apiReducersReducer = combineReducers<APIReducersState>({
647657
[statementFingerprintInsightsReducerObj.actionNamespace]:
648658
statementFingerprintInsightsReducerObj.reducer,
649659
[tenantsListObj.actionNamespace]: tenantsListObj.reducer,
660+
[connectivityObj.actionNamespace]: connectivityObj.reducer,
650661
});
651662

652663
export { CachedDataReducerState, KeyedCachedDataReducerState };
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2023 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the Business Source License
4+
// included in the file licenses/BSL.txt.
5+
//
6+
// As of the Change Date specified in that file, in accordance with
7+
// the Business Source License, use of this software will be governed
8+
// by the Apache License, Version 2.0, included in the file
9+
// licenses/APL.txt.
10+
11+
import { AdminUIState } from "src/redux/state";
12+
13+
export const connectivitySelector = (state: AdminUIState) =>
14+
state.cachedData.connectivity;

pkg/ui/workspaces/db-console/src/util/api.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ export type ListTenantsRequestMessage =
208208
export type ListTenantsResponseMessage =
209209
protos.cockroach.server.serverpb.ListTenantsResponse;
210210

211+
export type NetworkConnectivityRequest =
212+
protos.cockroach.server.serverpb.NetworkConnectivityRequest;
213+
export type NetworkConnectivityResponse =
214+
protos.cockroach.server.serverpb.NetworkConnectivityResponse;
215+
211216
// API constants
212217

213218
export const API_PREFIX = "_admin/v1";
@@ -851,6 +856,18 @@ export function getTenants(
851856
);
852857
}
853858

859+
export function getNetworkConnectivity(
860+
req: NetworkConnectivityRequest,
861+
timeout?: moment.Duration,
862+
): Promise<NetworkConnectivityResponse> {
863+
return timeoutFetch(
864+
serverpb.NetworkConnectivityResponse,
865+
`${STATUS_PREFIX}/connectivity`,
866+
req as any,
867+
timeout,
868+
);
869+
}
870+
854871
export function IsValidateUriName(...args: string[]): Promise<any> {
855872
for (const name of args) {
856873
if (name.includes("/")) {

pkg/ui/workspaces/db-console/src/views/app/components/chip/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ import React from "react";
1212
import "./styles.styl";
1313

1414
interface IChipProps {
15-
title: string;
16-
type?: "green" | "lightgreen" | "grey" | "blue" | "lightblue" | "yellow";
15+
title: React.ReactChild;
16+
type?:
17+
| "green"
18+
| "lightgreen"
19+
| "grey"
20+
| "blue"
21+
| "lightblue"
22+
| "yellow"
23+
| "red"
24+
| "white";
1725
}
1826

1927
export const Chip: React.SFC<IChipProps> = ({ title, type }) => (

pkg/ui/workspaces/db-console/src/views/app/components/chip/styles.styl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@
3535
background $chip-blue
3636
&--yellow
3737
background $chip-yellow
38+
&--red
39+
background $chip-red
40+
&--white
41+
background $colors--neutral-0
42+
border-color $colors--neutral-4
43+
border-style solid
44+
border-width 1px

0 commit comments

Comments
 (0)