Skip to content

Commit 92ffac6

Browse files
authored
Merge pull request #4369 from atmire/w2p-130679_fix-back-button-on-group-roles-page-contribute_7.6
2 parents ab53a7e + 084cad6 commit 92ffac6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/app/access-control/group-registry/group-form/group-form.component.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { NoContent } from '../../../core/shared/NoContent.model';
3838
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
3939
import { DSONameServiceMock } from '../../../shared/mocks/dso-name.service.mock';
4040
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
41+
import { routeServiceStub } from '../../../shared/testing/route-service.stub';
42+
import { RouteService } from '../../../core/services/route.service';
4143

4244
describe('GroupFormComponent', () => {
4345
let component: GroupFormComponent;
@@ -230,6 +232,7 @@ describe('GroupFormComponent', () => {
230232
{ provide: ActivatedRoute, useValue: route },
231233
{ provide: Router, useValue: router },
232234
{ provide: AuthorizationDataService, useValue: authorizationService },
235+
{ provide: RouteService, useValue: routeServiceStub },
233236
],
234237
schemas: [CUSTOM_ELEMENTS_SCHEMA],
235238
}).compileComponents();

src/app/access-control/group-registry/group-form/group-form.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { ValidateGroupExists } from './validators/group-exists.validator';
4646
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
4747
import { environment } from '../../../../environments/environment';
4848
import { getGroupEditRoute, getGroupsRoute } from '../../access-control-routing-paths';
49+
import { RouteService } from '../../../core/services/route.service';
4950

5051
@Component({
5152
selector: 'ds-group-form',
@@ -155,6 +156,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
155156
public requestService: RequestService,
156157
protected changeDetectorRef: ChangeDetectorRef,
157158
public dsoNameService: DSONameService,
159+
protected routeService: RouteService,
158160
) {
159161
}
160162

@@ -267,7 +269,11 @@ export class GroupFormComponent implements OnInit, OnDestroy {
267269
onCancel() {
268270
this.groupDataService.cancelEditGroup();
269271
this.cancelForm.emit();
270-
void this.router.navigate([getGroupsRoute()]);
272+
this.routeService.getPreviousUrl().pipe(
273+
take(1),
274+
).subscribe((previousURL) => {
275+
void this.router.navigate([previousURL && previousURL.trim().length > 0 ? previousURL : getGroupsRoute()]);
276+
});
271277
}
272278

273279
/**

0 commit comments

Comments
 (0)