Skip to content

Commit 602ca15

Browse files
authored
fix: jumping content in database tabs (#2606)
1 parent 18af440 commit 602ca15

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

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

Lines changed: 12 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,14 @@ 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+
const [hasSuccessfulChart, setHasSuccessfulChart] = React.useState<boolean>(false);
35+
36+
const isDashboardHidden = React.useMemo(() => {
37+
return !graphShardExists && !hasSuccessfulChart;
38+
}, [graphShardExists, hasSuccessfulChart]);
39+
3240
const [autoRefreshInterval] = useAutoRefreshInterval();
3341

3442
// Refetch data only if dashboard successfully loaded
@@ -40,12 +48,14 @@ export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
4048
* 2. ydb version does not have /viewer/json/render endpoint (400, 404, CORS error, etc.)
4149
*
4250
* If at least one chart successfully loaded, dashboard should be shown
51+
* This fallback behavior is only used when GraphShardExists capability is not available or false
4352
* @link https://github.com/ydb-platform/ydb-embedded-ui/issues/659
4453
* @todo disable only for specific errors ('GraphShard is not enabled') after ydb-stable-24 is generally used
4554
*/
4655
const handleChartDataStatusChange = (chartStatus: ChartDataStatus) => {
56+
// Always track successful chart loads for fallback behavior
4757
if (chartStatus === 'success') {
48-
setIsDashboardHidden(false);
58+
setHasSuccessfulChart(true);
4959
}
5060
};
5161

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)