Skip to content

fix: jumping content in database tabs #2606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ChartOptions,
MetricDescription,
} from '../../../../../components/MetricChart';
import {useGraphShardExists} from '../../../../../store/reducers/capabilities/hooks';
import {cn} from '../../../../../utils/cn';
import {useAutoRefreshInterval} from '../../../../../utils/hooks';

Expand All @@ -28,7 +29,14 @@ interface TenantDashboardProps {
}

export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
const [isDashboardHidden, setIsDashboardHidden] = React.useState<boolean>(true);
const graphShardExists = useGraphShardExists();

const [hasSuccessfulChart, setHasSuccessfulChart] = React.useState<boolean>(false);

const isDashboardHidden = React.useMemo(() => {
return graphShardExists !== true && !hasSuccessfulChart;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!graphShardExists ?

}, [graphShardExists, hasSuccessfulChart]);

const [autoRefreshInterval] = useAutoRefreshInterval();

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

Expand Down
7 changes: 7 additions & 0 deletions src/store/reducers/capabilities/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ export const selectSecuritySetting = createSelector(
selectDatabaseCapabilities(state, database).data?.Settings?.Security?.[setting],
);

export const selectGraphShardExists = createSelector(
(state: RootState) => state,
(_state: RootState, database?: string) => database,
(state, database) =>
selectDatabaseCapabilities(state, database).data?.Settings?.Database?.GraphShardExists,
);

export async function queryCapability(
capability: Capability,
database: string | undefined,
Expand Down
7 changes: 7 additions & 0 deletions src/store/reducers/capabilities/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
capabilitiesApi,
selectCapabilityVersion,
selectDatabaseCapabilities,
selectGraphShardExists,
selectMetaCapabilities,
selectMetaCapabilityVersion,
selectSecuritySetting,
Expand Down Expand Up @@ -98,6 +99,12 @@ const useGetSecuritySetting = (feature: SecuritySetting) => {
return useTypedSelector((state) => selectSecuritySetting(state, feature, database));
};

export const useGraphShardExists = () => {
const database = useDatabaseFromQuery();

return useTypedSelector((state) => selectGraphShardExists(state, database));
};

export const useClusterWithoutAuthInUI = () => {
return useGetSecuritySetting('UseLoginProvider') === false;
};
Expand Down
3 changes: 3 additions & 0 deletions src/types/api/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export interface CapabilitiesResponse {
Capabilities: Record<Partial<Capability>, number>;
Settings?: {
Security?: Record<Partial<SecuritySetting>, boolean>;
Database?: {
GraphShardExists?: boolean;
};
};
}

Expand Down
Loading