mirror of
https://github.com/goharbor/harbor
synced 2025-05-15 02:37:53 +00:00
Merge pull request #2 from steven-zou/fix/issue_1766
fix self deletion issue of #1766
This commit is contained in:
commit
3a3b1c5ad5
@ -17,7 +17,7 @@
|
|||||||
<clr-dg-column>{{'USER.COLUMN_EMAIL' | translate}}</clr-dg-column>
|
<clr-dg-column>{{'USER.COLUMN_EMAIL' | translate}}</clr-dg-column>
|
||||||
<clr-dg-column>{{'USER.COLUMN_REG_NAME' | translate}}</clr-dg-column>
|
<clr-dg-column>{{'USER.COLUMN_REG_NAME' | translate}}</clr-dg-column>
|
||||||
<clr-dg-row *ngFor="let user of users" [clrDgItem]="user">
|
<clr-dg-row *ngFor="let user of users" [clrDgItem]="user">
|
||||||
<clr-dg-action-overflow>
|
<clr-dg-action-overflow [hidden]="isMySelf(user.user_id)">
|
||||||
<button class="action-item" (click)="changeAdminRole(user)">{{adminActions(user)}}</button>
|
<button class="action-item" (click)="changeAdminRole(user)">{{adminActions(user)}}</button>
|
||||||
<button class="action-item" (click)="deleteUser(user)">{{'USER.DEL_ACTION' | translate}}</button>
|
<button class="action-item" (click)="deleteUser(user)">{{'USER.DEL_ACTION' | translate}}</button>
|
||||||
</clr-dg-action-overflow>
|
</clr-dg-action-overflow>
|
||||||
|
@ -12,6 +12,8 @@ import { ConfirmationState, ConfirmationTargets, AlertType, httpStatusCode } fro
|
|||||||
import { errorHandler, accessErrorHandler } from '../shared/shared.utils';
|
import { errorHandler, accessErrorHandler } from '../shared/shared.utils';
|
||||||
import { MessageService } from '../global-message/message.service';
|
import { MessageService } from '../global-message/message.service';
|
||||||
|
|
||||||
|
import { SessionService } from '../shared/session.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'harbor-user',
|
selector: 'harbor-user',
|
||||||
templateUrl: 'user.component.html',
|
templateUrl: 'user.component.html',
|
||||||
@ -35,7 +37,8 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private deletionDialogService: ConfirmationDialogService,
|
private deletionDialogService: ConfirmationDialogService,
|
||||||
private msgService: MessageService) {
|
private msgService: MessageService,
|
||||||
|
private session: SessionService) {
|
||||||
this.deletionSubscription = deletionDialogService.confirmationConfirm$.subscribe(confirmed => {
|
this.deletionSubscription = deletionDialogService.confirmationConfirm$.subscribe(confirmed => {
|
||||||
if (confirmed &&
|
if (confirmed &&
|
||||||
confirmed.source === ConfirmationTargets.USER &&
|
confirmed.source === ConfirmationTargets.USER &&
|
||||||
@ -45,6 +48,17 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isMySelf(uid: number): boolean {
|
||||||
|
let currentUser = this.session.getCurrentUser();
|
||||||
|
if(currentUser){
|
||||||
|
if(currentUser.user_id === uid ){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private isMatchFilterTerm(terms: string, testedItem: string): boolean {
|
private isMatchFilterTerm(terms: string, testedItem: string): boolean {
|
||||||
return testedItem.indexOf(terms) != -1;
|
return testedItem.indexOf(terms) != -1;
|
||||||
}
|
}
|
||||||
@ -101,6 +115,10 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.isMySelf(user.user_id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Value copy
|
//Value copy
|
||||||
let updatedUser: User = {
|
let updatedUser: User = {
|
||||||
user_id: user.user_id
|
user_id: user.user_id
|
||||||
@ -130,6 +148,10 @@ export class UserComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.isMySelf(user.user_id)){
|
||||||
|
return; //Double confirm
|
||||||
|
}
|
||||||
|
|
||||||
//Confirm deletion
|
//Confirm deletion
|
||||||
let msg: ConfirmationMessage = new ConfirmationMessage(
|
let msg: ConfirmationMessage = new ConfirmationMessage(
|
||||||
"USER.DELETION_TITLE",
|
"USER.DELETION_TITLE",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user