From fec9e856f6d8c2612e688a9f4189fcf796d59ed0 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 9 Apr 2024 17:49:34 +0800 Subject: [PATCH 1/2] fix: deprecated settings tests (#2538) --- .../expectDeprecatedSettingMessage.ts | 4 ++-- .../src/createSettingsAliasResolver.test.ts | 11 +++++++++-- .../core-settings/src/createSettingsAliasResolver.ts | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts b/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts index 0ae2cf2a0b..d9e937d7bd 100644 --- a/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts +++ b/webapp/packages/core-settings/src/__custom_mocks__/expectDeprecatedSettingMessage.ts @@ -7,7 +7,7 @@ */ import { addKnownWarn, consoleSpy } from '@cloudbeaver/tests-runner'; -const DEPRECATED_SETTING_MESSAGE_REGEX = /You are using deprecated settings.*/; +const DEPRECATED_SETTING_MESSAGE_REGEX = /You have deprecated settings:*/; beforeAll(async () => { addKnownWarn(DEPRECATED_SETTING_MESSAGE_REGEX); @@ -15,7 +15,7 @@ beforeAll(async () => { export function expectDeprecatedSettingMessage(deprecated?: string, key?: string) { if (deprecated && key) { - expect(consoleSpy.warn).toHaveBeenCalledWith(expect.stringMatching(`You are using deprecated settings: "${deprecated}". Use "${key}" instead.`)); + expect(consoleSpy.warn).toHaveBeenCalledWith(expect.stringMatching(`You have deprecated settings: "${deprecated}". Use "${key}" instead.`)); } else { expect(consoleSpy.warn).toHaveBeenCalledWith(expect.stringMatching(DEPRECATED_SETTING_MESSAGE_REGEX)); } diff --git a/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts b/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts index ff9a4d21c7..746996751d 100644 --- a/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts +++ b/webapp/packages/core-settings/src/createSettingsAliasResolver.test.ts @@ -9,7 +9,7 @@ import '@testing-library/jest-dom'; import { SyncExecutor } from '@cloudbeaver/core-executor'; -import { expectDeprecatedSettingMessage } from './__custom_mocks__/expectDeprecatedSettingMessage'; +import { expectDeprecatedSettingMessage, expectNoDeprecatedSettingMessage } from './__custom_mocks__/expectDeprecatedSettingMessage'; import { createSettingsAliasResolver } from './createSettingsAliasResolver'; import type { ISettingsSource } from './ISettingsSource'; @@ -52,9 +52,16 @@ function createResolver(settings: Record) { }); } -test('Deprecated setting extracted', async () => { +test('Deprecated setting ignored', async () => { const resolver = createResolver(newSettings); + expect(resolver.has('value')).toBe(false); + expectNoDeprecatedSettingMessage(); +}); + +test('Deprecated setting extracted', async () => { + const resolver = createResolver(deprecatedSettings); + expect(resolver.has('value')).toBe(true); expect(resolver.getValue('value')).toBe('deprecatedValue'); expectDeprecatedSettingMessage('deprecated', 'value'); diff --git a/webapp/packages/core-settings/src/createSettingsAliasResolver.ts b/webapp/packages/core-settings/src/createSettingsAliasResolver.ts index fcd10580ac..a032f6703f 100644 --- a/webapp/packages/core-settings/src/createSettingsAliasResolver.ts +++ b/webapp/packages/core-settings/src/createSettingsAliasResolver.ts @@ -69,7 +69,7 @@ export function createSettingsAliasResolver Date: Tue, 9 Apr 2024 11:53:02 +0200 Subject: [PATCH 2/2] CB-4960 remove data import button from query sources (#2529) * CB-4960 remove data import button from query sources * CB-4960 show import button only in container data source * CB-4960 show import button on json tab --------- Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../plugin-data-import/src/DataImportBootstrap.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/webapp/packages/plugin-data-import/src/DataImportBootstrap.ts b/webapp/packages/plugin-data-import/src/DataImportBootstrap.ts index 5d9e9408e6..e93e016053 100644 --- a/webapp/packages/plugin-data-import/src/DataImportBootstrap.ts +++ b/webapp/packages/plugin-data-import/src/DataImportBootstrap.ts @@ -9,10 +9,10 @@ import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs'; import { ACTION_IMPORT, ActionService, DATA_CONTEXT_MENU, menuExtractItems, MenuService } from '@cloudbeaver/core-view'; import { + ContainerDataSource, DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX, DATA_VIEWER_DATA_MODEL_ACTIONS_MENU, - DatabaseEditAction, } from '@cloudbeaver/plugin-data-viewer'; import { DataImportDialogLazy } from './DataImportDialog/DataImportDialogLazy'; @@ -42,12 +42,8 @@ export class DataImportBootstrap extends Bootstrap { } if (action === ACTION_IMPORT) { - if (model.isReadonly(resultIndex)) { - return false; - } - - const editor = model.source.getActionImplementation(resultIndex, DatabaseEditAction); - return editor?.hasFeature('add') === true; + const isContainer = model.source instanceof ContainerDataSource; + return !model.isReadonly(resultIndex) && isContainer; } return [ACTION_IMPORT].includes(action);