mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
/*
|
|
* CloudBeaver - Cloud Database Manager
|
|
* Copyright (C) 2020-2021 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 { SettingsMenuService } from '@cloudbeaver/core-app';
|
|
import { AuthInfoService } from '@cloudbeaver/core-authentication';
|
|
import { injectable, Bootstrap } from '@cloudbeaver/core-di';
|
|
import { ServerConfigResource } from '@cloudbeaver/core-root';
|
|
|
|
import { AuthenticationService } from './AuthenticationService';
|
|
import { AuthDialogService } from './Dialog/AuthDialogService';
|
|
|
|
@injectable()
|
|
export class PluginBootstrap extends Bootstrap {
|
|
constructor(
|
|
private readonly serverConfigResource: ServerConfigResource,
|
|
private readonly authDialogService: AuthDialogService,
|
|
private readonly authenticationService: AuthenticationService,
|
|
private readonly authInfoService: AuthInfoService,
|
|
private readonly settingsMenuService: SettingsMenuService,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
register(): void {
|
|
this.settingsMenuService.addMenuItem(
|
|
SettingsMenuService.settingsMenuToken,
|
|
{
|
|
id: 'login',
|
|
order: 0,
|
|
isHidden: () => this.serverConfigResource.enabledAuthProviders.length === 0 || !!this.authInfoService.userInfo,
|
|
title: 'authentication_login',
|
|
onClick: () => this.authDialogService.showLoginForm(false, null, true),
|
|
}
|
|
);
|
|
|
|
this.settingsMenuService.addMenuItem(
|
|
SettingsMenuService.settingsMenuToken,
|
|
{
|
|
id: 'logout',
|
|
order: Number.MAX_SAFE_INTEGER,
|
|
isHidden: () => !this.authInfoService.userInfo,
|
|
title: 'authentication_logout',
|
|
onClick: this.authenticationService.logout.bind(this.authenticationService),
|
|
}
|
|
);
|
|
}
|
|
|
|
load(): void | Promise<void> { }
|
|
}
|