Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions src/containers/ClusterModeGuard/ClusterModeGuard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {ReactNode} from 'react';
import {useTypedSelector} from '../../lib';

export interface ClusterModeGuardProps {
children: ReactNode;
mode: 'single' | 'multi';
}

export function ClusterModeGuard({children, mode}: ClusterModeGuardProps) {
const shouldRender = useTypedSelector((state) =>
mode === 'single' ? state.singleClusterMode : !state.singleClusterMode,
);

return shouldRender ? <>{children}</> : null;
}
1 change: 1 addition & 0 deletions src/containers/ClusterModeGuard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ClusterModeGuard';
3 changes: 3 additions & 0 deletions src/containers/UserSettings/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type SettingsElementType = 'switch' | 'radio';
export interface SettingProps {
type?: SettingsElementType;
title: string;
description?: ReactNode;
settingKey: string;
helpPopoverContent?: ReactNode;
options?: {value: string; content: string}[];
Expand All @@ -25,6 +26,7 @@ export const Setting = ({
type = 'switch',
settingKey,
title,
description,
helpPopoverContent,
options,
defaultValue,
Expand Down Expand Up @@ -85,6 +87,7 @@ export const Setting = ({
<Settings.Item
title={title}
highlightedTitle={title}
description={description}
renderTitleComponent={renderTitleComponent}
>
{getSettingsElement(type)}
Expand Down
3 changes: 3 additions & 0 deletions src/containers/UserSettings/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"settings.language.option-russian": "Russian",
"settings.language.option-english": "English",

"settings.binaryDataInPlainTextDisplay.title": "Display binary data in plain text",
"settings.binaryDataInPlainTextDisplay.description": "Available starting from version 24.1",

"settings.invertedDisks.title": "Inverted disks space indicators",

"settings.useNodesEndpoint.title": "Break the Nodes tab in Diagnostics",
Expand Down
10 changes: 2 additions & 8 deletions src/containers/UserSettings/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {i18n, Lang} from '../../../utils/i18n';
import {registerKeysets} from '../../../utils/i18n';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'ydb-user-settings';

i18n.registerKeyset(Lang.En, COMPONENT, en);
i18n.registerKeyset(Lang.Ru, COMPONENT, ru);

export default i18n.keyset(COMPONENT);
export default registerKeysets('ydb-user-settings', {en});
27 changes: 0 additions & 27 deletions src/containers/UserSettings/i18n/ru.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
USE_BACKEND_PARAMS_FOR_TABLES_KEY,
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
QUERY_USE_MULTI_SCHEMA_KEY,
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
} from '../../utils/constants';
import {Lang, defaultLang} from '../../utils/i18n';

import type {SettingProps} from './Setting';
import i18n from './i18n';
import {ClusterModeGuard} from '../ClusterModeGuard';

export interface SettingsSection {
id: string;
Expand Down Expand Up @@ -75,6 +77,16 @@ export const languageSetting: SettingProps = {
},
};

export const binaryDataInPlainTextDisplay: SettingProps = {
settingKey: BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
title: i18n('settings.binaryDataInPlainTextDisplay.title'),
description: (
<ClusterModeGuard mode="multi">
{i18n('settings.binaryDataInPlainTextDisplay.description')}
</ClusterModeGuard>
),
};

export const invertedDisksSetting: SettingProps = {
settingKey: INVERTED_DISKS_KEY,
title: i18n('settings.invertedDisks.title'),
Expand All @@ -98,7 +110,7 @@ export const queryUseMultiSchemaSetting: SettingProps = {
export const appearanceSection: SettingsSection = {
id: 'appearanceSection',
title: i18n('section.appearance'),
settings: [themeSetting, invertedDisksSetting],
settings: [themeSetting, invertedDisksSetting, binaryDataInPlainTextDisplay],
};
export const experimentsSection: SettingsSection = {
id: 'experimentsSection',
Expand Down
15 changes: 14 additions & 1 deletion src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ import type {JsonHotKeysResponse} from '../types/api/hotkeys';

import {backend as BACKEND, metaBackend as META_BACKEND} from '../store';
import {prepareSortValue} from '../utils/filters';
import {BINARY_DATA_IN_PLAIN_TEXT_DISPLAY} from '../utils/constants';
import {parseMetaCluster} from './parsers/parseMetaCluster';
import {parseMetaTenants} from './parsers/parseMetaTenants';
import {settingsManager} from './settings';

type AxiosOptions = {
concurrentId?: string;
Expand Down Expand Up @@ -305,9 +307,20 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
const uiTimeout = 9 * 60 * 1000;
const backendTimeout = 10 * 60 * 1000;

/**
* Return strings using base64 encoding.
* @link https://github.com/ydb-platform/ydb/pull/647
*/
const base64 = !settingsManager.readUserSettingsValue(
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
true,
);

return this.post<QueryAPIResponse<Action, Schema>>(
this.getPath(
`/viewer/json/query?timeout=${backendTimeout}${schema ? `&schema=${schema}` : ''}`,
`/viewer/json/query?timeout=${backendTimeout}&base64=${base64}${
schema ? `&schema=${schema}` : ''
}`,
),
params,
{},
Expand Down
2 changes: 2 additions & 0 deletions src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
USE_BACKEND_PARAMS_FOR_TABLES_KEY,
USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY,
USE_CLUSTER_BALANCER_AS_BACKEND_KEY,
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
} from '../utils/constants';
import {QUERY_ACTIONS, QUERY_MODES} from '../utils/query';
import {parseJson} from '../utils/utils';
Expand All @@ -27,6 +28,7 @@ export const DEFAULT_USER_SETTINGS: SettingsObject = {
[INVERTED_DISKS_KEY]: false,
[USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY]: false,
[QUERY_USE_MULTI_SCHEMA_KEY]: false,
[BINARY_DATA_IN_PLAIN_TEXT_DISPLAY]: true,
[SAVED_QUERIES_KEY]: [],
[TENANT_INITIAL_PAGE_KEY]: TENANT_PAGES_IDS.query,
[QUERY_INITIAL_MODE_KEY]: QUERY_MODES.script,
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const SAVED_QUERIES_KEY = 'saved_queries';
export const ASIDE_HEADER_COMPACT_KEY = 'asideHeaderCompact';
export const QUERIES_HISTORY_KEY = 'queries_history';
export const DATA_QA_TUNE_COLUMNS_POPUP = 'tune-columns-popup';
export const BINARY_DATA_IN_PLAIN_TEXT_DISPLAY = 'binaryDataInPlainTextDisplay';

export const DEFAULT_SIZE_RESULT_PANE_KEY = 'default-size-result-pane';
export const DEFAULT_SIZE_TENANT_SUMMARY_KEY = 'default-size-tenant-summary-pane';
Expand Down