mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge pull request #110 from dbeaver/refactor-authentication
fix: infinity data refreshes
This commit is contained in:
@@ -29,13 +29,14 @@ export class PermissionsResource extends CachedDataResource<Set<string>, null> {
|
||||
return this.data.has(id);
|
||||
}
|
||||
|
||||
protected async loader(): Promise<Set<string>> {
|
||||
protected async loader(key: null): Promise<Set<string>> {
|
||||
const { permissions } = await this.graphQLService.gql.sessionPermissions();
|
||||
|
||||
this.data.clear();
|
||||
for (const permission of permissions) {
|
||||
this.data.add(permission);
|
||||
}
|
||||
this.markUpdated(key);
|
||||
this.loaded = true;
|
||||
|
||||
return this.data;
|
||||
|
||||
@@ -21,9 +21,10 @@ export class ServerConfigResource extends CachedDataResource<ServerConfig | null
|
||||
return !!this.data;
|
||||
}
|
||||
|
||||
protected async loader(): Promise<ServerConfig> {
|
||||
protected async loader(key: null): Promise<ServerConfig> {
|
||||
const { serverConfig } = await this.graphQLService.gql.serverConfig();
|
||||
|
||||
this.markUpdated(key);
|
||||
return serverConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ export class SessionResource extends CachedDataResource<SessionState | null, nul
|
||||
return !!this.data;
|
||||
}
|
||||
|
||||
protected async loader(): Promise<SessionState> {
|
||||
protected async loader(key: null): Promise<SessionState> {
|
||||
const { session } = await this.graphQLService.gql.openSession();
|
||||
|
||||
this.markUpdated(key);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export class RolesResource extends CachedDataResource<AdminRoleInfo[], string |
|
||||
const { roles } = await this.graphQLService.gql.getRolesList({ roleId });
|
||||
|
||||
if (!roleId) {
|
||||
this.markUpdated(roleId);
|
||||
return roles as AdminRoleInfo[];
|
||||
}
|
||||
|
||||
@@ -41,6 +42,8 @@ export class RolesResource extends CachedDataResource<AdminRoleInfo[], string |
|
||||
this.data.push(...roles as AdminRoleInfo[]);
|
||||
}
|
||||
|
||||
this.markUpdated(roleId);
|
||||
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export class UsersResource extends CachedDataResource<AdminUserInfo[], string |
|
||||
const { users } = await this.graphQLService.gql.getUsersList({ userId });
|
||||
|
||||
if (!userId) {
|
||||
this.markUpdated(userId);
|
||||
return users as AdminUserInfo[];
|
||||
}
|
||||
|
||||
@@ -41,6 +42,8 @@ export class UsersResource extends CachedDataResource<AdminUserInfo[], string |
|
||||
this.data.push(...users as AdminUserInfo[]);
|
||||
}
|
||||
|
||||
this.markUpdated(userId);
|
||||
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,10 @@ export class AuthProvidersResource extends CachedDataResource<AuthProvider[], nu
|
||||
return !!this.data.length;
|
||||
}
|
||||
|
||||
protected async loader(): Promise<AuthProvider[]> {
|
||||
protected async loader(key: null): Promise<AuthProvider[]> {
|
||||
const { providers } = await this.graphQLService.gql.getAuthProviders();
|
||||
|
||||
this.markUpdated(key);
|
||||
return providers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,13 @@ export class DataSourcesResource extends CachedDataResource<DBSource[], null> {
|
||||
return !!this.data.length;
|
||||
}
|
||||
|
||||
protected async loader(): Promise<DBSource[]> {
|
||||
protected async loader(key: null): Promise<DBSource[]> {
|
||||
if (!await this.permissionsService.hasAsync(EPermission.public)) {
|
||||
this.markUpdated(key);
|
||||
return [];
|
||||
}
|
||||
const { dataSourceList } = await this.graphQLService.gql.dataSourceList();
|
||||
this.markUpdated(key);
|
||||
return dataSourceList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class DataTransferProcessorsResource extends CachedDataResource<Map<strin
|
||||
return this.loaded;
|
||||
}
|
||||
|
||||
protected async loader() {
|
||||
protected async loader(key: null) {
|
||||
const { processors } = await this.graphQLService.gql.getDataTransferProcessors();
|
||||
|
||||
this.data.clear();
|
||||
@@ -34,6 +34,7 @@ export class DataTransferProcessorsResource extends CachedDataResource<Map<strin
|
||||
this.data.set(processor.id, processor);
|
||||
}
|
||||
this.loaded = true;
|
||||
this.markUpdated(key);
|
||||
|
||||
return this.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user