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';
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
) {
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,
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();
}
);
}
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}'`
+ );
+ });
}
});
}