Skip to content

Commit

Permalink
feat: [query settings] display trace level selector
Browse files Browse the repository at this point in the history
  • Loading branch information
astandrik committed Aug 19, 2024
1 parent 7d544b7 commit 0a0c5cc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {MonacoEditor} from '../../../../components/MonacoEditor/MonacoEditor';
import SplitPane from '../../../../components/SplitPane';
import type {RootState} from '../../../../store';
import {cancelQueryApi} from '../../../../store/reducers/cancelQuery';
import {useTracingLevelOptionAvailable} from '../../../../store/reducers/capabilities/hooks';
import {
executeQueryApi,
goToNextQuery,
Expand All @@ -29,7 +30,6 @@ import {cn} from '../../../../utils/cn';
import {
DEFAULT_IS_QUERY_RESULT_COLLAPSED,
DEFAULT_SIZE_RESULT_PANE_KEY,
ENABLE_TRACING_LEVEL_KEY,
LAST_USED_QUERY_ACTION_KEY,
QUERY_USE_MULTI_SCHEMA_KEY,
} from '../../../../utils/constants';
Expand Down Expand Up @@ -103,7 +103,7 @@ function QueryEditor(props: QueryEditorProps) {
const [resultType, setResultType] = React.useState<ValueOf<typeof RESULT_TYPES>>();
const [isResultLoaded, setIsResultLoaded] = React.useState(false);
const [querySettings] = useQueryExecutionSettings();
const [enableTracingLevel] = useSetting<boolean>(ENABLE_TRACING_LEVEL_KEY);
const enableTracingLevel = useTracingLevelOptionAvailable();
const [lastQueryExecutionSettings, setLastQueryExecutionSettings] =
useLastQueryExecutionSettings();
const {resetBanner} = useChangedQuerySettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import React from 'react';
import {Dialog, Link as ExternalLink, Flex, TextInput} from '@gravity-ui/uikit';
import {Controller, useForm} from 'react-hook-form';

import {useTracingLevelOptionAvailable} from '../../../../store/reducers/capabilities/hooks';
import {
selectQueryAction,
setQueryAction,
} from '../../../../store/reducers/queryActions/queryActions';
import type {QuerySettings} from '../../../../types/store/query';
import {cn} from '../../../../utils/cn';
import {ENABLE_TRACING_LEVEL_KEY} from '../../../../utils/constants';
import {
useQueryExecutionSettings,
useSetting,
useTypedDispatch,
useTypedSelector,
} from '../../../../utils/hooks';
Expand Down Expand Up @@ -71,7 +70,7 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
defaultValues: initialValues,
});

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

return (
<form onSubmit={handleSubmit(onSubmit)}>
Expand Down
3 changes: 0 additions & 3 deletions src/containers/UserSettings/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

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

"settings.enableTracingLevel.title": "Enable tracing level select",
"settings.enableTracingLevel.description": "Caution: Enabling this setting may break running of queries",

"settings.queryUseMultiSchema.title": "Allow queries with multiple result sets",
"settings.queryUseMultiSchema.description": "Use 'multi' schema for queries. It enables queries with multiple result sets. It returns nothing on versions 23-3 and older",

Expand Down
9 changes: 1 addition & 8 deletions src/containers/UserSettings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
AUTOCOMPLETE_ON_ENTER,
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
ENABLE_AUTOCOMPLETE,
ENABLE_TRACING_LEVEL_KEY,
INVERTED_DISKS_KEY,
LANGUAGE_KEY,
QUERY_USE_MULTI_SCHEMA_KEY,
Expand Down Expand Up @@ -113,12 +112,6 @@ export const showDomainDatabase: SettingProps = {
title: i18n('settings.showDomainDatabase.title'),
};

export const enableTracingLevel: SettingProps = {
settingKey: ENABLE_TRACING_LEVEL_KEY,
title: i18n('settings.enableTracingLevel.title'),
description: i18n('settings.enableTracingLevel.description'),
};

export const queryUseMultiSchemaSetting: SettingProps = {
settingKey: QUERY_USE_MULTI_SCHEMA_KEY,
title: i18n('settings.queryUseMultiSchema.title'),
Expand Down Expand Up @@ -167,7 +160,7 @@ export const experimentsSection: SettingsSection = {
export const devSettingsSection: SettingsSection = {
id: 'devSettingsSection',
title: i18n('section.dev-setting'),
settings: [enableAutocompleteSetting, autocompleteOnEnterSetting, enableTracingLevel],
settings: [enableAutocompleteSetting, autocompleteOnEnterSetting],
};

export const aboutSettingsSection: SettingsSection = {
Expand Down
2 changes: 0 additions & 2 deletions src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
DEFAULT_QUERY_SETTINGS,
ENABLE_AUTOCOMPLETE,
ENABLE_TRACING_LEVEL_KEY,
INVERTED_DISKS_KEY,
IS_HOTKEYS_HELP_HIDDEN_KEY,
LANGUAGE_KEY,
Expand Down Expand Up @@ -48,7 +47,6 @@ export const DEFAULT_USER_SETTINGS = {
[AUTOCOMPLETE_ON_ENTER]: true,
[IS_HOTKEYS_HELP_HIDDEN_KEY]: false,
[AUTO_REFRESH_INTERVAL]: 0,
[ENABLE_TRACING_LEVEL_KEY]: false,
[SHOW_DOMAIN_DATABASE_KEY]: false,
[LAST_QUERY_EXECUTION_SETTINGS_KEY]: undefined,
[QUERY_SETTINGS_BANNER_LAST_CLOSED_KEY]: undefined,
Expand Down
4 changes: 4 additions & 0 deletions src/store/reducers/capabilities/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export const useDiskPagesAvailable = () => {
// It's enough to check only pdisk handler
return useGetFeatureVersion('/pdisk/info') > 0;
};

export const useTracingLevelOptionAvailable = () => {
return useGetFeatureVersion('/viewer/query') > 2;
};
2 changes: 1 addition & 1 deletion src/types/api/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export interface CapabilitiesResponse {
}

// Add feature name before using it
export type Capability = '/pdisk/info' | '/scheme/directory';
export type Capability = '/pdisk/info' | '/scheme/directory' | '/viewer/query';
2 changes: 0 additions & 2 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,3 @@ export const ENABLE_AUTOCOMPLETE = 'enableAutocomplete';
export const AUTOCOMPLETE_ON_ENTER = 'autocompleteOnEnter';

export const IS_HOTKEYS_HELP_HIDDEN_KEY = 'isHotKeysHelpHidden';

export const ENABLE_TRACING_LEVEL_KEY = 'enableTracingLevel';
9 changes: 3 additions & 6 deletions src/utils/hooks/useQueryExecutionSettings.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {useTracingLevelOptionAvailable} from '../../store/reducers/capabilities/hooks';
import type {QuerySettings} from '../../types/store/query';
import {
DEFAULT_QUERY_SETTINGS,
ENABLE_TRACING_LEVEL_KEY,
QUERY_EXECUTION_SETTINGS_KEY,
} from '../constants';
import {DEFAULT_QUERY_SETTINGS, QUERY_EXECUTION_SETTINGS_KEY} from '../constants';

import {useSetting} from './useSetting';

export const useQueryExecutionSettings = () => {
const [enableTracingLevel] = useSetting<boolean>(ENABLE_TRACING_LEVEL_KEY);
const enableTracingLevel = useTracingLevelOptionAvailable();
const [setting, setSetting] = useSetting<QuerySettings>(QUERY_EXECUTION_SETTINGS_KEY);

return [
Expand Down

0 comments on commit 0a0c5cc

Please sign in to comment.