From 5118ef91a849a55d0f7676ad6fb225d31ac5263f Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 10 Oct 2024 15:57:37 +0200 Subject: [PATCH] CB-5710 change getters to methods --- .../core-authentication/src/AppAuthService.ts | 4 +-- .../src/UserInfoResource.ts | 27 +++++++------------ .../core-projects/src/ProjectsService.ts | 2 +- .../src/UserSettingsService.ts | 8 +++--- .../src/AuthenticationService.ts | 2 +- .../src/PluginBootstrap.ts | 4 +-- .../src/ConnectionAuthService.ts | 2 +- .../NavNodes/ConnectionFoldersBootstrap.ts | 2 +- .../PublicConnectionFormService.ts | 3 ++- .../src/NavNodes/ResourceFoldersBootstrap.ts | 2 +- .../src/ResourceManagerService.ts | 2 +- .../SessionExpireWarningDialogBootstrap.ts | 2 +- .../src/UserMenu/UserMenu.tsx | 2 +- .../UserProfileFormBootstrap.ts | 2 +- .../src/UserProfileOptionsPanelService.ts | 2 +- 15 files changed, 30 insertions(+), 36 deletions(-) diff --git a/webapp/packages/core-authentication/src/AppAuthService.ts b/webapp/packages/core-authentication/src/AppAuthService.ts index 7090a62385..0e653faf10 100644 --- a/webapp/packages/core-authentication/src/AppAuthService.ts +++ b/webapp/packages/core-authentication/src/AppAuthService.ts @@ -16,7 +16,7 @@ import { UserInfoResource } from './UserInfoResource.js'; @injectable() export class AppAuthService extends Bootstrap { get authenticated(): boolean { - return this.serverConfigResource.configurationMode || this.userInfoResource.hasAccess; + return this.serverConfigResource.configurationMode || this.userInfoResource.hasAccess(); } get loaders(): ILoadableState[] { @@ -56,7 +56,7 @@ export class AppAuthService extends Bootstrap { await this.userInfoResource.load(); - return !this.serverConfigResource.configurationMode && !this.userInfoResource.hasAccess; + return !this.serverConfigResource.configurationMode && !this.userInfoResource.hasAccess(); } async authUser(): Promise { diff --git a/webapp/packages/core-authentication/src/UserInfoResource.ts b/webapp/packages/core-authentication/src/UserInfoResource.ts index 803037cc6e..0537b2569b 100644 --- a/webapp/packages/core-authentication/src/UserInfoResource.ts +++ b/webapp/packages/core-authentication/src/UserInfoResource.ts @@ -55,18 +55,6 @@ export class UserInfoResource extends CachedDataResource { @@ -94,13 +94,13 @@ export class UserSettingsService extends SettingsSource { private refreshConfig() { this.update(() => { - if (!this.userInfoResource.isAuthenticated) { + if (!this.userInfoResource.isAuthenticated()) { this.clear(); this.lastConfig = null; return; } - if (this.userInfoResource.isData() && this.userInfoResource.data.configurationParameters !== this.lastConfig) { + if (this.userInfoResource.data.configurationParameters !== this.lastConfig) { this.clear(); this.localSettings.clear(); this.lastConfig = this.userInfoResource.data.configurationParameters; @@ -121,7 +121,7 @@ export class UserSettingsService extends SettingsSource { } private getSource() { - if (this.userInfoResource.isAuthenticated) { + if (this.userInfoResource.isAuthenticated()) { return this.settings; } diff --git a/webapp/packages/plugin-authentication/src/AuthenticationService.ts b/webapp/packages/plugin-authentication/src/AuthenticationService.ts index f353e15950..1c9e723787 100644 --- a/webapp/packages/plugin-authentication/src/AuthenticationService.ts +++ b/webapp/packages/plugin-authentication/src/AuthenticationService.ts @@ -67,7 +67,7 @@ export class AuthenticationService extends Bootstrap { this.onLogin = new Executor(); this.onLogout.before(this.navigationService.navigationTask); - this.onLogin.before(this.navigationService.navigationTask, undefined, () => userInfoResource.isAnonymous); + this.onLogin.before(this.navigationService.navigationTask, undefined, () => userInfoResource.isAnonymous()); this.authPromise = null; this.configureAuthProvider = null; diff --git a/webapp/packages/plugin-authentication/src/PluginBootstrap.ts b/webapp/packages/plugin-authentication/src/PluginBootstrap.ts index 11c8786960..e80443375d 100644 --- a/webapp/packages/plugin-authentication/src/PluginBootstrap.ts +++ b/webapp/packages/plugin-authentication/src/PluginBootstrap.ts @@ -28,7 +28,7 @@ export class PluginBootstrap extends Bootstrap { this.menuService.addCreator({ menus: [TOP_NAV_BAR_SETTINGS_MENU], getItems: (context, items) => { - if (this.serverConfigResource.enabledAuthProviders.length > 0 && this.userInfoResource.isAnonymous) { + if (this.serverConfigResource.enabledAuthProviders.length > 0 && this.userInfoResource.isAnonymous()) { return [ ...items, new MenuBaseItem( @@ -42,7 +42,7 @@ export class PluginBootstrap extends Bootstrap { ]; } - if (this.userInfoResource.isAuthenticated) { + if (this.userInfoResource.isAuthenticated()) { return [ ...items, new MenuBaseItem( diff --git a/webapp/packages/plugin-connections/src/ConnectionAuthService.ts b/webapp/packages/plugin-connections/src/ConnectionAuthService.ts index bfff83dc95..71b7f51887 100644 --- a/webapp/packages/plugin-connections/src/ConnectionAuthService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionAuthService.ts @@ -41,7 +41,7 @@ export class ConnectionAuthService extends Dependency { connections: connectionInfoResource.values.filter(connection => connection.connected).map(createConnectionParam), state, }), - state => state === 'before' && userInfoResource.isAnonymous, + state => state === 'before' && userInfoResource.isAnonymous(), ); this.authenticationService.onLogout.before( connectionsManagerService.onDisconnect, diff --git a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts index f87351ef73..ce69635c20 100644 --- a/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts +++ b/webapp/packages/plugin-connections/src/NavNodes/ConnectionFoldersBootstrap.ts @@ -126,7 +126,7 @@ export class ConnectionFoldersBootstrap extends Bootstrap { isActionApplicable: (context, action) => { const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE)!; - if (action !== ACTION_NEW_FOLDER || !this.userInfoResource.isAuthenticated || tree.baseRoot !== ROOT_NODE_PATH) { + if (action !== ACTION_NEW_FOLDER || !this.userInfoResource.isAuthenticated() || tree.baseRoot !== ROOT_NODE_PATH) { return false; } diff --git a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts index ca6492ef29..98424a2a4c 100644 --- a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts +++ b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts @@ -60,8 +60,9 @@ export class PublicConnectionFormService { executorHandlerFilter( () => !!this.formState && this.optionsPanelService.isOpen(formGetter), async (event, context) => { - if (event === 'before' && !this.userInfoResource.isData()) { + if (event === 'before' && this.userInfoResource.isAnonymous()) { const confirmed = await this.showUnsavedChangesDialog(); + if (!confirmed) { ExecutorInterrupter.interrupt(context); } diff --git a/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts b/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts index 3fb8572474..0a5d22b181 100644 --- a/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts +++ b/webapp/packages/plugin-navigation-tree-rm/src/NavNodes/ResourceFoldersBootstrap.ts @@ -89,7 +89,7 @@ export class ResourceFoldersBootstrap extends Bootstrap { isActionApplicable: context => { const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE); - if (!tree?.baseRoot.startsWith(RESOURCES_NODE_PATH) || !this.userInfoResource.isAuthenticated) { + if (!tree?.baseRoot.startsWith(RESOURCES_NODE_PATH) || !this.userInfoResource.isAuthenticated()) { return false; } diff --git a/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts b/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts index 22af72f735..b29ebf0e82 100644 --- a/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts +++ b/webapp/packages/plugin-resource-manager/src/ResourceManagerService.ts @@ -15,7 +15,7 @@ import { ServerConfigResource } from '@cloudbeaver/core-root'; @injectable() export class ResourceManagerService { get enabled() { - return !!this.serverConfigResource.data?.resourceManagerEnabled && this.userInfoResource.isAuthenticated; + return !!this.serverConfigResource.data?.resourceManagerEnabled && this.userInfoResource.isAuthenticated(); } constructor( diff --git a/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts b/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts index db49c48472..72f8605814 100644 --- a/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts +++ b/webapp/packages/plugin-session-expiration/src/SessionExpireWarningDialog/SessionExpireWarningDialogBootstrap.ts @@ -38,7 +38,7 @@ export class SessionExpireWarningDialogBootstrap extends Bootstrap { } private handleSessionResourceDataUpdate(isValid?: boolean, remainingTime?: number) { - if (!this.serverConfigResource.configurationMode && !this.userInfoResource.hasAccess) { + if (!this.serverConfigResource.configurationMode && !this.userInfoResource.hasAccess()) { return; } diff --git a/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx b/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx index d5dc2d0bcb..2d8f9a05ee 100644 --- a/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx +++ b/webapp/packages/plugin-user-profile/src/UserMenu/UserMenu.tsx @@ -27,7 +27,7 @@ export const UserMenu = observer(function UserMenu() { context.set(DATA_CONTEXT_USER, userInfoResource.data, id); }); - if (!userInfoResource.isData() || !userInfoResource.isAuthenticated) { + if (!userInfoResource.isAuthenticated()) { return null; } diff --git a/webapp/packages/plugin-user-profile/src/UserProfileForm/UserProfileFormBootstrap.ts b/webapp/packages/plugin-user-profile/src/UserProfileForm/UserProfileFormBootstrap.ts index 1ce0941239..260ebe8831 100644 --- a/webapp/packages/plugin-user-profile/src/UserProfileForm/UserProfileFormBootstrap.ts +++ b/webapp/packages/plugin-user-profile/src/UserProfileForm/UserProfileFormBootstrap.ts @@ -27,7 +27,7 @@ export class UserProfileFormBootstrap extends Bootstrap { key: 'account', name: 'plugin_user_profile_account_title', order: 1, - isHidden: () => this.userInfoResource.isAnonymous, + isHidden: () => this.userInfoResource.isAnonymous(), panel: () => UserProfileFormPanel, }); } diff --git a/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts b/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts index 0e0f820161..5a6c0ff62a 100644 --- a/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts +++ b/webapp/packages/plugin-user-profile/src/UserProfileOptionsPanelService.ts @@ -82,7 +82,7 @@ export class UserProfileOptionsPanelService { return; } - if (!this.userInfoResource.isData()) { + if (!this.userInfoResource.hasAccess()) { this.close(true); } }