Skip to content

Commit

Permalink
Merge branch 'devel' into CB-4178-te-cloud-storage-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgeniaBzzz authored Apr 9, 2024
2 parents 51db21a + 433eaac commit 4fb78d5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*/
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);
});

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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -52,9 +52,16 @@ function createResolver(settings: Record<any, any>) {
});
}

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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function createSettingsAliasResolver<TTarget extends schema.SomeZodObject
const oldKey = mapKey(key);
const has = source.has(oldKey);

if (!DEPRECATED_SETTINGS.has(oldKey)) {
if (has && !DEPRECATED_SETTINGS.has(oldKey)) {
console.warn(`You have deprecated settings: "${String(oldKey)}". Use "${key}" instead.`);
DEPRECATED_SETTINGS.add(oldKey);
}
Expand Down
10 changes: 3 additions & 7 deletions webapp/packages/plugin-data-import/src/DataImportBootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4fb78d5

Please sign in to comment.