Skip to content

Commit

Permalink
add debugging snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Platonn committed Jan 20, 2025
1 parent ff23d3a commit c65487a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, Injector } from '@angular/core';
import { B2BUser, B2BUserRole, B2BUserRight } from '@spartacus/core';
import { Observable, Subscription } from 'rxjs';
import { startWith, switchMap } from 'rxjs/operators';
Expand Down Expand Up @@ -43,8 +43,13 @@ export class UserDetailsComponent {

constructor(
protected itemService: ItemService<B2BUser>,
protected b2bUserService: B2BUserService
) {}
protected b2bUserService: B2BUserService,
protected injector: Injector
) {
console.log({
UserDetailsComponent: this,
});
}

hasRight(model: B2BUser): boolean {
return (model.roles ?? []).some((role: string) =>
Expand Down
15 changes: 12 additions & 3 deletions feature-libs/organization/administration/core/guards/user.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Injectable } from '@angular/core';
import { Injectable, Injector } from '@angular/core';
import { Router, UrlTree } from '@angular/router';
import {
GlobalMessageService,
Expand All @@ -13,14 +13,23 @@ import {
} from '@spartacus/core';
import { B2BUserService } from '../services';

let UserGuard_count = 0;

@Injectable()
export class UserGuard {
UserGuard_count = ++UserGuard_count;

constructor(
protected globalMessageService: GlobalMessageService,
protected b2bUserService: B2BUserService,
protected semanticPathService: SemanticPathService,
protected router: Router
) {}
protected router: Router,
protected injector: Injector
) {
console.log({
UserGuard: this,
});
}

canActivate(): boolean | UrlTree {
const isUpdatingUserAllowed = this.b2bUserService.isUpdatingUserAllowed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Injectable } from '@angular/core';
import { Injectable, Injector } from '@angular/core';
import { Store } from '@ngrx/store';
import {
B2BUser,
Expand Down Expand Up @@ -32,12 +32,21 @@ import {
} from '../store/selectors/b2b-user.selector';
import { getItemStatus } from '../utils/get-item-status';

let B2BUserService_count = 0;

@Injectable({ providedIn: 'root' })
export class B2BUserService {
B2BUserService_count = ++B2BUserService_count;

constructor(
protected store: Store<StateWithOrganization>,
protected userIdService: UserIdService
) {}
protected userIdService: UserIdService,
protected injector: Injector
) {
console.log({
B2BUserService: this,
});
}

load(orgCustomerId: string) {
this.userIdService.takeUserId(true).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Injectable } from '@angular/core';
import { B2BUserService } from '@spartacus/organization/administration/core';
import { Injectable, Injector } from '@angular/core';
import { Store } from '@ngrx/store';
import { UserIdService } from '@spartacus/core';
import {
B2BUserService,
StateWithOrganization,
} from '@spartacus/organization/administration/core';

let CDC_B2BUserService_count = 0;

@Injectable({
providedIn: 'root',
})
export class CdcB2BUserService extends B2BUserService {
CDC_B2BUserService_count = ++CDC_B2BUserService_count;

constructor(
protected store: Store<StateWithOrganization>,
protected userIdService: UserIdService,
protected injector: Injector
) {
super(store, userIdService, injector);
console.log({
CdcB2BUserService: this,
});
}

isUpdatingUserAllowed(): boolean {
return false;
}
Expand Down

0 comments on commit c65487a

Please sign in to comment.