]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / core / auth / role-list / role-list.component.ts
index a945b79fae4d9751a9083ae333bfba71ed8c29c1..83dcd69fa57f27998d9750646cbe8167224dca4b 100644 (file)
@@ -1,26 +1,26 @@
 import { Component, OnInit } from '@angular/core';
 
-import { I18n } from '@ngx-translate/i18n-polyfill';
-import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
+import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
 import { forkJoin } from 'rxjs';
 
-import { RoleService } from '../../../shared/api/role.service';
-import { ScopeService } from '../../../shared/api/scope.service';
-import { ListWithDetails } from '../../../shared/classes/list-with-details.class';
-import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
-import { FormModalComponent } from '../../../shared/components/form-modal/form-modal.component';
-import { ActionLabelsI18n } from '../../../shared/constants/app.constants';
-import { CellTemplate } from '../../../shared/enum/cell-template.enum';
-import { Icons } from '../../../shared/enum/icons.enum';
-import { NotificationType } from '../../../shared/enum/notification-type.enum';
-import { CdTableAction } from '../../../shared/models/cd-table-action';
-import { CdTableColumn } from '../../../shared/models/cd-table-column';
-import { CdTableSelection } from '../../../shared/models/cd-table-selection';
-import { Permission } from '../../../shared/models/permissions';
-import { EmptyPipe } from '../../../shared/pipes/empty.pipe';
-import { AuthStorageService } from '../../../shared/services/auth-storage.service';
-import { NotificationService } from '../../../shared/services/notification.service';
-import { URLBuilderService } from '../../../shared/services/url-builder.service';
+import { RoleService } from '~/app/shared/api/role.service';
+import { ScopeService } from '~/app/shared/api/scope.service';
+import { ListWithDetails } from '~/app/shared/classes/list-with-details.class';
+import { CriticalConfirmationModalComponent } from '~/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
+import { FormModalComponent } from '~/app/shared/components/form-modal/form-modal.component';
+import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
+import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
+import { Icons } from '~/app/shared/enum/icons.enum';
+import { NotificationType } from '~/app/shared/enum/notification-type.enum';
+import { CdTableAction } from '~/app/shared/models/cd-table-action';
+import { CdTableColumn } from '~/app/shared/models/cd-table-column';
+import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
+import { Permission } from '~/app/shared/models/permissions';
+import { EmptyPipe } from '~/app/shared/pipes/empty.pipe';
+import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
+import { ModalService } from '~/app/shared/services/modal.service';
+import { NotificationService } from '~/app/shared/services/notification.service';
+import { URLBuilderService } from '~/app/shared/services/url-builder.service';
 
 const BASE_URL = 'user-management/roles';
 
@@ -38,16 +38,15 @@ export class RoleListComponent extends ListWithDetails implements OnInit {
   scopes: Array<string>;
   selection = new CdTableSelection();
 
-  modalRef: BsModalRef;
+  modalRef: NgbModalRef;
 
   constructor(
     private roleService: RoleService,
     private scopeService: ScopeService,
     private emptyPipe: EmptyPipe,
     private authStorageService: AuthStorageService,
-    private modalService: BsModalService,
+    private modalService: ModalService,
     private notificationService: NotificationService,
-    private i18n: I18n,
     private urlBuilder: URLBuilderService,
     public actionLabels: ActionLabelsI18n
   ) {
@@ -87,18 +86,18 @@ export class RoleListComponent extends ListWithDetails implements OnInit {
   ngOnInit() {
     this.columns = [
       {
-        name: this.i18n('Name'),
+        name: $localize`Name`,
         prop: 'name',
         flexGrow: 3
       },
       {
-        name: this.i18n('Description'),
+        name: $localize`Description`,
         prop: 'description',
         flexGrow: 5,
         pipe: this.emptyPipe
       },
       {
-        name: this.i18n('System Role'),
+        name: $localize`System Role`,
         prop: 'system',
         cellClass: 'text-center',
         flexGrow: 1,
@@ -124,14 +123,11 @@ export class RoleListComponent extends ListWithDetails implements OnInit {
     this.roleService.delete(role).subscribe(
       () => {
         this.getRoles();
-        this.modalRef.hide();
-        this.notificationService.show(
-          NotificationType.success,
-          this.i18n(`Deleted role '{{role_name}}'`, { role_name: role })
-        );
+        this.modalRef.close();
+        this.notificationService.show(NotificationType.success, $localize`Deleted role '${role}'`);
       },
       () => {
-        this.modalRef.content.stopLoadingSpinner();
+        this.modalRef.componentInstance.stopLoadingSpinner();
       }
     );
   }
@@ -139,41 +135,34 @@ export class RoleListComponent extends ListWithDetails implements OnInit {
   deleteRoleModal() {
     const name = this.selection.first().name;
     this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, {
-      initialState: {
-        itemDescription: 'Role',
-        itemNames: [name],
-        submitAction: () => this.deleteRole(name)
-      }
+      itemDescription: 'Role',
+      itemNames: [name],
+      submitAction: () => this.deleteRole(name)
     });
   }
 
   cloneRole() {
     const name = this.selection.first().name;
     this.modalRef = this.modalService.show(FormModalComponent, {
-      initialState: {
-        fields: [
-          {
-            type: 'text',
-            name: 'newName',
-            value: `${name}_clone`,
-            label: this.i18n('New name'),
-            required: true
-          }
-        ],
-        titleText: this.i18n('Clone Role'),
-        submitButtonText: this.i18n('Clone Role'),
-        onSubmit: (values: object) => {
-          this.roleService.clone(name, values['newName']).subscribe(() => {
-            this.getRoles();
-            this.notificationService.show(
-              NotificationType.success,
-              this.i18n(`Cloned role '{{dst_name}}' from '{{src_name}}'`, {
-                src_name: name,
-                dst_name: values['newName']
-              })
-            );
-          });
+      fields: [
+        {
+          type: 'text',
+          name: 'newName',
+          value: `${name}_clone`,
+          label: $localize`New name`,
+          required: true
         }
+      ],
+      titleText: $localize`Clone Role`,
+      submitButtonText: $localize`Clone Role`,
+      onSubmit: (values: object) => {
+        this.roleService.clone(name, values['newName']).subscribe(() => {
+          this.getRoles();
+          this.notificationService.show(
+            NotificationType.success,
+            $localize`Cloned role '${values['newName']}' from '${name}'`
+          );
+        });
       }
     });
   }