From 5a105bea820d4154aeff039e08cf9ff0c96dc95e Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Thu, 18 Mar 2021 18:28:33 +0530 Subject: [PATCH] mgr/dashboard: Fix for broken User management role cloning Cloning a role in user management gets hit with a 415 error. Fixes: https://tracker.ceph.com/issues/49880 Signed-off-by: Nizamudeen A --- .../frontend/src/app/shared/api/role.service.spec.ts | 3 ++- .../dashboard/frontend/src/app/shared/api/role.service.ts | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.spec.ts index 8505461ff9596..c5af5877c84b3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.spec.ts @@ -46,8 +46,9 @@ describe('RoleService', () => { it('should call clone', () => { service.clone('foo', 'bar').subscribe(); - const req = httpTesting.expectOne('api/role/foo/clone?new_name=bar'); + const req = httpTesting.expectOne('api/role/foo/clone'); expect(req.request.method).toBe('POST'); + expect(req.request.body).toEqual({ new_name: 'bar' }); }); it('should check if role name exists', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.ts index 7dc906da18bb7..e76846b418f06 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/role.service.ts @@ -1,4 +1,4 @@ -import { HttpClient, HttpParams } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable, of as observableOf } from 'rxjs'; @@ -29,9 +29,7 @@ export class RoleService { } clone(name: string, newName: string) { - let params = new HttpParams(); - params = params.append('new_name', newName); - return this.http.post(`api/role/${name}/clone`, null, { params }); + return this.http.post(`api/role/${name}/clone`, { new_name: newName }); } update(role: RoleFormModel) { -- 2.39.5