Compare commits

...
2 Commits
Author SHA1 Message Date
Alexey a2db492359 CB-3888 fix: page loading for lists (#1930) 2023-08-18 16:52:24 +03:00
Alexey 67f59ae5e5 CB-3887 fix: auth dialog fallback (#1929) 2023-08-18 16:49:51 +03:00
4 changed files with 53 additions and 49 deletions
@@ -261,7 +261,7 @@ export class UsersResource extends CachedMapResource<string, AdminUser, UserReso
usersList.push(user);
} else {
const pageKey = this.isAlias(originalKey, CachedResourcePageKey);
const pageKey = this.isAlias(originalKey, CachedResourcePageKey) || this.isAlias(originalKey, CachedResourcePageListKey);
const filterKey = this.isAlias(originalKey, UsersResourceFilterKey);
let offset = CACHED_RESOURCE_DEFAULT_PAGE_OFFSET;
let limit = CACHED_RESOURCE_DEFAULT_PAGE_LIMIT;
@@ -45,7 +45,7 @@ export class DBObjectResource extends CachedMapResource<string, DBObject> {
this.navTreeResource.onDataOutdated.addHandler(key => {
ResourceKeyUtils.forEach(key, nodeId => {
const pageAlias = this.isAlias(nodeId, CachedResourcePageKey) ?? this.isAlias(nodeId, CachedResourcePageListKey);
const pageAlias = this.isAlias(nodeId, CachedResourcePageKey) || this.isAlias(nodeId, CachedResourcePageListKey);
if (pageAlias) {
this.markOutdated(DBObjectParentKey(pageAlias.target));
@@ -18,6 +18,7 @@ import {
CachedMapAllKey,
CachedMapResource,
CachedResourcePageKey,
CachedResourcePageListKey,
DetailsError,
NavNodeChildrenQuery as fake,
GraphQLService,
@@ -444,7 +445,7 @@ export class NavTreeResource extends CachedMapResource<string, string[], Record<
}
protected async loader(originalKey: ResourceKey<string>): Promise<Map<string, string[]>> {
const pageKey = this.isAlias(originalKey, CachedResourcePageKey);
const pageKey = this.isAlias(originalKey, CachedResourcePageKey) || this.isAlias(originalKey, CachedResourcePageListKey);
const allKey = this.isAlias(originalKey, CachedMapAllKey);
if (allKey) {
@@ -38,6 +38,7 @@ interface IState {
activeProvider: AuthProvider | null;
activeConfiguration: AuthProviderConfiguration | null;
credentials: IAuthCredentials;
tabIds: string[];
setTabId: (tabId: string | null) => void;
setActiveProvider: (provider: AuthProvider | null, configuration: AuthProviderConfiguration | null) => void;
@@ -53,52 +54,6 @@ export function useAuthDialogState(accessRequest: boolean, providerId: string |
const adminPageActive = administrationScreenService.isAdministrationPageActive;
const providers = authProvidersResource.data.filter(notEmptyProvider).sort(compareProviders);
const state = useObservableRef<IState>(
() => ({
tabId: null,
activeProvider: null,
activeConfiguration: null,
credentials: {
profile: '0',
credentials: {},
},
setTabId(tabId: string | null): void {
this.tabId = tabId;
},
setActiveProvider(provider: AuthProvider | null, configuration: AuthProviderConfiguration | null): void {
const providerChanged = this.activeProvider?.id !== provider?.id;
const configurationChanged = this.activeConfiguration?.id !== configuration?.id;
this.activeProvider = provider;
this.activeConfiguration = configuration;
if (providerChanged || configurationChanged) {
this.credentials.profile = '0';
this.credentials.credentials = {};
}
if (provider) {
if (provider.federated) {
this.setTabId(FEDERATED_AUTH);
} else {
this.setTabId(getAuthProviderTabId(provider, configuration));
}
} else {
this.setTabId(null);
}
},
}),
{
tabId: observable.ref,
activeProvider: observable.ref,
activeConfiguration: observable.ref,
credentials: observable,
setActiveProvider: action,
},
false,
);
const activeProviders = providers.filter(provider => {
if (provider.id === primaryId && adminPageActive && accessRequest) {
return true;
@@ -146,6 +101,54 @@ export function useAuthDialogState(accessRequest: boolean, providerId: string |
if (federatedProviders.length > 0) {
tabIds.push(FEDERATED_AUTH);
}
const state = useObservableRef<IState>(
() => ({
tabId: null,
activeProvider: null,
activeConfiguration: null,
credentials: {
profile: '0',
credentials: {},
},
setTabId(tabId: string | null): void {
if (tabIds.includes(tabId as any)) {
this.tabId = tabId;
} else {
this.tabId = tabIds[0] ?? null;
}
},
setActiveProvider(provider: AuthProvider | null, configuration: AuthProviderConfiguration | null): void {
const providerChanged = this.activeProvider?.id !== provider?.id;
const configurationChanged = this.activeConfiguration?.id !== configuration?.id;
this.activeProvider = provider;
this.activeConfiguration = configuration;
if (providerChanged || configurationChanged) {
this.credentials.profile = '0';
this.credentials.credentials = {};
}
if (provider) {
if (provider.federated) {
this.setTabId(FEDERATED_AUTH);
} else {
this.setTabId(getAuthProviderTabId(provider, configuration));
}
} else {
this.setTabId(null);
}
},
}),
{
tabId: observable.ref,
activeProvider: observable.ref,
activeConfiguration: observable.ref,
credentials: observable,
setActiveProvider: action,
},
{ tabIds },
);
const data = useObservableRef<IData>(
() => ({