[ACS-9554] Redirect from permissions page after node delete (#4531)

This commit is contained in:
Mykyta Maliarchuk 2025-04-25 10:33:57 +02:00 committed by GitHub
parent 5a168fa0c2
commit ba1ef44fdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -29,7 +29,7 @@ import { ActivatedRoute } from '@angular/router';
import { BehaviorSubject, of, Subject } from 'rxjs'; import { BehaviorSubject, of, Subject } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { ContentApiService } from '@alfresco/aca-shared'; import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { NavigateToFolder, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; import { NavigateToFolder, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { Node, NodeEntry, PathElement } from '@alfresco/js-api'; import { Node, NodeEntry, PathElement } from '@alfresco/js-api';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
@ -38,6 +38,7 @@ import { BreadcrumbComponent, ContentService, NodesApiService, SearchQueryBuilde
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { ContentActionRef } from '@alfresco/adf-extensions'; import { ContentActionRef } from '@alfresco/adf-extensions';
import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSnackBarModule } from '@angular/material/snack-bar';
import { Location } from '@angular/common';
describe('DetailsComponent', () => { describe('DetailsComponent', () => {
let component: DetailsComponent; let component: DetailsComponent;
@ -45,6 +46,8 @@ describe('DetailsComponent', () => {
let contentApiService: ContentApiService; let contentApiService: ContentApiService;
let contentService: ContentService; let contentService: ContentService;
let nodesApiService: NodesApiService; let nodesApiService: NodesApiService;
let appHookService: AppHookService;
let location: Location;
let store: Store; let store: Store;
let node: NodeEntry; let node: NodeEntry;
@ -101,6 +104,8 @@ describe('DetailsComponent', () => {
contentApiService = TestBed.inject(ContentApiService); contentApiService = TestBed.inject(ContentApiService);
contentService = TestBed.inject(ContentService); contentService = TestBed.inject(ContentService);
nodesApiService = TestBed.inject(NodesApiService); nodesApiService = TestBed.inject(NodesApiService);
appHookService = TestBed.inject(AppHookService);
location = TestBed.inject(Location);
store = TestBed.inject(Store); store = TestBed.inject(Store);
storeMock.dispatch.calls.reset(); storeMock.dispatch.calls.reset();
@ -258,4 +263,12 @@ describe('DetailsComponent', () => {
component.setActiveTab('permissions'); component.setActiveTab('permissions');
expect(component.activeTab).not.toBe(2); expect(component.activeTab).not.toBe(2);
}); });
it('should navigate back when nodesDeleted event is triggered', () => {
const locationSpy = spyOn(location, 'back');
fixture.detectChanges();
appHookService.nodesDeleted.next();
expect(locationSpy).toHaveBeenCalled();
});
}); });

View File

@ -24,10 +24,10 @@
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { ContentApiService, PageComponent, PageLayoutComponent, ToolbarComponent } from '@alfresco/aca-shared'; import { AppHookService, ContentApiService, PageComponent, PageLayoutComponent, ToolbarComponent } from '@alfresco/aca-shared';
import { NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; import { NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { BreadcrumbComponent, ContentService, NodesApiService, PermissionListComponent } from '@alfresco/adf-content-services'; import { BreadcrumbComponent, ContentService, NodesApiService, PermissionListComponent } from '@alfresco/adf-content-services';
import { CommonModule } from '@angular/common'; import { CommonModule, Location } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MatTabsModule } from '@angular/material/tabs'; import { MatTabsModule } from '@angular/material/tabs';
@ -76,7 +76,9 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
private readonly route: ActivatedRoute, private readonly route: ActivatedRoute,
private readonly contentApi: ContentApiService, private readonly contentApi: ContentApiService,
private readonly contentService: ContentService, private readonly contentService: ContentService,
private readonly nodesApiService: NodesApiService private readonly nodesApiService: NodesApiService,
private readonly appHookService: AppHookService,
private readonly location: Location
) { ) {
super(); super();
} }
@ -88,6 +90,7 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
const { data } = route.snapshot; const { data } = route.snapshot;
this.title = data.title; this.title = data.title;
this.nodesApiService.nodeUpdated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((node) => (this.node = { ...node })); this.nodesApiService.nodeUpdated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((node) => (this.node = { ...node }));
this.appHookService.nodesDeleted.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.location.back());
this.route.params.subscribe((params) => { this.route.params.subscribe((params) => {
this.isLoading = true; this.isLoading = true;
this.setActiveTab(params.activeTab); this.setActiveTab(params.activeTab);