Skip to content

Commit

Permalink
Merge pull request exadel-inc#692 from exadel-inc/EFRS-1182/BugFix-Se…
Browse files Browse the repository at this point in the history
…rvices-X-button-is-not-working-properly-and-invalid-minimum-number-of-characters-when-creating-a-clone-of-service

EFRS-1182/BugFix  prevent cloning service when click on X button
  • Loading branch information
smchedlidze826 committed Jan 5, 2022
2 parents ab14f27 + b36d9bc commit b695010
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FormsModule } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { MatInputModule } from '@angular/material/input';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { of, Subscription } from 'rxjs';
import { SnackBarModule } from 'src/app/features/snackbar/snackbar.module';
Expand All @@ -36,7 +37,16 @@ describe('ApplicationUserListComponent', () => {
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ApplicationUserListComponent, TranslatePipe],
imports: [SpinnerModule, UserTableModule, NoopAnimationsModule, FormsModule, TablePipeModule, MatInputModule, SnackBarModule],
imports: [
SpinnerModule,
UserTableModule,
NoopAnimationsModule,
FormsModule,
TablePipeModule,
MatInputModule,
SnackBarModule,
RouterTestingModule,
],
providers: [
{
provide: MatDialog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ <h1 mat-dialog-title>{{ 'common.capital.clone' | translate }} {{ data.entityType
{{ 'common.capital.clone' | translate }}
</button>
</div>
<button class="button-cross" mat-icon-button [mat-dialog-close]="initialName">
<button class="button-cross" mat-icon-button (click)="dialogRef.close()">
<mat-icon svgIcon="cross_new" inline="true"></mat-icon>
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export class ModelCloneDialogComponent {
constructor(public dialogRef: MatDialogRef<ModelCloneDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any) {}

get isCloneDisabled(): boolean {
return this.initialName ? this.initialName.length < 3 : true;
return this.initialName ? this.initialName.length < 1 : true;
}
}
2 changes: 2 additions & 0 deletions ui/src/app/features/user-list/user-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FormsModule } from '@angular/forms';
import { MatDialogModule } from '@angular/material/dialog';
import { MatInputModule } from '@angular/material/input';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { of, Subscription } from 'rxjs';
import { SpinnerModule } from 'src/app/features/spinner/spinner.module';
Expand Down Expand Up @@ -47,6 +48,7 @@ describe('UserListComponent', () => {
MatInputModule,
MatDialogModule,
InviteDialogModule,
RouterTestingModule,
],
declarations: [UserListComponent, TranslatePipe],
providers: [
Expand Down
12 changes: 11 additions & 1 deletion ui/src/app/features/user-table/user-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { TranslateService } from '@ngx-translate/core';
import { RoleEditDialogComponent } from '../role-edit-dialog/role-edit-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { UserRole } from '../../data/interfaces/user-role';
import { Router } from '@angular/router';
import { Routes } from 'src/app/data/enums/routers-url.enum';

@Component({
selector: 'app-user-table',
Expand All @@ -42,7 +44,7 @@ export class UserTableComponent extends TableComponent implements OnInit, OnChan
@Input() searchText: string;
@Output() deleteUser = new EventEmitter<UserDeletion>();

constructor(private dialog: MatDialog, private translate: TranslateService) {
constructor(private dialog: MatDialog, private translate: TranslateService, private router: Router) {
super();
}

Expand All @@ -53,6 +55,14 @@ export class UserTableComponent extends TableComponent implements OnInit, OnChan

ngOnChanges(): void {
this.getMessageContent();

if (!this.data.length) return;

const userIsInvited = !!this.data.find(item => item.id === this.currentUserId);

if (!userIsInvited) {
this.router.navigate([Routes.Home]);
}
}

isRoleChangeAllowed(user: AppUser): boolean {
Expand Down

0 comments on commit b695010

Please sign in to comment.