From 627347a28e1cf921be429ef169f0b585229168af Mon Sep 17 00:00:00 2001 From: Anton Standrik Date: Tue, 30 Jul 2024 17:57:55 +0300 Subject: [PATCH] fix: review fixes --- src/containers/UserSettings/i18n/en.json | 3 +-- src/containers/UserSettings/settings.tsx | 17 ++++++++++------- src/services/settings.ts | 4 ++-- src/store/reducers/tenants/selectors.ts | 12 ++++++------ src/utils/constants.ts | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/containers/UserSettings/i18n/en.json b/src/containers/UserSettings/i18n/en.json index c170b4ac9..545357df4 100644 --- a/src/containers/UserSettings/i18n/en.json +++ b/src/containers/UserSettings/i18n/en.json @@ -37,8 +37,7 @@ "settings.usePaginatedTables.title": "Use paginated tables", "settings.usePaginatedTables.description": " Use table with data load on scroll for Nodes and Storage tabs. It will increase performance, but could work unstable", - "settings.hideDomainDatabase.title": "Hide root domain", - "settings.hideDomainDatabase.description": "Hide root domain on database list", + "settings.showDomainDatabase.title": "Show domain database", "settings.useQuerySettings.title": "Use query settings", "settings.useQuerySettings.description": "Use query settings", diff --git a/src/containers/UserSettings/settings.tsx b/src/containers/UserSettings/settings.tsx index 4519f93ad..5d41790bd 100644 --- a/src/containers/UserSettings/settings.tsx +++ b/src/containers/UserSettings/settings.tsx @@ -6,11 +6,11 @@ import { AUTOCOMPLETE_ON_ENTER, BINARY_DATA_IN_PLAIN_TEXT_DISPLAY, ENABLE_AUTOCOMPLETE, - HIDE_DOMAIN_DATABASE_KEY, INVERTED_DISKS_KEY, LANGUAGE_KEY, QUERY_SETTINGS, QUERY_USE_MULTI_SCHEMA_KEY, + SHOW_DOMAIN_DATABASE_KEY, THEME_KEY, USE_CLUSTER_BALANCER_AS_BACKEND_KEY, USE_DIRECTORY_OPERATIONS, @@ -110,10 +110,9 @@ export const usePaginatedTables: SettingProps = { description: i18n('settings.usePaginatedTables.description'), }; -export const hideDomainDatabase: SettingProps = { - settingKey: HIDE_DOMAIN_DATABASE_KEY, - title: i18n('settings.hideDomainDatabase.title'), - description: i18n('settings.hideDomainDatabase.description'), +export const showDomainDatabase: SettingProps = { + settingKey: SHOW_DOMAIN_DATABASE_KEY, + title: i18n('settings.showDomainDatabase.title'), }; export const useQuerySettings: SettingProps = { @@ -166,7 +165,12 @@ export const interfaceVersionInfoField: SettingsInfoFieldProps = { export const appearanceSection: SettingsSection = { id: 'appearanceSection', title: i18n('section.appearance'), - settings: [themeSetting, invertedDisksSetting, binaryDataInPlainTextDisplay], + settings: [ + themeSetting, + invertedDisksSetting, + binaryDataInPlainTextDisplay, + showDomainDatabase, + ], }; export const experimentsSection: SettingsSection = { id: 'experimentsSection', @@ -174,7 +178,6 @@ export const experimentsSection: SettingsSection = { settings: [ useNodesEndpointSetting, usePaginatedTables, - hideDomainDatabase, queryUseMultiSchemaSetting, useSeparateDisksPagesSetting, useDirectoryActionsSetting, diff --git a/src/services/settings.ts b/src/services/settings.ts index dbe9d58eb..a929d917d 100644 --- a/src/services/settings.ts +++ b/src/services/settings.ts @@ -5,7 +5,6 @@ import { AUTO_REFRESH_INTERVAL, BINARY_DATA_IN_PLAIN_TEXT_DISPLAY, ENABLE_AUTOCOMPLETE, - HIDE_DOMAIN_DATABASE_KEY, INVERTED_DISKS_KEY, IS_HOTKEYS_HELP_HIDDEN_KEY, LANGUAGE_KEY, @@ -15,6 +14,7 @@ import { QUERY_SETTINGS, QUERY_USE_MULTI_SCHEMA_KEY, SAVED_QUERIES_KEY, + SHOW_DOMAIN_DATABASE_KEY, TENANT_INITIAL_PAGE_KEY, THEME_KEY, USE_CLUSTER_BALANCER_AS_BACKEND_KEY, @@ -51,7 +51,7 @@ export const DEFAULT_USER_SETTINGS = { [AUTO_REFRESH_INTERVAL]: 0, [USE_DIRECTORY_OPERATIONS]: false, [QUERY_SETTINGS]: false, - [HIDE_DOMAIN_DATABASE_KEY]: true, + [SHOW_DOMAIN_DATABASE_KEY]: false, } as const satisfies SettingsObject; class SettingsManager { diff --git a/src/store/reducers/tenants/selectors.ts b/src/store/reducers/tenants/selectors.ts index fd3883776..d64fa1864 100644 --- a/src/store/reducers/tenants/selectors.ts +++ b/src/store/reducers/tenants/selectors.ts @@ -2,7 +2,7 @@ import {createSelector} from '@reduxjs/toolkit'; import escapeRegExp from 'lodash/escapeRegExp'; import type {RootState} from '../..'; -import {HIDE_DOMAIN_DATABASE_KEY} from '../../../lib'; +import {SHOW_DOMAIN_DATABASE_KEY} from '../../../lib'; import {EFlag} from '../../../types/api/enums'; import {ProblemFilterValues, getSettingValue, selectProblemFilter} from '../settings/settings'; import type {ProblemFilterValue} from '../settings/types'; @@ -43,18 +43,18 @@ export const selectTenants = createSelector( ); export const selectTenantsSearchValue = (state: TenantsStateSlice) => state.tenants.searchValue; -export const selectUseHideDomainDatabase = (state: RootState) => - getSettingValue(state, HIDE_DOMAIN_DATABASE_KEY); +export const selectShowDomainDatabase = (state: RootState) => + getSettingValue(state, SHOW_DOMAIN_DATABASE_KEY); // ==== Complex selectors ==== export const selectFilteredTenants = createSelector( - [selectTenants, selectProblemFilter, selectTenantsSearchValue, selectUseHideDomainDatabase], - (tenants, problemFilter, searchQuery, useHideDomainDatabase) => { + [selectTenants, selectProblemFilter, selectTenantsSearchValue, selectShowDomainDatabase], + (tenants, problemFilter, searchQuery, showDomainDatabase) => { let result = filterTenantsByProblems(tenants, problemFilter); result = filteredTenantsBySearch(result, searchQuery); result = - useHideDomainDatabase && result.length > 1 + !showDomainDatabase && result.length > 1 ? result.filter((item) => item.Type !== 'Domain') : result; diff --git a/src/utils/constants.ts b/src/utils/constants.ts index b6314647c..99dcc0eb7 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -131,7 +131,7 @@ export const TENANT_INITIAL_PAGE_KEY = 'saved_tenant_initial_tab'; export const USE_PAGINATED_TABLES_KEY = 'useBackendParamsForTables'; // Setting to hide domain in database list -export const HIDE_DOMAIN_DATABASE_KEY = 'hideDomainDatabase'; +export const SHOW_DOMAIN_DATABASE_KEY = 'showDomainDatabase'; // Enable schema that supports multiple resultsets export const QUERY_USE_MULTI_SCHEMA_KEY = 'queryUseMultiSchema';