Merge pull request #4369 from atmire/w2p-130679_fix-back-button-on-group-roles-page-contribute_7.6

This commit is contained in:
Alan Orth
2025-09-15 08:56:29 +03:00
committed by GitHub
2 changed files with 10 additions and 1 deletions

View File

@@ -38,6 +38,8 @@ import { NoContent } from '../../../core/shared/NoContent.model';
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
import { DSONameServiceMock } from '../../../shared/mocks/dso-name.service.mock';
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
import { routeServiceStub } from '../../../shared/testing/route-service.stub';
import { RouteService } from '../../../core/services/route.service';
describe('GroupFormComponent', () => {
let component: GroupFormComponent;
@@ -230,6 +232,7 @@ describe('GroupFormComponent', () => {
{ provide: ActivatedRoute, useValue: route },
{ provide: Router, useValue: router },
{ provide: AuthorizationDataService, useValue: authorizationService },
{ provide: RouteService, useValue: routeServiceStub },
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();

View File

@@ -46,6 +46,7 @@ import { ValidateGroupExists } from './validators/group-exists.validator';
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
import { environment } from '../../../../environments/environment';
import { getGroupEditRoute, getGroupsRoute } from '../../access-control-routing-paths';
import { RouteService } from '../../../core/services/route.service';
@Component({
selector: 'ds-group-form',
@@ -155,6 +156,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
public requestService: RequestService,
protected changeDetectorRef: ChangeDetectorRef,
public dsoNameService: DSONameService,
protected routeService: RouteService,
) {
}
@@ -267,7 +269,11 @@ export class GroupFormComponent implements OnInit, OnDestroy {
onCancel() {
this.groupDataService.cancelEditGroup();
this.cancelForm.emit();
void this.router.navigate([getGroupsRoute()]);
this.routeService.getPreviousUrl().pipe(
take(1),
).subscribe((previousURL) => {
void this.router.navigate([previousURL && previousURL.trim().length > 0 ? previousURL : getGroupsRoute()]);
});
}
/**