Skip to content

Commit dc23319

Browse files
committed
fix: jumping content in database tabs
1 parent dcbefa1 commit dc23319

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/TenantDashboard/TenantDashboard.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
ChartOptions,
77
MetricDescription,
88
} from '../../../../../components/MetricChart';
9+
import {useGraphShardExists} from '../../../../../store/reducers/capabilities/hooks';
910
import {cn} from '../../../../../utils/cn';
1011
import {useAutoRefreshInterval} from '../../../../../utils/hooks';
1112

@@ -28,7 +29,13 @@ interface TenantDashboardProps {
2829
}
2930

3031
export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
31-
const [isDashboardHidden, setIsDashboardHidden] = React.useState<boolean>(true);
32+
const graphShardExists = useGraphShardExists();
33+
34+
// If GraphShardExists capability is true, show dashboard immediately
35+
// Otherwise, fall back to reactive behavior (hidden until first chart succeeds)
36+
const [isDashboardHidden, setIsDashboardHidden] = React.useState<boolean>(
37+
graphShardExists !== true,
38+
);
3239
const [autoRefreshInterval] = useAutoRefreshInterval();
3340

3441
// Refetch data only if dashboard successfully loaded
@@ -40,11 +47,13 @@ export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
4047
* 2. ydb version does not have /viewer/json/render endpoint (400, 404, CORS error, etc.)
4148
*
4249
* If at least one chart successfully loaded, dashboard should be shown
50+
* This fallback behavior is only used when GraphShardExists capability is not available or false
4351
* @link https://github.com/ydb-platform/ydb-embedded-ui/issues/659
4452
* @todo disable only for specific errors ('GraphShard is not enabled') after ydb-stable-24 is generally used
4553
*/
4654
const handleChartDataStatusChange = (chartStatus: ChartDataStatus) => {
47-
if (chartStatus === 'success') {
55+
// Only use reactive behavior when GraphShardExists capability is not true
56+
if (graphShardExists !== true && chartStatus === 'success') {
4857
setIsDashboardHidden(false);
4958
}
5059
};

src/store/reducers/capabilities/capabilities.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ export const selectSecuritySetting = createSelector(
6565
selectDatabaseCapabilities(state, database).data?.Settings?.Security?.[setting],
6666
);
6767

68+
export const selectGraphShardExists = createSelector(
69+
(state: RootState) => state,
70+
(_state: RootState, database?: string) => database,
71+
(state, database) =>
72+
selectDatabaseCapabilities(state, database).data?.Settings?.Database?.GraphShardExists,
73+
);
74+
6875
export async function queryCapability(
6976
capability: Capability,
7077
database: string | undefined,

src/store/reducers/capabilities/hooks.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
capabilitiesApi,
77
selectCapabilityVersion,
88
selectDatabaseCapabilities,
9+
selectGraphShardExists,
910
selectMetaCapabilities,
1011
selectMetaCapabilityVersion,
1112
selectSecuritySetting,
@@ -98,6 +99,12 @@ const useGetSecuritySetting = (feature: SecuritySetting) => {
9899
return useTypedSelector((state) => selectSecuritySetting(state, feature, database));
99100
};
100101

102+
export const useGraphShardExists = () => {
103+
const database = useDatabaseFromQuery();
104+
105+
return useTypedSelector((state) => selectGraphShardExists(state, database));
106+
};
107+
101108
export const useClusterWithoutAuthInUI = () => {
102109
return useGetSecuritySetting('UseLoginProvider') === false;
103110
};

src/types/api/capabilities.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export interface CapabilitiesResponse {
55
Capabilities: Record<Partial<Capability>, number>;
66
Settings?: {
77
Security?: Record<Partial<SecuritySetting>, boolean>;
8+
Database?: {
9+
GraphShardExists?: boolean;
10+
};
811
};
912
}
1013

0 commit comments

Comments
 (0)