From f6b86bbf2fec6e656c65c6cc8c427b916193a1b1 Mon Sep 17 00:00:00 2001 From: pujashahu Date: Tue, 17 Sep 2024 19:58:24 +0530 Subject: [PATCH] mgr/dashboard: carbonize user management-role form Fixes: https://tracker.ceph.com/issues/68123 Signed-off-by: Puja Shahu Signed-off-by: pujashahu --- .../frontend/src/app/core/auth/auth.module.ts | 8 +- .../auth/role-form/role-form.component.html | 135 +++++++++--------- .../checked-table-form.component.html | 57 ++++---- .../checked-table-form.component.spec.ts | 2 +- .../checked-table-form.component.ts | 5 +- 5 files changed, 104 insertions(+), 103 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/auth.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/auth.module.ts index eedcdd686021d..c0e0517896cd1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/auth.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/auth.module.ts @@ -17,7 +17,7 @@ import { UserFormComponent } from './user-form/user-form.component'; import { UserListComponent } from './user-list/user-list.component'; import { UserPasswordFormComponent } from './user-password-form/user-password-form.component'; import { UserTabsComponent } from './user-tabs/user-tabs.component'; - +import { ButtonModule, GridModule, IconModule, InputModule } from 'carbon-components-angular'; @NgModule({ imports: [ CommonModule, @@ -28,7 +28,11 @@ import { UserTabsComponent } from './user-tabs/user-tabs.component'; NgbPopoverModule, NgxPipeFunctionModule, RouterModule, - NgbModule + NgbModule, + IconModule, + GridModule, + ButtonModule, + InputModule ], declarations: [ LoginComponent, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.html index 9b792d127f125..7f79f92464d71 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.html @@ -1,75 +1,74 @@ -
-
-
+
+ +
{{ action | titlecase }} {{ resource | upperFirst }}
-
- - -
- -
- - This field is required. - The chosen name is already in use. -
-
- - -
- -
- -
-
- - -
- -
- -
-
- + class="form-header">{{ action | titlecase }} {{ resource | upperFirst }}
- - + +
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.html index 267d3e798fb79..da5080f3cc28d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.html @@ -9,49 +9,46 @@ [layer]="0" [limit]="0"> - -
- - +
+ + {{ value }} +
- -
- - +
+ + +
- -
- - +
+ + {{ column.name }} +
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.spec.ts index 73c7e7e3bff24..fbd2c63fc4898 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.spec.ts @@ -106,7 +106,7 @@ describe('CheckedTableFormComponent', () => { owner: ['read', 'write'], group: ['execute'] }); - component.onClickHeaderCheckbox('scope', ({ target: { checked: true } } as unknown) as Event); + component.onClickHeaderCheckbox('scope', true); const scopes_permissions = form.getValue('scopes_permissions'); const keys = Object.keys(scopes_permissions); expect(keys).toEqual(['owner', 'group']); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.ts index e592c3ff4f57b..5c1b2a71054c6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/checked-table-form/checked-table-form.component.ts @@ -126,7 +126,8 @@ export class CheckedTableFormComponent implements OnInit { // Add or remove the given permission(s) depending on the click event or if no // click event is given then add/remove them if they are absent/exist. if ( - (event && event.target['checked']) || + event || + event === true || !_.isEqual(permissions.sort(), _.intersection(scopes_permissions[scope], permissions).sort()) ) { scopes_permissions[scope] = _.union(scopes_permissions[scope], permissions); @@ -151,7 +152,7 @@ export class CheckedTableFormComponent implements OnInit { } _.each(permissions, (permission) => { _.each(this.scopes, (scope) => { - if (event.target['checked']) { + if (event === true) { scopes_permissions[scope] = _.union(scopes_permissions[scope], [permission]); } else { scopes_permissions[scope] = _.difference(scopes_permissions[scope], [permission]); -- 2.39.5