From d96b9e94adb27e4278dfae726f6a243437dc4b87 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Wed, 7 Feb 2024 17:31:19 +0100 Subject: [PATCH] Cb 4633 unit tests for utils (#2357) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CB-4633 blobToBase64 unit tests * СB-4633 importLazyComponent tests * CB-4633 OrderedMap unit tests * CB-4633 removed test time limit from blobToBase64 test * CB-4633 adds to ordered map unit tests for edge cases * CB-4633 importLazy moved to core-blocks * CB-4633 adds update-ts-references --------- Co-authored-by: s.teleshev --- webapp/packages/core-app/src/BodyLazy.ts | 2 +- .../__custom__mocks__/ErrorBoundaryMock.tsx | 28 +++ .../src/importLazyComponent.test.tsx | 43 +++++ .../src/importLazyComponent.ts | 0 webapp/packages/core-blocks/src/index.ts | 1 + webapp/packages/core-utils/package.json | 2 - .../core-utils/src/OrderedMap.test.ts | 170 ++++++++++++++++++ .../core-utils/src/blobToBase64.test.ts | 34 ++++ webapp/packages/core-utils/src/index.ts | 1 - .../plugin-codemirror6/src/EditorLoader.ts | 2 +- .../src/DataExportMenuService.ts | 3 +- .../CellFormatters/TextFormatter.tsx | 4 +- .../src/SpreadsheetBootstrap.ts | 2 +- .../src/DdlViewerBootstrap.ts | 2 +- .../packages/plugin-gis-viewer/package.json | 2 +- .../plugin-help/src/PluginBootstrap.ts | 3 +- .../src/LogViewer/LogViewerBootstrap.ts | 2 +- .../src/TreeNew/NodeControlLazy.ts | 2 +- .../src/TreeNew/NodeLazy.ts | 2 +- .../src/TreeNew/TreeLazy.ts | 2 +- .../package.json | 4 +- .../SettingsAdministrationPluginBootstrap.ts | 2 +- .../tsconfig.json | 3 - .../src/SettingsPanel/SettingsLazy.ts | 2 +- .../src/SqlResultTabs/SqlResultPanel.tsx | 2 +- .../plugin-sql-generator/package.json | 1 - .../src/ScriptPreview/ScriptPreviewService.ts | 2 +- .../SqlGenerators/SqlGeneratorsBootstrap.ts | 2 +- .../plugin-sql-generator/tsconfig.json | 3 - .../package.json | 1 - .../src/PluginBootstrap.ts | 2 +- .../tsconfig.json | 3 - 32 files changed, 298 insertions(+), 36 deletions(-) create mode 100644 webapp/packages/core-blocks/src/__custom__mocks__/ErrorBoundaryMock.tsx create mode 100644 webapp/packages/core-blocks/src/importLazyComponent.test.tsx rename webapp/packages/{core-utils => core-blocks}/src/importLazyComponent.ts (100%) create mode 100644 webapp/packages/core-utils/src/OrderedMap.test.ts create mode 100644 webapp/packages/core-utils/src/blobToBase64.test.ts diff --git a/webapp/packages/core-app/src/BodyLazy.ts b/webapp/packages/core-app/src/BodyLazy.ts index 11567db4b6..4e12407945 100644 --- a/webapp/packages/core-app/src/BodyLazy.ts +++ b/webapp/packages/core-app/src/BodyLazy.ts @@ -5,6 +5,6 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; export const BodyLazy = importLazyComponent(() => import('./Body').then(m => m.Body)); diff --git a/webapp/packages/core-blocks/src/__custom__mocks__/ErrorBoundaryMock.tsx b/webapp/packages/core-blocks/src/__custom__mocks__/ErrorBoundaryMock.tsx new file mode 100644 index 0000000000..ddf2ab1059 --- /dev/null +++ b/webapp/packages/core-blocks/src/__custom__mocks__/ErrorBoundaryMock.tsx @@ -0,0 +1,28 @@ +import React from 'react'; + +type Props = { + children: React.ReactNode; +}; + +type State = { + hasError: boolean; + error: any | null; +}; +export default class ErrorBoundary extends React.Component { + constructor(props: any) { + super(props); + this.state = { hasError: false, error: null }; + } + + static getDerivedStateFromError(error: any) { + return { hasError: true, error }; + } + + render() { + if (this.state.hasError) { + return

{this.state.error.message}

; + } + + return this.props.children; + } +} diff --git a/webapp/packages/core-blocks/src/importLazyComponent.test.tsx b/webapp/packages/core-blocks/src/importLazyComponent.test.tsx new file mode 100644 index 0000000000..8e35ed33e3 --- /dev/null +++ b/webapp/packages/core-blocks/src/importLazyComponent.test.tsx @@ -0,0 +1,43 @@ +import { render, screen, waitFor } from '@testing-library/react'; +import React, { Suspense } from 'react'; + +import ErrorBoundary from './__custom__mocks__/ErrorBoundaryMock'; +import { importLazyComponent } from './importLazyComponent'; + +describe('importLazyComponent', () => { + const fallback = 'Loading...'; + + it('should render the lazy component', async () => { + const loadedText = 'Lazy Component'; + const mockComponent: React.FC = () =>
{loadedText}
; + const componentImporter = jest.fn(() => Promise.resolve(mockComponent)); + const LazyComponent = importLazyComponent(componentImporter); + render( + + + , + ); + + expect(screen.getByText(fallback)).toBeTruthy(); + await waitFor(() => expect(screen.getByText(loadedText)).toBeTruthy()); + expect(componentImporter).toHaveBeenCalled(); + }); + + it('should render the error boundary if rejects with an error', async () => { + const errorText = 'Error'; + const componentImporter = jest.fn(() => Promise.reject(new Error(errorText))); + const LazyComponent = importLazyComponent(componentImporter as any); + + render( + + + + + , + ); + + expect(screen.getByText(fallback)).toBeTruthy(); + await waitFor(() => expect(screen.getByText(errorText)).toBeTruthy()); + expect(componentImporter).toHaveBeenCalled(); + }); +}); diff --git a/webapp/packages/core-utils/src/importLazyComponent.ts b/webapp/packages/core-blocks/src/importLazyComponent.ts similarity index 100% rename from webapp/packages/core-utils/src/importLazyComponent.ts rename to webapp/packages/core-blocks/src/importLazyComponent.ts diff --git a/webapp/packages/core-blocks/src/index.ts b/webapp/packages/core-blocks/src/index.ts index dae9b93393..39cb6cd39d 100644 --- a/webapp/packages/core-blocks/src/index.ts +++ b/webapp/packages/core-blocks/src/index.ts @@ -229,3 +229,4 @@ export * from './useUserData'; export * from './useMergeRefs'; export * from './usePasswordValidation'; export * from './manifest'; +export * from './importLazyComponent'; diff --git a/webapp/packages/core-utils/package.json b/webapp/packages/core-utils/package.json index ec5e63e248..cb6c9e7b07 100644 --- a/webapp/packages/core-utils/package.json +++ b/webapp/packages/core-utils/package.json @@ -24,7 +24,6 @@ "fast-deep-equal": "^3.1.3", "md5": "^2.3.0", "mobx": "^6.12.0", - "react": "^18.2.0", "underscore": "^1.13.6", "uuid": "^9.0.1", "whatwg-mimetype": "^4.0.0", @@ -35,7 +34,6 @@ "devDependencies": { "@types/jest": "^29.5.10", "@types/md5": "~2.3.5", - "@types/react": "^18.2.42", "@types/underscore": "^1.11.15", "@types/uuid": "~9.0.7", "typescript": "^5.3.2" diff --git a/webapp/packages/core-utils/src/OrderedMap.test.ts b/webapp/packages/core-utils/src/OrderedMap.test.ts new file mode 100644 index 0000000000..32dfc12ee2 --- /dev/null +++ b/webapp/packages/core-utils/src/OrderedMap.test.ts @@ -0,0 +1,170 @@ +import { OrderedMap } from './OrderedMap'; + +describe('OrderedMap', () => { + it('should add and get items', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(2, 'two'); + map.add(3, 'three'); + map.add(Infinity, 'infinity'); + map.add(NaN, 'nan'); + + expect(map.get(1)).toBe('one'); + expect(map.get(2)).toBe('two'); + expect(map.get(3)).toBe('three'); + expect(map.get(Infinity)).toBe('infinity'); + expect(map.get(NaN)).toBe('nan'); + }); + + it('should not get not exist item and return undefined', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(2, 'two'); + map.add(3, 'three'); + + expect(map.get(4)).toBeUndefined(); + expect(map.get(Infinity)).toBeUndefined(); + expect(map.get(NaN)).toBeUndefined(); + }); + + it('should addValue and get items', () => { + const toKey = (v: string) => v.length; + const map = new OrderedMap(toKey); + map.addValue('one'); + map.addValue('twoo'); + map.addValue('three'); + + expect(map.get(3)).toBe('one'); + expect(map.get(4)).toBe('twoo'); + expect(map.get(5)).toBe('three'); + }); + + it('should not override with addValue if it already exists', () => { + const toKey = (v: string) => v.length; + const map = new OrderedMap(toKey); + map.addValue('one'); + map.addValue('twoo'); + map.addValue('three'); + map.addValue('four'); + + expect(map.get(4)).toBe('twoo'); + }); + + it('should not addValue if no key fn', () => { + const map = new OrderedMap(); + expect(() => map.addValue('one')).toThrow(); + }); + + it('should be ordered', () => { + const map = new OrderedMap(); + map.add(3, 'three'); + map.add(1, 'one'); + map.add(2, 'two'); + + expect(map.keys).toEqual([3, 1, 2]); + expect(map.values).toEqual(['three', 'one', 'two']); + }); + + it('should has items', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(2, 'two'); + map.add(3, 'three'); + map.add(Infinity, 'infinity'); + map.add(NaN, 'nan'); + + expect(map.has(1)).toBeTruthy(); + expect(map.has(2)).toBeTruthy(); + expect(map.has(3)).toBeTruthy(); + expect(map.has(Infinity)).toBeTruthy(); + expect(map.has(NaN)).toBeTruthy(); + }); + + it('should not override items', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(1, 'two'); + map.add(Infinity, 'infinity'); + map.add(Infinity, 'infinity2'); + map.add(NaN, 'nan'); + map.add(NaN, 'nan2'); + + expect(map.get(1)).toBe('one'); + expect(map.get(Infinity)).toBe('infinity'); + expect(map.get(NaN)).toBe('nan'); + }); + + it('should remove items', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(2, 'two'); + map.add(3, 'three'); + + map.remove(2); + + expect(map.get(2)).toBeUndefined(); + expect(map.keys).toEqual([1, 3]); + expect(map.values).toEqual(['one', 'three']); + }); + + it('should not have non-existing items after removal', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(2, 'two'); + map.add(3, 'three'); + + expect(map.has(4)).toBeFalsy(); + expect(map.get(4)).toBeUndefined(); + map.remove(4); + expect(map.has(4)).toBeFalsy(); + expect(map.get(4)).toBeUndefined(); + }); + + it('should remove all items', () => { + const map = new OrderedMap(); + map.add(1, 'one'); + map.add(2, 'two'); + map.add(3, 'three'); + + map.removeAll(); + + expect(map.keys).toEqual([]); + expect(map.values).toEqual([]); + }); + + it('should throw bulk update items if no toKey fn', () => { + const map = new OrderedMap(); + + expect(() => map.bulkUpdate(['one', 'two', 'three'])).toThrow(); + }); + + it('should bulk update items', () => { + const toKey = (v: string) => v.length; + const map = new OrderedMap(toKey); + map.bulkUpdate(['o', 'tw', 'thr']); + + expect(map.keys).toEqual([1, 2, 3]); + expect(map.values).toEqual(['o', 'tw', 'thr']); + }); + + it('should bulk rewrite items', () => { + const toKey = (v: string) => v.length; + const map = new OrderedMap(toKey); + map.bulkUpdate(['o', 'tw', 'thr']); + map.bulkRewrite(['one', 'twoo', 'three']); + + expect(map.keys).toEqual([3, 4, 5]); + expect(map.values).toEqual(['one', 'twoo', 'three']); + }); + + it('should sort items', () => { + const map = new OrderedMap(); + map.add(3, 'c'); + map.add(1, 'a'); + map.add(2, 'b'); + + map.sort((a, b) => (a > b ? 1 : -1)); + + expect(map.keys).toEqual([1, 2, 3]); + }); +}); diff --git a/webapp/packages/core-utils/src/blobToBase64.test.ts b/webapp/packages/core-utils/src/blobToBase64.test.ts new file mode 100644 index 0000000000..ca3667c1dd --- /dev/null +++ b/webapp/packages/core-utils/src/blobToBase64.test.ts @@ -0,0 +1,34 @@ +import { blobToBase64 } from './blobToBase64'; + +describe('blobToBase64', () => { + it('converts blob to base64', async () => { + const blob = new Blob(['test'], { type: 'text/plain' }); + const base64 = await blobToBase64(blob); + + expect(base64).toBe('data:text/plain;base64,dGVzdA=='); + }); + + it('converts blob to base64 with slice', async () => { + const blob = new Blob(['this is a test with longer text']); + const base64 = await blobToBase64(blob, 20); + + expect(base64).toBe('data:application/octet-stream;base64,dGhpcyBpcyBhIHRlc3Qgd2l0aCA='); + }); + + it('calls readAsDataURL', async () => { + const readAsDataURL = jest.fn(blob => Promise.resolve(blob)); + Object.defineProperty(global, 'FileReader', { + writable: true, + value: jest.fn().mockImplementation(() => ({ + readAsDataURL, + })), + }); + jest.useFakeTimers(); + + const blob = new Blob(['test'], { type: 'text/plain' }); + + blobToBase64(blob); + + expect(readAsDataURL).toHaveBeenCalledWith(blob); + }); +}); diff --git a/webapp/packages/core-utils/src/index.ts b/webapp/packages/core-utils/src/index.ts index c6dd61c238..053616dad3 100644 --- a/webapp/packages/core-utils/src/index.ts +++ b/webapp/packages/core-utils/src/index.ts @@ -8,7 +8,6 @@ export * from './Quadtree/index'; export * from './underscore'; -export * from './importLazyComponent'; export * from './base64ToBlob'; export * from './blobToBase64'; export * from './base64ToHex'; diff --git a/webapp/packages/plugin-codemirror6/src/EditorLoader.ts b/webapp/packages/plugin-codemirror6/src/EditorLoader.ts index d8327d8663..84f909daf8 100644 --- a/webapp/packages/plugin-codemirror6/src/EditorLoader.ts +++ b/webapp/packages/plugin-codemirror6/src/EditorLoader.ts @@ -5,6 +5,6 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; export const EditorLoader = importLazyComponent(() => import('./Editor').then(m => m.Editor)); diff --git a/webapp/packages/plugin-data-export/src/DataExportMenuService.ts b/webapp/packages/plugin-data-export/src/DataExportMenuService.ts index d2e045fd8f..3cd8d03a4d 100644 --- a/webapp/packages/plugin-data-export/src/DataExportMenuService.ts +++ b/webapp/packages/plugin-data-export/src/DataExportMenuService.ts @@ -5,13 +5,14 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { createConnectionParam, DATA_CONTEXT_CONNECTION } from '@cloudbeaver/core-connections'; import { injectable } from '@cloudbeaver/core-di'; import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { LocalizationService } from '@cloudbeaver/core-localization'; import { DATA_CONTEXT_NAV_NODE, EObjectFeature } from '@cloudbeaver/core-navigation-tree'; import { EAdminPermission, SessionPermissionsResource } from '@cloudbeaver/core-root'; -import { importLazyComponent, withTimestamp } from '@cloudbeaver/core-utils'; +import { withTimestamp } from '@cloudbeaver/core-utils'; import { ACTION_EXPORT, ActionService, DATA_CONTEXT_MENU, DATA_CONTEXT_MENU_NESTED, menuExtractItems, MenuService } from '@cloudbeaver/core-view'; import { DATA_CONTEXT_DV_DDM, diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/TextFormatter.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/TextFormatter.tsx index f56dca3a4a..14f4b317fb 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/TextFormatter.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/CellFormatters/TextFormatter.tsx @@ -8,8 +8,8 @@ import { observer } from 'mobx-react-lite'; import { useCallback, useContext, useEffect, useRef } from 'react'; -import { getComputed, IconOrImage, Loader, s, useS } from '@cloudbeaver/core-blocks'; -import { importLazyComponent, isValidUrl } from '@cloudbeaver/core-utils'; +import { getComputed, IconOrImage, importLazyComponent, Loader, s, useS } from '@cloudbeaver/core-blocks'; +import { isValidUrl } from '@cloudbeaver/core-utils'; import type { IResultSetRowKey } from '@cloudbeaver/plugin-data-viewer'; import type { RenderCellProps } from '@cloudbeaver/plugin-react-data-grid'; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts index 380febaa42..7a5726b7c4 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts @@ -5,10 +5,10 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { ExceptionsCatcherService } from '@cloudbeaver/core-events'; import { ResultDataFormat } from '@cloudbeaver/core-sdk'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { DataPresentationService } from '@cloudbeaver/plugin-data-viewer'; import { DataGridContextMenuCellEditingService } from './DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService'; diff --git a/webapp/packages/plugin-ddl-viewer/src/DdlViewerBootstrap.ts b/webapp/packages/plugin-ddl-viewer/src/DdlViewerBootstrap.ts index e9ff3ae085..3c6fd1e126 100644 --- a/webapp/packages/plugin-ddl-viewer/src/DdlViewerBootstrap.ts +++ b/webapp/packages/plugin-ddl-viewer/src/DdlViewerBootstrap.ts @@ -5,9 +5,9 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { EObjectFeature, NavNodeInfoResource } from '@cloudbeaver/core-navigation-tree'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { NavNodeViewService } from '@cloudbeaver/plugin-navigation-tree'; import { DDLViewerFooterService } from './DdlViewer/DDLViewerFooterService'; diff --git a/webapp/packages/plugin-gis-viewer/package.json b/webapp/packages/plugin-gis-viewer/package.json index f302d6d720..50b1f2976a 100644 --- a/webapp/packages/plugin-gis-viewer/package.json +++ b/webapp/packages/plugin-gis-viewer/package.json @@ -35,10 +35,10 @@ "peerDependencies": {}, "devDependencies": { "@types/leaflet": "^1.9.8", + "@types/proj4": "^2.5.5", "@types/react": "^18.2.42", "@types/react-leaflet": "~3.0.0", "@types/wellknown": "~0.5.8", - "@types/proj4": "^2.5.5", "leaflet": "^1.9.4", "typescript": "^5.3.2", "typescript-plugin-css-modules": "^5.0.2" diff --git a/webapp/packages/plugin-help/src/PluginBootstrap.ts b/webapp/packages/plugin-help/src/PluginBootstrap.ts index 6b7b615855..d18c6dca5b 100644 --- a/webapp/packages/plugin-help/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-help/src/PluginBootstrap.ts @@ -6,13 +6,12 @@ * you may not use this file except in compliance with the License. */ import { AppScreenService } from '@cloudbeaver/core-app'; -import { ActionSnackbar } from '@cloudbeaver/core-blocks'; +import { ActionSnackbar, importLazyComponent } from '@cloudbeaver/core-blocks'; import { LocalStorageSaveService } from '@cloudbeaver/core-browser'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { ENotificationType, INotification, NotificationService } from '@cloudbeaver/core-events'; import { ScreenService } from '@cloudbeaver/core-routing'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { ActionService, menuExtractItems, MenuService } from '@cloudbeaver/core-view'; import { MENU_APP_STATE } from '@cloudbeaver/plugin-top-app-bar'; diff --git a/webapp/packages/plugin-log-viewer/src/LogViewer/LogViewerBootstrap.ts b/webapp/packages/plugin-log-viewer/src/LogViewer/LogViewerBootstrap.ts index 9bf712c858..4e43df3137 100644 --- a/webapp/packages/plugin-log-viewer/src/LogViewer/LogViewerBootstrap.ts +++ b/webapp/packages/plugin-log-viewer/src/LogViewer/LogViewerBootstrap.ts @@ -5,8 +5,8 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { ActionService, DATA_CONTEXT_MENU, menuExtractItems, MenuService } from '@cloudbeaver/core-view'; import { MENU_TOOLS, ToolsPanelService } from '@cloudbeaver/plugin-tools-panel'; diff --git a/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeControlLazy.ts b/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeControlLazy.ts index 92b1eac49e..0807ca27c6 100644 --- a/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeControlLazy.ts +++ b/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeControlLazy.ts @@ -5,6 +5,6 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; export const NodeControl = importLazyComponent(() => import('./NodeControl').then(m => m.NodeControl)); diff --git a/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeLazy.ts b/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeLazy.ts index 45c1edc530..da870f42c2 100644 --- a/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeLazy.ts +++ b/webapp/packages/plugin-navigation-tree/src/TreeNew/NodeLazy.ts @@ -5,6 +5,6 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; export const Node = importLazyComponent(() => import('./Node').then(m => m.Node)); diff --git a/webapp/packages/plugin-navigation-tree/src/TreeNew/TreeLazy.ts b/webapp/packages/plugin-navigation-tree/src/TreeNew/TreeLazy.ts index f53d85411e..77f0f129d0 100644 --- a/webapp/packages/plugin-navigation-tree/src/TreeNew/TreeLazy.ts +++ b/webapp/packages/plugin-navigation-tree/src/TreeNew/TreeLazy.ts @@ -5,6 +5,6 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; export const Tree = importLazyComponent(() => import('./Tree').then(m => m.Tree)); diff --git a/webapp/packages/plugin-settings-administration/package.json b/webapp/packages/plugin-settings-administration/package.json index e9239c3add..852236881b 100644 --- a/webapp/packages/plugin-settings-administration/package.json +++ b/webapp/packages/plugin-settings-administration/package.json @@ -25,7 +25,6 @@ "@cloudbeaver/core-localization": "~0.1.0", "@cloudbeaver/core-root": "~0.1.0", "@cloudbeaver/core-ui": "~0.1.0", - "@cloudbeaver/core-utils": "~0.1.0", "@cloudbeaver/plugin-settings-panel": "~0.1.0", "mobx-react-lite": "^4.0.5", "react": "^18.2.0", @@ -34,6 +33,7 @@ "peerDependencies": {}, "devDependencies": { "@types/react": "^18.2.42", - "typescript": "^5.3.2" + "typescript": "^5.3.2", + "typescript-plugin-css-modules": "^5.0.2" } } diff --git a/webapp/packages/plugin-settings-administration/src/SettingsAdministrationPluginBootstrap.ts b/webapp/packages/plugin-settings-administration/src/SettingsAdministrationPluginBootstrap.ts index d5d3d650ec..5dc1d5b774 100644 --- a/webapp/packages/plugin-settings-administration/src/SettingsAdministrationPluginBootstrap.ts +++ b/webapp/packages/plugin-settings-administration/src/SettingsAdministrationPluginBootstrap.ts @@ -6,8 +6,8 @@ * you may not use this file except in compliance with the License. */ import { AdministrationItemService, AdministrationItemType } from '@cloudbeaver/core-administration'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; const SettingsAdministration = importLazyComponent(() => import('./SettingsAdministration').then(module => module.SettingsAdministration)); const SettingsDrawerItem = importLazyComponent(() => import('./SettingsDrawerItem').then(module => module.SettingsDrawerItem)); diff --git a/webapp/packages/plugin-settings-administration/tsconfig.json b/webapp/packages/plugin-settings-administration/tsconfig.json index 835eff9384..21c92d16a3 100644 --- a/webapp/packages/plugin-settings-administration/tsconfig.json +++ b/webapp/packages/plugin-settings-administration/tsconfig.json @@ -27,9 +27,6 @@ { "path": "../core-ui/tsconfig.json" }, - { - "path": "../core-utils/tsconfig.json" - }, { "path": "../plugin-settings-panel/tsconfig.json" } diff --git a/webapp/packages/plugin-settings-panel/src/SettingsPanel/SettingsLazy.ts b/webapp/packages/plugin-settings-panel/src/SettingsPanel/SettingsLazy.ts index b5066c887c..32be743a2a 100644 --- a/webapp/packages/plugin-settings-panel/src/SettingsPanel/SettingsLazy.ts +++ b/webapp/packages/plugin-settings-panel/src/SettingsPanel/SettingsLazy.ts @@ -5,6 +5,6 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; export const Settings = importLazyComponent(() => import('./Settings').then(m => m.Settings)); diff --git a/webapp/packages/plugin-sql-editor/src/SqlResultTabs/SqlResultPanel.tsx b/webapp/packages/plugin-sql-editor/src/SqlResultTabs/SqlResultPanel.tsx index 4426870641..e13e6dc344 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlResultTabs/SqlResultPanel.tsx +++ b/webapp/packages/plugin-sql-editor/src/SqlResultTabs/SqlResultPanel.tsx @@ -9,7 +9,7 @@ import { observer } from 'mobx-react-lite'; import React from 'react'; import styled, { css } from 'reshadow'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import type { ISqlEditorTabState } from '../ISqlEditorTabState'; diff --git a/webapp/packages/plugin-sql-generator/package.json b/webapp/packages/plugin-sql-generator/package.json index 5916ceabeb..eb5e2f9283 100644 --- a/webapp/packages/plugin-sql-generator/package.json +++ b/webapp/packages/plugin-sql-generator/package.json @@ -27,7 +27,6 @@ "@cloudbeaver/core-navigation-tree": "~0.1.0", "@cloudbeaver/core-resource": "~0.1.0", "@cloudbeaver/core-sdk": "~0.1.0", - "@cloudbeaver/core-utils": "~0.1.0", "@cloudbeaver/core-view": "~0.1.0", "@cloudbeaver/plugin-codemirror6": "~0.1.0", "@cloudbeaver/plugin-data-viewer": "~0.1.0", diff --git a/webapp/packages/plugin-sql-generator/src/ScriptPreview/ScriptPreviewService.ts b/webapp/packages/plugin-sql-generator/src/ScriptPreview/ScriptPreviewService.ts index acb864edf3..3b71aea5e6 100644 --- a/webapp/packages/plugin-sql-generator/src/ScriptPreview/ScriptPreviewService.ts +++ b/webapp/packages/plugin-sql-generator/src/ScriptPreview/ScriptPreviewService.ts @@ -5,11 +5,11 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { injectable } from '@cloudbeaver/core-di'; import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { NotificationService } from '@cloudbeaver/core-events'; import { GraphQLService, ResultDataFormat, UpdateResultsDataBatchScriptMutationVariables } from '@cloudbeaver/core-sdk'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { DocumentEditAction, type IDatabaseDataModel, ResultSetEditAction } from '@cloudbeaver/plugin-data-viewer'; const ScriptPreviewDialog = importLazyComponent(() => import('./ScriptPreviewDialog').then(m => m.ScriptPreviewDialog)); diff --git a/webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsBootstrap.ts b/webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsBootstrap.ts index 6abaa910e1..fd8e269610 100644 --- a/webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsBootstrap.ts +++ b/webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsBootstrap.ts @@ -5,11 +5,11 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { DATA_CONTEXT_NAV_NODE, EObjectFeature } from '@cloudbeaver/core-navigation-tree'; import { getCachedMapResourceLoaderState } from '@cloudbeaver/core-resource'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { DATA_CONTEXT_MENU, DATA_CONTEXT_MENU_NESTED, MenuBaseItem, MenuService } from '@cloudbeaver/core-view'; import { MENU_SQL_GENERATORS } from './MENU_SQL_GENERATORS'; diff --git a/webapp/packages/plugin-sql-generator/tsconfig.json b/webapp/packages/plugin-sql-generator/tsconfig.json index da10ce04d5..933b6ec7a5 100644 --- a/webapp/packages/plugin-sql-generator/tsconfig.json +++ b/webapp/packages/plugin-sql-generator/tsconfig.json @@ -33,9 +33,6 @@ { "path": "../core-sdk/tsconfig.json" }, - { - "path": "../core-utils/tsconfig.json" - }, { "path": "../core-view/tsconfig.json" }, diff --git a/webapp/packages/plugin-version-update-administration/package.json b/webapp/packages/plugin-version-update-administration/package.json index 5ee8eaa36d..0543555044 100644 --- a/webapp/packages/plugin-version-update-administration/package.json +++ b/webapp/packages/plugin-version-update-administration/package.json @@ -24,7 +24,6 @@ "@cloudbeaver/core-resource": "~0.1.0", "@cloudbeaver/core-root": "~0.1.0", "@cloudbeaver/core-ui": "~0.1.0", - "@cloudbeaver/core-utils": "~0.1.0", "@cloudbeaver/core-version": "~0.1.0", "@cloudbeaver/core-version-update": "~0.1.0", "mobx-react-lite": "^4.0.5", diff --git a/webapp/packages/plugin-version-update-administration/src/PluginBootstrap.ts b/webapp/packages/plugin-version-update-administration/src/PluginBootstrap.ts index 502130187c..2e52cd3e4f 100644 --- a/webapp/packages/plugin-version-update-administration/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-version-update-administration/src/PluginBootstrap.ts @@ -6,8 +6,8 @@ * you may not use this file except in compliance with the License. */ import { AdministrationItemService, AdministrationItemType } from '@cloudbeaver/core-administration'; +import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; -import { importLazyComponent } from '@cloudbeaver/core-utils'; import { VersionUpdateService } from '@cloudbeaver/core-version-update'; const DockerUpdateInstructions = importLazyComponent(() => import('./DockerUpdateInstructions').then(m => m.DockerUpdateInstructions)); diff --git a/webapp/packages/plugin-version-update-administration/tsconfig.json b/webapp/packages/plugin-version-update-administration/tsconfig.json index 0bb37fe6d5..ae98b253df 100644 --- a/webapp/packages/plugin-version-update-administration/tsconfig.json +++ b/webapp/packages/plugin-version-update-administration/tsconfig.json @@ -27,9 +27,6 @@ { "path": "../core-ui/tsconfig.json" }, - { - "path": "../core-utils/tsconfig.json" - }, { "path": "../core-version-update/tsconfig.json" },