Skip to content

fix: make plan to svg more comprehensive #1658

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 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,6 +1,6 @@
import React from 'react';

import {Dialog, Link as ExternalLink, Flex, TextInput} from '@gravity-ui/uikit';
import {Dialog, Link as ExternalLink, Flex, TextInput, Tooltip} from '@gravity-ui/uikit';
import {zodResolver} from '@hookform/resolvers/zod';
import {Controller, useForm} from 'react-hook-form';

Expand All @@ -11,8 +11,10 @@ import {
} from '../../../../store/reducers/queryActions/queryActions';
import type {QuerySettings} from '../../../../types/store/query';
import {cn} from '../../../../utils/cn';
import {USE_SHOW_PLAN_SVG_KEY} from '../../../../utils/constants';
import {
useQueryExecutionSettings,
useSetting,
useTypedDispatch,
useTypedSelector,
} from '../../../../utils/hooks';
Expand Down Expand Up @@ -77,6 +79,7 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
resolver: zodResolver(querySettingsValidationSchema),
});

const [useShowPlanToSvg] = useSetting<boolean>(USE_SHOW_PLAN_SVG_KEY);
const enableTracingLevel = useTracingLevelOptionAvailable();

return (
Expand Down Expand Up @@ -178,22 +181,29 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
<label htmlFor="statisticsMode" className={b('field-title')}>
{QUERY_SETTINGS_FIELD_SETTINGS.statisticsMode.title}
</label>
<div className={b('control-wrapper', {statisticsMode: true})}>
<Controller
name="statisticsMode"
control={control}
render={({field}) => (
<QuerySettingsSelect
id="statisticsMode"
setting={field.value}
onUpdateSetting={field.onChange}
settingOptions={
QUERY_SETTINGS_FIELD_SETTINGS.statisticsMode.options
}
/>
)}
/>
</div>
<Tooltip
disabled={!useShowPlanToSvg}
openDelay={0}
content={i18n('tooltip_plan-to-svg-statistics')}
>
<div className={b('control-wrapper', {statisticsMode: true})}>
<Controller
name="statisticsMode"
control={control}
render={({field}) => (
<QuerySettingsSelect
id="statisticsMode"
disabled={useShowPlanToSvg}
setting={field.value}
onUpdateSetting={field.onChange}
settingOptions={
QUERY_SETTINGS_FIELD_SETTINGS.statisticsMode.options
}
/>
)}
/>
</div>
</Tooltip>
</Flex>
<Flex direction="row" alignItems="flex-start" className={b('dialog-row')}>
<label htmlFor="limitRows" className={b('field-title')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface QuerySettingsSelectProps<T extends SelectType> {
id?: string;
setting: T;
settingOptions: QuerySettingSelectOption<T>[];
disabled?: boolean;
onUpdateSetting: (mode: T) => void;
}

Expand All @@ -34,6 +35,7 @@ export function QuerySettingsSelect<T extends SelectType>(props: QuerySettingsSe
<div className={b('selector')}>
<Select<T>
id={props.id}
disabled={props.disabled}
options={props.settingOptions}
value={[props.setting]}
onUpdate={(value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"form.tracing-level": "Tracing level",
"form.limit-rows": "Limit rows",
"button-done": "Save",
"tooltip_plan-to-svg-statistics": "Statistics option is set to \"Full\" due to the enabled \"Execution plan\" experiment.\n To disable it, go to the \"Experiments\" section in the user settings.",
"button-cancel": "Cancel",
"form.timeout.seconds": "sec",
"form.validation.timeout": "Must be positive",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"form.statistics-mode": "Π Π΅ΠΆΠΈΠΌ сбора статистики",
"form.tracing-level": "Tracing level",
"form.limit-rows": "Π›ΠΈΠΌΠΈΡ‚ строк",
"tooltip_plan-to-svg-statistics": "ΠžΠΏΡ†ΠΈΡ статистики установлСна Π² Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ \"Full\" ΠΈΠ·-Π·Π° Π²ΠΊΠ»ΡŽΡ‡Π΅Π½Π½ΠΎΠ³ΠΎ экспСримСнта \"Execution plan\".\n Π§Ρ‚ΠΎΠ±Ρ‹ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ Π΅Π³ΠΎ, ΠΏΠ΅Ρ€Π΅ΠΉΠ΄ΠΈΡ‚Π΅ Π² Ρ€Π°Π·Π΄Π΅Π» \"Experiments\" Π² настройках ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ.",
"button-done": "Π“ΠΎΡ‚ΠΎΠ²ΠΎ",
"button-cancel": "ΠžΡ‚ΠΌΠ΅Π½ΠΈΡ‚ΡŒ",
"form.timeout.seconds": "сСк",
Expand Down
4 changes: 2 additions & 2 deletions src/containers/UserSettings/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

"settings.enableNetworkTable.title": "Enable network table",

"settings.useShowPlanToSvg.title": "Plan to svg",
"settings.useShowPlanToSvg.description": " Show \"Plan to svg\" button in query result widow (if query was executed with full stats option).",
"settings.useShowPlanToSvg.title": "Execution plan",
"settings.useShowPlanToSvg.description": " Show \"Execution plan\" button in query result widow. Opens svg with execution plan in a new window.",

"settings.showDomainDatabase.title": "Show domain database",

Expand Down
6 changes: 4 additions & 2 deletions src/utils/hooks/useQueryExecutionSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useTracingLevelOptionAvailable} from '../../store/reducers/capabilities/hooks';
import type {QuerySettings} from '../../types/store/query';
import {QUERY_EXECUTION_SETTINGS_KEY} from '../constants';
import {DEFAULT_QUERY_SETTINGS, querySettingsRestoreSchema} from '../query';
import {QUERY_EXECUTION_SETTINGS_KEY, USE_SHOW_PLAN_SVG_KEY} from '../constants';
import {DEFAULT_QUERY_SETTINGS, STATISTICS_MODES, querySettingsRestoreSchema} from '../query';

import {useSetting} from './useSetting';

Expand All @@ -10,9 +10,11 @@ export const useQueryExecutionSettings = () => {
const [storageSettings, setSettings] = useSetting<QuerySettings>(QUERY_EXECUTION_SETTINGS_KEY);

const validatedSettings = querySettingsRestoreSchema.parse(storageSettings);
const [useShowPlanToSvg] = useSetting<boolean>(USE_SHOW_PLAN_SVG_KEY);

const settings: QuerySettings = {
...validatedSettings,
statisticsMode: useShowPlanToSvg ? STATISTICS_MODES.full : validatedSettings.statisticsMode,
tracingLevel: enableTracingLevel
? validatedSettings.tracingLevel
: DEFAULT_QUERY_SETTINGS.tracingLevel,
Expand Down
Loading