Skip to content
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

feat: option to hide domain #1094

Merged
merged 3 commits into from
Jul 30, 2024
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
2 changes: 2 additions & 0 deletions src/containers/UserSettings/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"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.showDomainDatabase.title": "Show domain database",

"settings.useQuerySettings.title": "Use query settings",
"settings.useQuerySettings.description": "Use query settings",

Expand Down
13 changes: 12 additions & 1 deletion src/containers/UserSettings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LANGUAGE_KEY,
QUERY_SETTINGS,
QUERY_USE_MULTI_SCHEMA_KEY,
SHOW_DOMAIN_DATABASE_KEY,
THEME_KEY,
USE_CLUSTER_BALANCER_AS_BACKEND_KEY,
USE_DIRECTORY_OPERATIONS,
Expand Down Expand Up @@ -109,6 +110,11 @@ export const usePaginatedTables: SettingProps = {
description: i18n('settings.usePaginatedTables.description'),
};

export const showDomainDatabase: SettingProps = {
settingKey: SHOW_DOMAIN_DATABASE_KEY,
title: i18n('settings.showDomainDatabase.title'),
};

export const useQuerySettings: SettingProps = {
settingKey: QUERY_SETTINGS,
title: i18n('settings.useQuerySettings.title'),
Expand Down Expand Up @@ -159,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',
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 {
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,
Expand Down Expand Up @@ -50,6 +51,7 @@ export const DEFAULT_USER_SETTINGS = {
[AUTO_REFRESH_INTERVAL]: 0,
[USE_DIRECTORY_OPERATIONS]: false,
[QUERY_SETTINGS]: false,
[SHOW_DOMAIN_DATABASE_KEY]: false,
} as const satisfies SettingsObject;

class SettingsManager {
Expand Down
14 changes: 11 additions & 3 deletions src/store/reducers/tenants/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import {createSelector} from '@reduxjs/toolkit';
import escapeRegExp from 'lodash/escapeRegExp';

import type {RootState} from '../..';
import {SHOW_DOMAIN_DATABASE_KEY} from '../../../lib';
import {EFlag} from '../../../types/api/enums';
import {ProblemFilterValues, selectProblemFilter} from '../settings/settings';
import {ProblemFilterValues, getSettingValue, selectProblemFilter} from '../settings/settings';
import type {ProblemFilterValue} from '../settings/types';

import {tenantsApi} from './tenants';
Expand Down Expand Up @@ -42,13 +43,20 @@ export const selectTenants = createSelector(
);
export const selectTenantsSearchValue = (state: TenantsStateSlice) => state.tenants.searchValue;

export const selectShowDomainDatabase = (state: RootState) =>
getSettingValue(state, SHOW_DOMAIN_DATABASE_KEY);

// ==== Complex selectors ====

export const selectFilteredTenants = createSelector(
[selectTenants, selectProblemFilter, selectTenantsSearchValue],
(tenants, problemFilter, searchQuery) => {
[selectTenants, selectProblemFilter, selectTenantsSearchValue, selectShowDomainDatabase],
(tenants, problemFilter, searchQuery, showDomainDatabase) => {
let result = filterTenantsByProblems(tenants, problemFilter);
result = filteredTenantsBySearch(result, searchQuery);
result =
!showDomainDatabase && result.length > 1
? result.filter((item) => item.Type !== 'Domain')
: result;

return result;
},
Expand Down
3 changes: 3 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export const TENANT_INITIAL_PAGE_KEY = 'saved_tenant_initial_tab';
// Old key value for backward compatibility
export const USE_PAGINATED_TABLES_KEY = 'useBackendParamsForTables';

// Setting to hide domain in database list
export const SHOW_DOMAIN_DATABASE_KEY = 'showDomainDatabase';

// Enable schema that supports multiple resultsets
export const QUERY_USE_MULTI_SCHEMA_KEY = 'queryUseMultiSchema';

Expand Down
Loading