refactor: CB-2243 product config structure

This commit is contained in:
Wroud
2022-07-19 17:36:13 +03:00
parent ff7bad888c
commit a3c4617960
32 changed files with 232 additions and 50 deletions
@@ -19,8 +19,8 @@ export type AdministrationSettings = typeof defaultSettings;
export class AdministrationSettingsService {
readonly settings: PluginSettings<AdministrationSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core.administration', defaultSettings);
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getCoreSettings('administration', defaultSettings);
}
isBase(feature: string): boolean {
@@ -22,11 +22,14 @@ const defaultSettings = {
export type CoreSettings = typeof defaultSettings;
/**
* @deprecated use plugin-log-viewer, core-navigation-tree settings instead
*/
@injectable()
export class CoreSettingsService {
readonly settings: PluginSettings<CoreSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core', defaultSettings);
this.settings = this.pluginManagerService.getDeprecatedPluginSettings('core', defaultSettings);
}
}
+1
View File
@@ -23,6 +23,7 @@ export * from './shared/NodesManager/NavNodeContextMenuService';
export * from './shared/NodesManager/NavNodeInfoResource';
export * from './shared/NodesManager/NavNodeManagerService';
export * from './shared/NodesManager/NavTreeResource';
export * from './shared/NodesManager/NavTreeSettingsService';
export * from './shared/NodesManager/nodeDeleteContext';
export * from './shared/NodesManager/NavNodeExtensionsService';
export * from './shared/NodesManager/NodeLink';
+4
View File
@@ -24,12 +24,14 @@ import { NavNodeInfoResource } from './shared/NodesManager/NavNodeInfoResource';
import { NavNodeManagerService } from './shared/NodesManager/NavNodeManagerService';
import { NavNodeViewService } from './shared/NodesManager/NavNodeView/NavNodeViewService';
import { NavTreeResource } from './shared/NodesManager/NavTreeResource';
import { NavTreeSettingsService } from './shared/NodesManager/NavTreeSettingsService';
import { SessionExpiredDialogService } from './shared/SessionExpireDialog/SessionExpiredDialogService';
import { SessionExpireWarningDialogService } from './shared/SessionExpireWarningDialog/SessionExpireWarningDialogService';
import { SqlGeneratorsBootstrap } from './shared/SqlGenerators/SqlGeneratorsBootstrap';
import { SqlGeneratorsResource } from './shared/SqlGenerators/SqlGeneratorsResource';
import { LogViewerBootstrap } from './shared/ToolsPanel/LogViewer/LogViewerBootstrap';
import { LogViewerService } from './shared/ToolsPanel/LogViewer/LogViewerService';
import { LogViewerSettingsService } from './shared/ToolsPanel/LogViewer/LogViewerSettingsService';
import { ToolsPanelService } from './shared/ToolsPanel/ToolsPanelService';
import { AdministrationTopAppBarBootstrapService } from './TopNavBar/AdministrationTopAppBarBootstrapService';
import { ConnectionSchemaManagerBootstrap } from './TopNavBar/ConnectionSchemaManager/ConnectionSchemaManagerBootstrap';
@@ -63,6 +65,8 @@ export const coreAppManifest: PluginManifest = {
TopNavService,
AppScreenService,
CoreSettingsService,
NavTreeSettingsService,
LogViewerSettingsService,
AdministrationTopAppBarBootstrapService,
AppLocaleService,
SessionExpiredDialogService,
@@ -25,6 +25,7 @@ import type { INodeActions } from './INodeActions';
import { getNodeDisplayName, NavNodeInfoResource } from './NavNodeInfoResource';
import { NavNodeManagerService } from './NavNodeManagerService';
import { NavTreeResource } from './NavTreeResource';
import { NavTreeSettingsService } from './NavTreeSettingsService';
import { nodeDeleteContext } from './nodeDeleteContext';
export interface INodeMenuData {
@@ -43,7 +44,8 @@ export class NavNodeContextMenuService extends Bootstrap {
private readonly menuService: MenuService,
private readonly coreSettingsService: CoreSettingsService,
private readonly localizationService: LocalizationService,
private readonly navNodeInfoResource: NavNodeInfoResource
private readonly navNodeInfoResource: NavNodeInfoResource,
private readonly navTreeSettingsService: NavTreeSettingsService
) {
super();
}
@@ -87,7 +89,9 @@ export class NavNodeContextMenuService extends Bootstrap {
}
if (action === ACTION_RENAME) {
const globalPermission = this.coreSettingsService.settings.getValue('app.metadata.editing');
const globalPermission = this.navTreeSettingsService.settings.isValueDefault('editing')
? this.coreSettingsService.settings.getValue('app.metadata.editing')
: this.navTreeSettingsService.settings.getValue('editing');
if (!globalPermission) {
return false;
@@ -97,7 +101,9 @@ export class NavNodeContextMenuService extends Bootstrap {
}
if (action === ACTION_DELETE) {
const globalPermission = this.coreSettingsService.settings.getValue('app.metadata.deleting');
const globalPermission = this.navTreeSettingsService.settings.isValueDefault('deleting')
? this.coreSettingsService.settings.getValue('app.metadata.deleting')
: this.navTreeSettingsService.settings.getValue('deleting');
if (!globalPermission) {
return false;
@@ -30,6 +30,7 @@ import { MetadataMap } from '@cloudbeaver/core-utils';
import { CoreSettingsService } from '../../CoreSettingsService';
import type { NavNode } from './EntityTypes';
import { NavNodeInfoResource, ROOT_NODE_PATH } from './NavNodeInfoResource';
import { NavTreeSettingsService } from './NavTreeSettingsService';
import { NodeManagerUtils } from './NodeManagerUtils';
// TODO: so much dirty
@@ -62,13 +63,18 @@ export class NavTreeResource extends CachedMapResource<string, string[]> {
protected metadata: MetadataMap<string, INodeMetadata>;
get childrenLimit(): number {
return this.coreSettingsService.settings.getValue('app.navigationTree.childrenLimit');
return (
this.navTreeSettingsService.settings.isValueDefault('childrenLimit')
? this.coreSettingsService.settings.getValue('app.navigationTree.childrenLimit')
: this.navTreeSettingsService.settings.getValue('childrenLimit')
);
}
constructor(
private readonly graphQLService: GraphQLService,
private readonly navNodeInfoResource: NavNodeInfoResource,
private readonly coreSettingsService: CoreSettingsService,
private readonly navTreeSettingsService: NavTreeSettingsService,
private readonly sessionDataResource: SessionDataResource,
private readonly connectionInfo: ConnectionInfoResource,
private readonly userInfoResource: UserInfoResource,
@@ -0,0 +1,28 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2022 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { injectable } from '@cloudbeaver/core-di';
import { PluginManagerService, PluginSettings } from '@cloudbeaver/core-plugin';
const defaultSettings = {
// temporary limit for all nodes children in app
childrenLimit: 500,
editing: true,
deleting: true,
};
export type NavTreeSettings = typeof defaultSettings;
@injectable()
export class NavTreeSettingsService {
readonly settings: PluginSettings<NavTreeSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getCoreSettings('navigation-tree', defaultSettings);
}
}
@@ -17,6 +17,7 @@ import { uuid } from '@cloudbeaver/core-utils';
import { CoreSettingsService } from '../../../CoreSettingsService';
import type { ILogEntry } from './ILogEntry';
import { LogViewerSettingsService } from './LogViewerSettingsService';
const logViewerSettingsKey = 'log-viewer';
@@ -46,6 +47,7 @@ export class LogViewerService {
private readonly notificationService: NotificationService,
private readonly permissionsService: PermissionsService,
private readonly permissionsResource: SessionPermissionsResource,
private readonly logViewerSettingsService: LogViewerSettingsService,
private readonly sessionExpireService: SessionExpireService
) {
@@ -80,8 +82,14 @@ export class LogViewerService {
}
this.failedRequestsCount = 0;
this.settings.active = true;
const refreshInterval = this.coreSettingsService.settings.getValue('app.logViewer.refreshTimeout');
this.maxFailedRequests = this.coreSettingsService.settings.getValue('app.logViewer.maxFailedRequests');
const refreshInterval = this.logViewerSettingsService.settings.isValueDefault('refreshTimeout')
? this.coreSettingsService.settings.getValue('app.logViewer.refreshTimeout')
: this.logViewerSettingsService.settings.getValue('refreshTimeout');
this.maxFailedRequests = this.logViewerSettingsService.settings.isValueDefault('maxFailedRequests')
? this.coreSettingsService.settings.getValue('app.logViewer.maxFailedRequests')
: this.logViewerSettingsService.settings.getValue('maxFailedRequests');
await this.updateLog();
this.runInterval(refreshInterval);
@@ -100,7 +108,10 @@ export class LogViewerService {
}
async loadLog(): Promise<ILogEntry[]> {
const maxLogEntries = this.coreSettingsService.settings.getValue('app.logViewer.logBatchSize');
const maxLogEntries = this.logViewerSettingsService.settings.isValueDefault('logBatchSize')
? this.coreSettingsService.settings.getValue('app.logViewer.logBatchSize')
: this.logViewerSettingsService.settings.getValue('logBatchSize');
const { log } = await this.graphQLService.sdk.readSessionLog({
maxEntries: maxLogEntries,
clearEntries: true,
@@ -114,7 +125,11 @@ export class LogViewerService {
private addNewEntries(entries: ILogEntry[]) {
this.log.unshift(...entries.reverse());
const maxLogEntries = this.coreSettingsService.settings.getValue('app.logViewer.maxLogRecords');
const maxLogEntries = this.logViewerSettingsService.settings.isValueDefault('maxLogRecords')
? this.coreSettingsService.settings.getValue('app.logViewer.maxLogRecords')
: this.logViewerSettingsService.settings.getValue('maxLogRecords');
if (this.log.length > maxLogEntries) {
this.log.splice(maxLogEntries, this.log.length - maxLogEntries);
}
@@ -134,9 +149,9 @@ export class LogViewerService {
try {
const newEntries = await this.loadLog();
this.addNewEntries(newEntries);
} catch (e: any) {
if (this.failedRequestsCount === 0 && !this.sessionExpireService.sessionExpired) {
this.notificationService.logException(e, 'Failed to load log');
} catch (exception: any) {
if (this.failedRequestsCount === 0 && !this.sessionExpireService.expired) {
this.notificationService.logException(exception, 'Failed to load log');
}
this.failedRequestsCount++;
@@ -10,16 +10,19 @@ import { injectable } from '@cloudbeaver/core-di';
import { PluginManagerService, PluginSettings } from '@cloudbeaver/core-plugin';
const defaultSettings = {
disabled: false,
refreshTimeout: 3000,
maxLogRecords: 1000,
logBatchSize: 2000,
maxFailedRequests: 3,
};
export type CookiesSettings = typeof defaultSettings;
export type LogViewerSettings = typeof defaultSettings;
@injectable()
export class CookiesSettingsService {
readonly settings: PluginSettings<CookiesSettings>;
export class LogViewerSettingsService {
readonly settings: PluginSettings<LogViewerSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core.cookies', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('log-viewer', defaultSettings);
}
}
@@ -20,7 +20,7 @@ export type AuthSettings = typeof defaultSettings;
export class AuthSettingsService {
readonly settings: PluginSettings<AuthSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core.authentication', defaultSettings);
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getCoreSettings('authentication', defaultSettings);
}
}
@@ -0,0 +1,36 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2022 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { injectable } from '@cloudbeaver/core-di';
import { PluginManagerService, PluginSettings } from '@cloudbeaver/core-plugin';
const defaultSettings = {
'cookies.disabled': false,
};
/** @deprecated don't use */
const deprecatedDefaultSettings = {
disabled: false,
};
export type CookiesSettings = typeof defaultSettings;
/** @deprecated don't use */
export type DeprecatedCookiesSettings = typeof deprecatedDefaultSettings;
@injectable()
export class BrowserSettingsService {
readonly settings: PluginSettings<CookiesSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<DeprecatedCookiesSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('browser', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getCoreSettings('cookies', deprecatedDefaultSettings);
}
}
@@ -8,13 +8,16 @@
import { injectable } from '@cloudbeaver/core-di';
import { CookiesSettingsService } from './CookiesSettingsService';
import { BrowserSettingsService } from './BrowserSettingsService';
@injectable()
export class CookiesService {
get cookiesEnabled() {
return !this.cookiesSettingsService.settings.getValue('disabled');
if (this.browserSettingsService.settings.isValueDefault('cookies.disabled')) {
return !this.browserSettingsService.deprecatedSettings.getValue('disabled');
}
return !this.browserSettingsService.settings.getValue('cookies.disabled');
}
constructor(private readonly cookiesSettingsService: CookiesSettingsService) {}
constructor(private readonly browserSettingsService: BrowserSettingsService) {}
}
+2 -2
View File
@@ -8,8 +8,8 @@
import type { PluginManifest } from '@cloudbeaver/core-di';
import { BrowserSettingsService } from './BrowserSettingsService';
import { CookiesService } from './CookiesService';
import { CookiesSettingsService } from './CookiesSettingsService';
export const coreBrowserManifest: PluginManifest = {
@@ -18,7 +18,7 @@ export const coreBrowserManifest: PluginManifest = {
},
providers: [
CookiesSettingsService,
BrowserSettingsService,
CookiesService,
],
};
@@ -12,7 +12,6 @@ import { PluginManagerService, PluginSettings } from '@cloudbeaver/core-plugin';
const defaultSettings = {
notificationsPool: 5,
maxPersistentAllow: 5,
};
export type EventsSettings = typeof defaultSettings;
@@ -20,8 +19,11 @@ export type EventsSettings = typeof defaultSettings;
@injectable()
export class EventsSettingsService {
readonly settings: PluginSettings<EventsSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<EventsSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core_events', defaultSettings);
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('notifications', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getDeprecatedPluginSettings('core_events', defaultSettings);
}
}
@@ -51,8 +51,13 @@ export class NotificationService {
): INotification<TProps> {
if (options.persistent) {
const persistentNotifications = this.notificationList.values.filter(value => value.persistent);
if (persistentNotifications.length >= this.settings.settings.getValue('maxPersistentAllow')) {
throw new Error(`You cannot create more than ${this.settings.settings.getValue('maxPersistentAllow')} persistent notification`);
const maxPersistentAllow = this.settings.settings.isValueDefault('maxPersistentAllow')
? this.settings.deprecatedSettings.getValue('maxPersistentAllow')
: this.settings.settings.getValue('maxPersistentAllow');
if (persistentNotifications.length >= maxPersistentAllow) {
throw new Error(`You cannot create more than ${maxPersistentAllow} persistent notification`);
}
}
@@ -90,7 +95,11 @@ export class NotificationService {
const filteredNotificationList = this.notificationList.values.filter(notification => !notification.persistent);
if (filteredNotificationList.length > this.settings.settings.getValue('notificationsPool')) {
const notificationsPool = this.settings.settings.isValueDefault('notificationsPool')
? this.settings.deprecatedSettings.getValue('notificationsPool')
: this.settings.settings.getValue('notificationsPool');
if (filteredNotificationList.length > notificationsPool) {
let i = 0;
while (this.notificationList.get(this.notificationList.keys[i])?.persistent) {
i++;
@@ -43,6 +43,10 @@ export class LocalizationService extends Bootstrap {
}
get defaultLanguage(): string {
if (this.pluginSettings.getValue('defaultLanguage')) {
return this.deprecatedPluginSettings.getValue('defaultLanguage');
}
return this.pluginSettings.getValue('defaultLanguage');
}
@@ -50,6 +54,8 @@ export class LocalizationService extends Bootstrap {
language: DEFAULT_LOCALE_NAME,
};
readonly pluginSettings: PluginSettings<IDefaultSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedPluginSettings: PluginSettings<IDefaultSettings>;
readonly onChange: ISyncExecutor<string>;
// observable.shallow - don't treat locales as observables
@@ -67,7 +73,8 @@ export class LocalizationService extends Bootstrap {
super();
this.onChange = new SyncExecutor();
this.pluginSettings = this.pluginManagerService.getPluginSettings('core.user', defaultThemeSettings);
this.pluginSettings = this.pluginManagerService.getCoreSettings('localization', defaultThemeSettings);
this.deprecatedPluginSettings = this.pluginManagerService.getCoreSettings('user', defaultThemeSettings);
sessionResource.onDataUpdate.addHandler(this.syncLanguage.bind(this));
makeObservable<LocalizationService, 'localeMap' | 'setCurrentLocale'>(this, {
@@ -15,7 +15,19 @@ import { PluginSettings } from './PluginSettings';
export class PluginManagerService {
constructor(private readonly productManagerService: ProductManagerService) { }
getCoreSettings<T>(scope: string, defaults: T) {
return new PluginSettings(this.productManagerService.settings, 'core.' + scope, defaults);
}
getPluginSettings<T>(scope: string, defaults: T) {
return new PluginSettings(this.productManagerService.settings, 'plugin.' + scope, defaults);
}
/**
* Please use getPluginSettings instead
* @deprecated Please use getPluginSettings instead, will be removed in 23.0.0
*/
getDeprecatedPluginSettings<T>(scope: string, defaults: T) {
return new PluginSettings(this.productManagerService.settings, scope, defaults);
}
}
@@ -20,6 +20,10 @@ export class PluginSettings<T> implements ISettingsSource {
return true;
}
isValueDefault<TKey extends keyof T>(key: TKey): boolean {
return !this.source.has(this.scopedKey(key));
}
getValue<TKey extends keyof T>(key: TKey): T[TKey] {
if (this.source.has(this.scopedKey(key))) {
return this.source.getValue(this.scopedKey(key));
@@ -46,6 +46,10 @@ export class ThemeService extends Bootstrap {
}
get defaultThemeId(): string {
if (this.themeSettingsService.settings.isValueDefault('defaultTheme')) {
return this.themeSettingsService.deprecatedSettings.getValue('defaultTheme');
}
return this.themeSettingsService.settings.getValue('defaultTheme');
}
@@ -22,8 +22,11 @@ export const defaultThemeSettings: IDefaultSettings = {
@injectable()
export class ThemeSettingsService {
readonly settings: PluginSettings<IDefaultSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<IDefaultSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core.user', defaultThemeSettings);
this.settings = this.pluginManagerService.getPluginSettings('theming', defaultThemeSettings);
this.deprecatedSettings = this.pluginManagerService.getCoreSettings('user', defaultThemeSettings);
}
}
@@ -10,10 +10,10 @@ import { EObjectFeature, DATA_CONTEXT_NAV_NODE } from '@cloudbeaver/core-app';
import { injectable } from '@cloudbeaver/core-di';
import { IMenuContext, CommonDialogService } from '@cloudbeaver/core-dialogs';
import { ActionService, ACTION_EXPORT, DATA_CONTEXT_MENU_NESTED, MenuService } from '@cloudbeaver/core-view';
import { DATA_CONTEXT_CONNECTION } from '@cloudbeaver/plugin-connections';
import { TableFooterMenuService, ITableFooterMenuContext, IDatabaseDataSource, IDataContainerOptions } from '@cloudbeaver/plugin-data-viewer';
import type { IDataQueryOptions } from '@cloudbeaver/plugin-sql-editor';
import { DATA_CONTEXT_CONNECTION } from '../../plugin-connections/src';
import { DataExportSettingsService } from './DataExportSettingsService';
import { DataExportDialog } from './Dialog/DataExportDialog';
@@ -37,7 +37,7 @@ export class DataExportMenuService {
isPresent(context) {
return context.contextType === TableFooterMenuService.nodeContextType;
},
isHidden: () => this.dataExportSettingsService.settings.getValue('disabled'),
isHidden: () => this.isDisabled(),
isDisabled(context) {
return context.data.model.isLoading()
|| context.data.model.isDisabled(context.data.resultIndex)
@@ -55,7 +55,7 @@ export class DataExportMenuService {
}
return (
!this.dataExportSettingsService.settings.getValue('disabled')
!this.isDisabled()
&& context.has(DATA_CONTEXT_CONNECTION)
&& !context.has(DATA_CONTEXT_MENU_NESTED)
);
@@ -110,4 +110,11 @@ export class DataExportMenuService {
},
});
}
private isDisabled() {
if (this.dataExportSettingsService.settings.isValueDefault('disabled')) {
return this.dataExportSettingsService.deprecatedSettings.getValue('disabled');
}
return this.dataExportSettingsService.settings.getValue('disabled');
}
}
@@ -18,8 +18,11 @@ export type DataExportSettings = typeof defaultSettings;
@injectable()
export class DataExportSettingsService {
readonly settings: PluginSettings<DataExportSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<DataExportSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('plugin_data_export', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('data-export', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getDeprecatedPluginSettings('plugin_data_export', defaultSettings);
}
}
@@ -18,8 +18,11 @@ export type DataGridSettings = typeof defaultSettings;
@injectable()
export class DataGridSettingsService {
readonly settings: PluginSettings<DataGridSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<typeof defaultSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('plugin_data_spreadsheet_new', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('data-spreadsheet', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getDeprecatedPluginSettings('plugin_data_spreadsheet_new', defaultSettings);
}
}
@@ -40,7 +40,11 @@ export class SpreadsheetBootstrap extends Bootstrap {
id: 'spreadsheet_grid',
dataFormat: ResultDataFormat.Resultset,
getPresentationComponent: () => SpreadsheetGrid,
hidden: () => this.dataGridSettingsService.settings.getValue('hidden'),
hidden: () => (
this.dataGridSettingsService.settings.isValueDefault('hidden')
? this.dataGridSettingsService.deprecatedSettings.getValue('hidden')
: this.dataGridSettingsService.settings.getValue('hidden')
),
title: 'Table',
icon: 'table-icon-sm',
});
@@ -18,7 +18,9 @@ export class DataViewerService {
) { }
isDataEditable(connection: Connection) {
const disabled = this.dataViewerSettingsService.settings.getValue('disableEdit');
const disabled = this.dataViewerSettingsService.settings.isValueDefault('disableEdit')
? this.dataViewerSettingsService.deprecatedSettings.getValue('disableEdit')
: this.dataViewerSettingsService.settings.getValue('disableEdit');
return !disabled && !connection.readOnly;
}
}
@@ -18,8 +18,11 @@ export type DataViewerSettings = typeof defaultSettings;
@injectable()
export class DataViewerSettingsService {
readonly settings: PluginSettings<DataViewerSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<typeof defaultSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core.app.dataViewer', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('data-viewer', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getDeprecatedPluginSettings('core.app.dataViewer', defaultSettings);
}
}
@@ -6,7 +6,7 @@
* you may not use this file except in compliance with the License.
*/
import { CoreSettingsService, ENodeFeature, getNodeDisplayName, NavNode, NavNodeInfoResource, NavTreeResource } from '@cloudbeaver/core-app';
import { CoreSettingsService, ENodeFeature, getNodeDisplayName, NavNode, NavNodeInfoResource, NavTreeResource, NavTreeSettingsService } from '@cloudbeaver/core-app';
import type { TableState } from '@cloudbeaver/core-blocks';
import { injectable } from '@cloudbeaver/core-di';
import {
@@ -32,7 +32,8 @@ export class ObjectPropertyTableFooterService {
private readonly navNodeInfoResource: NavNodeInfoResource,
private readonly notificationService: NotificationService,
private readonly commonDialogService: CommonDialogService,
private readonly coreSettingsService: CoreSettingsService
private readonly coreSettingsService: CoreSettingsService,
private readonly navTreeSettingsService: NavTreeSettingsService
) {
this.contextMenuService.addPanel(this.objectPropertyTableFooterToken);
@@ -45,7 +46,9 @@ export class ObjectPropertyTableFooterService {
isPresent(context) {
return context.contextType === ObjectPropertyTableFooterService.objectPropertyContextType;
},
isHidden: () => !this.coreSettingsService.settings.getValue('app.metadata.deleting'),
isHidden: () => !(this.navTreeSettingsService.settings.isValueDefault('deleting')
? this.coreSettingsService.settings.getValue('app.metadata.deleting')
: this.navTreeSettingsService.settings.getValue('deleting')),
isDisabled: context => {
if (context.data.tableState.selectedList.length === 0) {
return true;
@@ -16,8 +16,11 @@ const defaultSettings = {
@injectable()
export class ResourceManagerSettingsService {
readonly settings: PluginSettings<typeof defaultSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<typeof defaultSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('plugin_resource_manager', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('resource-manager', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getDeprecatedPluginSettings('plugin_resource_manager', defaultSettings);
}
}
@@ -195,7 +195,9 @@ export class PluginBootstrap extends Bootstrap {
return;
}
const maxSize = this.sqlEditorSettingsService.settings.getValue('maxFileSize');
const maxSize = this.sqlEditorSettingsService.settings.isValueDefault('maxFileSize')
? this.sqlEditorSettingsService.deprecatedSettings.getValue('maxFileSize')
: this.sqlEditorSettingsService.settings.getValue('maxFileSize');
const size = Math.round(resource.length / 1000); // kilobyte
if (size > maxSize) {
@@ -19,6 +19,6 @@ export class ResourceEditorSettingsService {
readonly settings: PluginSettings<ResourceEditorSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('plugin.resource_editor', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('sql-editor-navigation-tab-resource', defaultSettings);
}
}
@@ -71,7 +71,10 @@ export function useTools(state: ISqlEditorTabState): Readonly<State> {
},
checkFileValidity(file: File) {
const maxSize = this.sqlEditorSettingsService.settings.getValue('maxFileSize');
const maxSize = this.sqlEditorSettingsService.settings.isValueDefault('maxFileSize')
? this.sqlEditorSettingsService.deprecatedSettings.getValue('maxFileSize')
: this.sqlEditorSettingsService.settings.getValue('maxFileSize');
const size = Math.round(file.size / 1000); // kilobyte
const aboveMaxSize = size > maxSize;
@@ -16,8 +16,11 @@ const defaultSettings = {
@injectable()
export class SqlEditorSettingsService {
readonly settings: PluginSettings<typeof defaultSettings>;
/** @deprecated Use settings instead, will be removed in 23.0.0 */
readonly deprecatedSettings: PluginSettings<typeof defaultSettings>;
constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.getPluginSettings('core.app.sqlEditor', defaultSettings);
this.settings = this.pluginManagerService.getPluginSettings('sql-editor', defaultSettings);
this.deprecatedSettings = this.pluginManagerService.getDeprecatedPluginSettings('core.app.sqlEditor', defaultSettings);
}
}