mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
chore: cleanup
This commit is contained in:
@@ -10,6 +10,8 @@ import { SettingsMenuService } from '@dbeaver/core/app';
|
||||
import { injectable } from '@dbeaver/core/di';
|
||||
import { PermissionsService } from '@dbeaver/core/root';
|
||||
|
||||
export const ADMINISTRATION_PERMISSION = 'admin';
|
||||
|
||||
@injectable()
|
||||
export class AdministrationMenuService {
|
||||
static administrationMenuToken = 'administrationMenu';
|
||||
@@ -19,11 +21,14 @@ export class AdministrationMenuService {
|
||||
) { }
|
||||
|
||||
register() {
|
||||
this.settingsMenuService.addMenuItem({
|
||||
id: AdministrationMenuService.administrationMenuToken,
|
||||
order: 0,
|
||||
isHidden: () => !this.permissionsService.has('admin'),
|
||||
title: 'administration_menu_enter',
|
||||
});
|
||||
this.settingsMenuService.addMenuItem(
|
||||
SettingsMenuService.settingsMenuToken,
|
||||
{
|
||||
id: AdministrationMenuService.administrationMenuToken,
|
||||
order: 0,
|
||||
isHidden: () => !this.permissionsService.has(ADMINISTRATION_PERMISSION),
|
||||
title: 'administration_menu_enter',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,48 +32,54 @@ export class SettingsMenuService {
|
||||
return this.menu.getMenu(SettingsMenuService.settingsMenuToken);
|
||||
}
|
||||
|
||||
addMenuItem(options: IComputedMenuItemOptions, panelId: string = SettingsMenuService.settingsMenuToken) {
|
||||
addMenuItem(panelId: string, options: IComputedMenuItemOptions) {
|
||||
this.menu.addMenuItem(panelId, options);
|
||||
}
|
||||
|
||||
private addThemes() {
|
||||
this.addMenuItem({
|
||||
id: this.themeMenuToken,
|
||||
order: 1,
|
||||
title: 'app_shared_settingsMenu_theme',
|
||||
isPanel: true,
|
||||
});
|
||||
this.addMenuItem(
|
||||
SettingsMenuService.settingsMenuToken,
|
||||
{
|
||||
id: this.themeMenuToken,
|
||||
order: 1,
|
||||
title: 'app_shared_settingsMenu_theme',
|
||||
isPanel: true,
|
||||
}
|
||||
);
|
||||
|
||||
this.themeService.themes.forEach((theme) => {
|
||||
this.addMenuItem(
|
||||
this.themeMenuToken,
|
||||
{
|
||||
id: theme.id,
|
||||
title: theme.name,
|
||||
isDisabled: () => theme.id === this.themeService.currentThemeId,
|
||||
onClick: () => this.themeService.changeThemeAsync(theme.id),
|
||||
},
|
||||
this.themeMenuToken
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private addLocales() {
|
||||
this.addMenuItem({
|
||||
id: this.langMenuToken,
|
||||
order: 2,
|
||||
title: 'app_shared_settingsMenu_lang',
|
||||
isPanel: true,
|
||||
});
|
||||
this.addMenuItem(
|
||||
SettingsMenuService.settingsMenuToken,
|
||||
{
|
||||
id: this.langMenuToken,
|
||||
order: 2,
|
||||
title: 'app_shared_settingsMenu_lang',
|
||||
isPanel: true,
|
||||
}
|
||||
);
|
||||
|
||||
this.localizationService.getSupportedLanguages().forEach((lang) => {
|
||||
this.addMenuItem(
|
||||
this.langMenuToken,
|
||||
{
|
||||
id: lang.isoCode,
|
||||
title: lang.nativeName,
|
||||
isDisabled: () => lang.isoCode === this.localizationService.getCurrentLanguage(),
|
||||
onClick: () => this.localizationService.changeLocaleAsync(lang.isoCode),
|
||||
},
|
||||
this.langMenuToken
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,12 +29,6 @@ export class PermissionsService {
|
||||
return this.permissions.data.has(id);
|
||||
}
|
||||
|
||||
async hasAsync(id: string): Promise<boolean> {
|
||||
const permissions = await this.permissions.load();
|
||||
|
||||
return permissions.has(id);
|
||||
}
|
||||
|
||||
async update() {
|
||||
await this.permissions.refresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user