mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-17 04:11:24 +01:00
Merge pull request #4174 from pengpengshui/batchDelection
Modify users about delete myself display issue #4164
This commit is contained in:
commit
f70c656817
@ -16,7 +16,7 @@ export const LIST_REPLICATION_RULE_TEMPLATE: string = `
|
||||
<clr-dg-row *clrDgItems="let p of changedRules" [clrDgItem]="p" (click)="selectRule(p)" [style.backgroundColor]="(projectScope && withReplicationJob && selectedId === p.id) ? '#eee' : ''">
|
||||
<clr-dg-cell>{{p.name}}</clr-dg-cell>
|
||||
<clr-dg-cell *ngIf="!projectScope">
|
||||
<a href="javascript:void(0)" (click)="redirectTo(p)">{{p.projects?.length>0 ? p.projects[0].name : ''}}</a>
|
||||
<a href="javascript:void(0)" (click)="$event.stopPropagation(); redirectTo(p)">{{p.projects?.length>0 ? p.projects[0].name : ''}}</a>
|
||||
</clr-dg-cell>
|
||||
<clr-dg-cell>
|
||||
{{p.description ? trancatedDescription(p.description) : '-'}}
|
||||
|
@ -8,7 +8,7 @@ export const COPY_INPUT_HTML = `
|
||||
<input type="text" class="command-input" size="{{inputSize}}" [(ngModel)]="defaultValue" #inputTarget readonly/>
|
||||
</span>
|
||||
<span>
|
||||
<input type="text" size="{{inputSize}}" [(ngModel)]="defaultValue" #inputTarget1 style="width: 1px; min-width: 0px; padding: 0;">
|
||||
<input type="text" size="{{inputSize}}" [(ngModel)]="defaultValue" #inputTarget1 style="width: 1px; min-width: 0px; padding: 0; opacity: .1;">
|
||||
</span>
|
||||
<span>
|
||||
<clr-icon shape="copy" [class.is-success]="isCopied" [class.is-error]="hasCopyError" class="info-tips-icon" size="24" [ngxClipboard]="inputTarget1" (cbOnSuccess)="onSuccess($event)" (cbOnError)="onError($event)"></clr-icon>
|
||||
|
@ -31,7 +31,7 @@
|
||||
"clarity-icons": "^0.10.17",
|
||||
"clarity-ui": "^0.10.17",
|
||||
"core-js": "^2.4.1",
|
||||
"harbor-ui": "0.6.41",
|
||||
"harbor-ui": "0.6.42",
|
||||
"intl": "^1.2.5",
|
||||
"mutationobserver-shim": "^0.3.2",
|
||||
"ngx-cookie": "^1.0.0",
|
||||
|
@ -471,6 +471,7 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
this.repService.updateEndpoint(endpointId, pullData)
|
||||
.then((res: any) => {
|
||||
this.saveRuleOpe();
|
||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
this.inProgress = false;
|
||||
|
@ -58,7 +58,7 @@
|
||||
<div formArrayName="targets">
|
||||
<div class="select endpointSelect pull-left" *ngFor="let target of targets.controls; let i= index" [formGroupName]="i">
|
||||
<select id="ruleTarget " class="inputWidth" (change)="targetChange($event)" formControlName="id">
|
||||
<option *ngFor="let target of targetList" value="{{target.id}}">{{target.name}}<span [hidden]="!target.name">:</span> {{target.endpoint}}</option>
|
||||
<option *ngFor="let target of targetList" value="{{target.id}}">{{target.name}}-{{target.endpoint}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-info btn-sm addEndpoint" (click)="openModal()"><clr-icon shape="plus"></clr-icon> {{'REPLICATION.NEW' | translate}}</button>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<clr-dg-action-bar>
|
||||
<button type="button" class="btn btn-sm btn-secondary" (click)="addNewUser()" [disabled]="!canCreateUser"><clr-icon shape="plus" size="16"></clr-icon> {{'USER.ADD_ACTION' | translate}}</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="set-admin" [disabled]="!ifSameRole" (click)="changeAdminRole()" ><clr-icon shape="wrench" size="16"></clr-icon> {{ISADMNISTRATOR | translate}}</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" (click)="deleteUsers(selectedRow)" [disabled]="!selectedRow.length || !canCreateUser"><clr-icon shape="times" size="16"></clr-icon> {{'USER.DEL_ACTION' | translate}}</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" (click)="deleteUsers(selectedRow)" [disabled]="!selectedRow.length || onlySelf || !canCreateUser"><clr-icon shape="times" size="16"></clr-icon> {{'USER.DEL_ACTION' | translate}}</button>
|
||||
</clr-dg-action-bar>
|
||||
<clr-dg-column>{{'USER.COLUMN_NAME' | translate}}</clr-dg-column>
|
||||
<clr-dg-column>{{'USER.COLUMN_ADMIN' | translate}}</clr-dg-column>
|
||||
|
@ -94,6 +94,10 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
|
||||
get onlySelf(): boolean {
|
||||
return this.selectedRow.length === 1 && this.isMySelf(this.selectedRow[0].user_id);
|
||||
}
|
||||
|
||||
private isMatchFilterTerm(terms: string, testedItem: string): boolean {
|
||||
return testedItem.toLowerCase().indexOf(terms.toLowerCase()) !== -1;
|
||||
}
|
||||
@ -222,17 +226,17 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
deleteUsers(users: User[]): void {
|
||||
let userArr: string[] = [];
|
||||
this.batchDelectionInfos = [];
|
||||
if (users && users.length) {
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
if (this.onlySelf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isMySelf(users[i].user_id)) {
|
||||
continue; //Double confirm
|
||||
}
|
||||
let initBatchMessage = new BatchInfo ();
|
||||
initBatchMessage.name = users[i].username;
|
||||
this.batchDelectionInfos.push(initBatchMessage);
|
||||
userArr.push(users[i].username);
|
||||
}
|
||||
if (users && users.length) {
|
||||
users.forEach(user => {
|
||||
let initBatchMessage = new BatchInfo ();
|
||||
initBatchMessage.name = user.username;
|
||||
this.batchDelectionInfos.push(initBatchMessage);
|
||||
userArr.push(user.username);
|
||||
})
|
||||
this.deletionDialogService.addBatchInfoList(this.batchDelectionInfos);
|
||||
//Confirm deletion
|
||||
let msg: ConfirmationMessage = new ConfirmationMessage(
|
||||
@ -252,7 +256,14 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
let promiseLists: any[] = [];
|
||||
if (users && users.length) {
|
||||
users.forEach(user => {
|
||||
promiseLists.push(this.delOperate(user.user_id, user.username));
|
||||
let findedList = this.batchDelectionInfos.find(data => data.name === user.username);
|
||||
if (this.isMySelf(user.user_id)) {
|
||||
this.translate.get('BATCH.DELETED_FAILURE').subscribe(res => {
|
||||
findedList = BathInfoChanges(findedList, res, false, true);
|
||||
});
|
||||
} else {
|
||||
promiseLists.push(this.delOperate(user.user_id, user.username));
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(promiseLists).then((item) => {
|
||||
|
Loading…
Reference in New Issue
Block a user