mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-12 23:37:00 +08:00
* CB-4629 feat: enable user settings UI * CB-4629 feat: localization * CB-4629 feat: restore default settings * CB-4629 feat: preferences menu * CB-4629 chore: update ts references * CB-4629 user preference store * CB-4629 fix anonymous preferences * CB-4629 nullable annotation * CB-4629 refactor: context menu API * CB-4629 fix: tools panel styles * CB-4629 fix: remove outline for tab list * CB-4629 fix: hide account tab in anonymous mode * CB-4629 anonymous preferences * CB-4629 read anonymous user parameters * CB-4629 fix: zod validation and localization * CB-4629 use websession preference store in completion context * CB-4629 fix: revert tools styles --------- Co-authored-by: Aleksei Potsetsuev <wrouds@gmail.com> Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com>
102 lines
3.4 KiB
TypeScript
102 lines
3.4 KiB
TypeScript
/*
|
|
* 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.
|
|
*/
|
|
import { AppScreenService } from '@cloudbeaver/core-app';
|
|
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 { ActionService, menuExtractItems, MenuService } from '@cloudbeaver/core-view';
|
|
import { MENU_APP_STATE } from '@cloudbeaver/plugin-top-app-bar';
|
|
|
|
import { ACTION_APP_HELP } from './actions/ACTION_APP_HELP';
|
|
|
|
const ShortcutsDialog = importLazyComponent(() => import('./Shortcuts/ShortcutsDialog').then(m => m.ShortcutsDialog));
|
|
|
|
@injectable()
|
|
export class PluginBootstrap extends Bootstrap {
|
|
private errorNotification: INotification<any> | null;
|
|
constructor(
|
|
private readonly menuService: MenuService,
|
|
private readonly screenService: ScreenService,
|
|
private readonly actionService: ActionService,
|
|
private readonly commonDialogService: CommonDialogService,
|
|
private readonly notificationService: NotificationService,
|
|
private readonly localStorageSaveService: LocalStorageSaveService,
|
|
) {
|
|
super();
|
|
this.errorNotification = null;
|
|
}
|
|
|
|
async load(): Promise<void> {}
|
|
|
|
register(): void {
|
|
this.addTopAppMenuItems();
|
|
this.addMultiTabSupportNotification();
|
|
}
|
|
|
|
private addMultiTabSupportNotification() {
|
|
const displayErrorMessage = () => {
|
|
if (this.errorNotification) {
|
|
return;
|
|
}
|
|
if (this.screenService.isActive(AppScreenService.screenName) && this.localStorageSaveService.storage === 'session') {
|
|
this.errorNotification = this.notificationService.customNotification(
|
|
() => ActionSnackbar,
|
|
{
|
|
actionText: 'plugin_help_multi_tab_support_load_settings',
|
|
onAction: () => {
|
|
this.localStorageSaveService.updateStorage('local');
|
|
this.errorNotification?.close(false);
|
|
},
|
|
},
|
|
{
|
|
type: ENotificationType.Error,
|
|
title: 'plugin_help_multi_tab_support_title',
|
|
message: 'plugin_help_multi_tab_support_description',
|
|
onClose: () => {
|
|
this.errorNotification = null;
|
|
},
|
|
},
|
|
);
|
|
}
|
|
};
|
|
this.localStorageSaveService.onStorageChange.addHandler(displayErrorMessage);
|
|
|
|
this.screenService.routeChange.addPostHandler(displayErrorMessage);
|
|
}
|
|
|
|
private addTopAppMenuItems() {
|
|
this.menuService.addCreator({
|
|
menus: [MENU_APP_STATE],
|
|
getItems: (context, items) => [...items, ACTION_APP_HELP],
|
|
orderItems: (context, items) => {
|
|
const extracted = menuExtractItems(items, [ACTION_APP_HELP]);
|
|
|
|
items.splice(items.length - 1, 0, ...extracted);
|
|
|
|
return items;
|
|
},
|
|
});
|
|
|
|
this.actionService.addHandler({
|
|
id: 'app-help',
|
|
actions: [ACTION_APP_HELP],
|
|
handler: async (context, action) => {
|
|
switch (action) {
|
|
case ACTION_APP_HELP: {
|
|
await this.commonDialogService.open(ShortcutsDialog, null);
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
});
|
|
}
|
|
}
|