diff --git a/webapp/packages/core-cli/configs/webpack.config.js b/webapp/packages/core-cli/configs/webpack.config.js index bff5c17322..a3cf90a543 100644 --- a/webapp/packages/core-cli/configs/webpack.config.js +++ b/webapp/packages/core-cli/configs/webpack.config.js @@ -1,3 +1,10 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ const { resolve } = require('path'); const PnpWebpackPlugin = require('pnp-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -150,9 +157,9 @@ module.exports = (env, argv) => { pathinfo: false, }, resolve: { - extensions: ['.ts', '.tsx', '.wasm', '.mjs', '.js', '.jsx', '.json'], + extensions: ['.ts', '.tsx', '.wasm', '.mjs', '.js', '.jsx', '.json', '.json5'], modules: nodeModules, - plugins: [PnpWebpackPlugin, new SourceAssetsResolver(['.json5', '.css', '.scss'])], + plugins: [PnpWebpackPlugin, new SourceAssetsResolver(['.json5', '.css', '.scss', '.json'])], }, resolveLoader: { modules: nodeModules, diff --git a/webapp/packages/core-connections/src/ConnectionInfoResource.ts b/webapp/packages/core-connections/src/ConnectionInfoResource.ts index bbef1a5d1f..49c37698d0 100644 --- a/webapp/packages/core-connections/src/ConnectionInfoResource.ts +++ b/webapp/packages/core-connections/src/ConnectionInfoResource.ts @@ -601,7 +601,7 @@ export class ConnectionInfoResource extends CachedMapResource false), z.boolean(), z.string(), z.number()]).pipe(z.coerce.boolean()); }, + + async loadLocale(code: string) { + let translation = {}; + switch (code) { + case 'ru': + translation = await import('zod-i18n-map/locales/ru/zod.json'); + break; + case 'en': + translation = await import('zod-i18n-map/locales/en/zod.json'); + break; + case 'it': + translation = await import('zod-i18n-map/locales/it/zod.json'); + break; + case 'zh': + translation = await import('zod-i18n-map/locales/zh-CN/zod.json'); + break; + } + + i18next.addResourceBundle(code, 'zod', translation, true); + }, + + async setLocale(code: string) { + i18next.changeLanguage(code); + }, }; export { z as schema }; diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts index d409689046..89881ba7e6 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts @@ -21,12 +21,16 @@ import { schema, schemaExtra } from '@cloudbeaver/core-utils'; import { DATA_EDITOR_SETTINGS_GROUP } from './DATA_EDITOR_SETTINGS_GROUP'; +const FETCH_MIN = 10; +const FETCH_MAX = 5000; +const DEFAULT_FETCH_SIZE = 200; + const defaultSettings = schema.object({ 'plugin.data-viewer.disableEdit': schemaExtra.stringedBoolean().default(false), 'plugin.data-viewer.disableCopyData': schemaExtra.stringedBoolean().default(false), - 'plugin.data-viewer.fetchMin': schema.coerce.number().min(10).default(100), - 'plugin.data-viewer.fetchMax': schema.coerce.number().min(10).default(5000), - 'resultset.maxrows': schema.coerce.number().min(10).default(200), + 'plugin.data-viewer.fetchMin': schema.coerce.number().min(FETCH_MIN).default(DEFAULT_FETCH_SIZE), + 'plugin.data-viewer.fetchMax': schema.coerce.number().min(FETCH_MIN).default(FETCH_MAX), + 'resultset.maxrows': schema.coerce.number().min(FETCH_MIN).max(FETCH_MAX).default(DEFAULT_FETCH_SIZE), }); export type DataViewerSettings = schema.infer; diff --git a/webapp/packages/plugin-localization/package.json b/webapp/packages/plugin-localization/package.json index 2bc940d27d..bacc99b3ad 100644 --- a/webapp/packages/plugin-localization/package.json +++ b/webapp/packages/plugin-localization/package.json @@ -17,7 +17,10 @@ "update-ts-references": "rimraf --glob dist && typescript-resolve-references" }, "dependencies": { - "@cloudbeaver/core-di": "~0.1.0" + "@cloudbeaver/core-di": "~0.1.0", + "@cloudbeaver/core-localization": "~0.1.0", + "@cloudbeaver/core-utils": "~0.1.0", + "mobx": "^6.12.0" }, "peerDependencies": {}, "devDependencies": { diff --git a/webapp/packages/plugin-localization/src/PluginBootstrap.ts b/webapp/packages/plugin-localization/src/PluginBootstrap.ts index 09687f9836..2297d1ed03 100644 --- a/webapp/packages/plugin-localization/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-localization/src/PluginBootstrap.ts @@ -5,11 +5,29 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ +import { autorun, type IReactionDisposer } from 'mobx'; + import { Bootstrap, injectable } from '@cloudbeaver/core-di'; +import { LocalizationService } from '@cloudbeaver/core-localization'; +import { schemaExtra } from '@cloudbeaver/core-utils'; @injectable() export class PluginBootstrap extends Bootstrap { - constructor() { + private reactionDisposer: IReactionDisposer | null; + constructor(private readonly localizationService: LocalizationService) { super(); + this.reactionDisposer = null; + } + + register(): void { + this.reactionDisposer = autorun(() => schemaExtra.setLocale(this.localizationService.currentLanguage)); + this.localizationService.addProvider(async locale => { + await schemaExtra.loadLocale(locale); + return []; + }); + } + + dispose(): void { + this.reactionDisposer?.(); } } diff --git a/webapp/packages/plugin-localization/tsconfig.json b/webapp/packages/plugin-localization/tsconfig.json index 4a48d52a9c..55659bb8c2 100644 --- a/webapp/packages/plugin-localization/tsconfig.json +++ b/webapp/packages/plugin-localization/tsconfig.json @@ -8,6 +8,12 @@ "references": [ { "path": "../core-di/tsconfig.json" + }, + { + "path": "../core-localization/tsconfig.json" + }, + { + "path": "../core-utils/tsconfig.json" } ], "include": [ diff --git a/webapp/packages/plugin-object-viewer/package.json b/webapp/packages/plugin-object-viewer/package.json index f6ce1a07d4..d2766924e2 100644 --- a/webapp/packages/plugin-object-viewer/package.json +++ b/webapp/packages/plugin-object-viewer/package.json @@ -21,7 +21,6 @@ "@cloudbeaver/core-connections": "~0.1.0", "@cloudbeaver/core-data-context": "~0.1.0", "@cloudbeaver/core-di": "~0.1.0", - "@cloudbeaver/core-dialogs": "~0.1.0", "@cloudbeaver/core-events": "~0.1.0", "@cloudbeaver/core-executor": "~0.1.0", "@cloudbeaver/core-localization": "~0.1.0", diff --git a/webapp/packages/plugin-object-viewer/tsconfig.json b/webapp/packages/plugin-object-viewer/tsconfig.json index 180c20dba1..8a811e5f49 100644 --- a/webapp/packages/plugin-object-viewer/tsconfig.json +++ b/webapp/packages/plugin-object-viewer/tsconfig.json @@ -18,9 +18,6 @@ { "path": "../core-di/tsconfig.json" }, - { - "path": "../core-dialogs/tsconfig.json" - }, { "path": "../core-events/tsconfig.json" }, diff --git a/webapp/packages/plugin-settings-panel/src/SettingsPanel/Setting.tsx b/webapp/packages/plugin-settings-panel/src/SettingsPanel/Setting.tsx index 58625931f5..aa9c6a5feb 100644 --- a/webapp/packages/plugin-settings-panel/src/SettingsPanel/Setting.tsx +++ b/webapp/packages/plugin-settings-panel/src/SettingsPanel/Setting.tsx @@ -61,7 +61,7 @@ export const Setting = observer(function Setting({ source, setting }) { return null; } - return schemaValidationError(result.error).toString(); + return schemaValidationError(result.error, { prefix: null }).toString(); }); function handleChange(value: any) { diff --git a/webapp/packages/plugin-user-profile/src/UserProfileForm/UserAuthenticationPart/UserProfileFormAuthenticationPart.ts b/webapp/packages/plugin-user-profile/src/UserProfileForm/UserAuthenticationPart/UserProfileFormAuthenticationPart.ts index bc938e2251..c8b53684ad 100644 --- a/webapp/packages/plugin-user-profile/src/UserProfileForm/UserAuthenticationPart/UserProfileFormAuthenticationPart.ts +++ b/webapp/packages/plugin-user-profile/src/UserProfileForm/UserAuthenticationPart/UserProfileFormAuthenticationPart.ts @@ -65,7 +65,7 @@ export class UserProfileFormAuthenticationPart extends FormPart