Fix show objects info (#388)

This commit is contained in:
Rinat Arsaev 2024-09-16 15:19:19 +05:00 committed by GitHub
parent a42d5ff26c
commit 693b90fb1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 13 deletions

View File

@ -51,8 +51,16 @@ export class DomainStoreService {
map(([s]) => s?.domain),
shareReplay({ refCount: true, bufferSize: 1 }),
);
private objects$ = this.rawDomain$.pipe(
map((domain) => new Map(Array.from(domain).map(([r, d]) => [createObjectHash(r), d]))),
private objects$ = combineLatest([this.rawDomain$, this.domain$]).pipe(
map(
([rawDomain, domain]) =>
new Map(
Array.from(rawDomain).map(([ref, raw]) => [
createObjectHash(ref),
{ raw, reduced: domain.get(ref) },
]),
),
),
shareReplay({ refCount: true, bufferSize: 1 }),
);
@ -69,10 +77,7 @@ export class DomainStoreService {
getObject(ref: Reference, raw = false): Observable<DomainObject> {
return this.objects$.pipe(
map((objects) => {
const res = objects.get(createObjectHash(ref));
return raw || !this.domainSecretService.isExcludedObject(res) ? res : undefined;
}),
map((objects) => objects.get(createObjectHash(ref))?.[raw ? 'raw' : 'reduced']),
);
}

View File

@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common';
import { Component, DestroyRef, Input, OnChanges } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatButtonModule } from '@angular/material/button';
import { Router } from '@angular/router';
import { Reference } from '@vality/domain-proto/internal/domain';
import { ComponentChanges, DialogService } from '@vality/ng-core';
import { isEqualThrift } from '@vality/ng-thrift';
@ -50,7 +49,6 @@ export class DomainObjectCardComponent implements OnChanges {
private domainStoreService: DomainStoreService,
private destroyRef: DestroyRef,
private dialogService: DialogService,
private router: Router,
) {}
ngOnChanges(changes: ComponentChanges<DomainObjectCardComponent>) {

View File

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core';
import { Domain, DomainObject } from '@vality/domain-proto/domain';
import { getUnionKey } from '@vality/ng-thrift';
import { KeycloakService } from 'keycloak-angular';
import cloneDeep from 'lodash-es/cloneDeep';
import isNil from 'lodash-es/isNil';
@ -22,10 +21,6 @@ export class DomainSecretService {
constructor(private keycloakService: KeycloakService) {}
isExcludedObject(obj: DomainObject) {
return !this.hasDominantSecretRole && EXCLUDE_OBJECTS.includes(getUnionKey(obj));
}
reduceDomain(domain: Domain): Domain {
if (this.hasDominantSecretRole) {
return domain;