From 008cf32bb3d38f3469e2c2bc1ee9c5b1ffaad9e3 Mon Sep 17 00:00:00 2001 From: pfh Date: Mon, 29 Jan 2018 19:34:24 +0800 Subject: [PATCH 1/2] Modify users about delete myself display issue #4164 --- .../lib/src/push-image/copy-input.html.ts | 2 +- .../replication-rule.component.ts | 1 + .../replication-rule/replication-rule.html | 2 +- src/ui_ng/src/app/user/user.component.html | 2 +- src/ui_ng/src/app/user/user.component.ts | 33 ++++++++++++------- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/ui_ng/lib/src/push-image/copy-input.html.ts b/src/ui_ng/lib/src/push-image/copy-input.html.ts index 631c0b8c43..4006358b43 100644 --- a/src/ui_ng/lib/src/push-image/copy-input.html.ts +++ b/src/ui_ng/lib/src/push-image/copy-input.html.ts @@ -8,7 +8,7 @@ export const COPY_INPUT_HTML = ` - + diff --git a/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts b/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts index 311316cab4..1ccb7d7b70 100644 --- a/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts +++ b/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts @@ -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; diff --git a/src/ui_ng/src/app/replication/replication-rule/replication-rule.html b/src/ui_ng/src/app/replication/replication-rule/replication-rule.html index b0e1105b8f..d2ea5266c3 100644 --- a/src/ui_ng/src/app/replication/replication-rule/replication-rule.html +++ b/src/ui_ng/src/app/replication/replication-rule/replication-rule.html @@ -58,7 +58,7 @@
diff --git a/src/ui_ng/src/app/user/user.component.html b/src/ui_ng/src/app/user/user.component.html index fe8abb1609..6914135f33 100644 --- a/src/ui_ng/src/app/user/user.component.html +++ b/src/ui_ng/src/app/user/user.component.html @@ -13,7 +13,7 @@ - + {{'USER.COLUMN_NAME' | translate}} {{'USER.COLUMN_ADMIN' | translate}} diff --git a/src/ui_ng/src/app/user/user.component.ts b/src/ui_ng/src/app/user/user.component.ts index 473d219a7e..48ca425d88 100644 --- a/src/ui_ng/src/app/user/user.component.ts +++ b/src/ui_ng/src/app/user/user.component.ts @@ -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) => { From 84c9a409ed642161836e8120fe75ba5e5cdc4e11 Mon Sep 17 00:00:00 2001 From: pfh Date: Tue, 30 Jan 2018 11:53:53 +0800 Subject: [PATCH 2/2] Stop bubbling event in replication list --- .../list-replication-rule.component.html.ts | 2 +- src/ui_ng/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui_ng/lib/src/list-replication-rule/list-replication-rule.component.html.ts b/src/ui_ng/lib/src/list-replication-rule/list-replication-rule.component.html.ts index 444cbad417..9faec0912a 100644 --- a/src/ui_ng/lib/src/list-replication-rule/list-replication-rule.component.html.ts +++ b/src/ui_ng/lib/src/list-replication-rule/list-replication-rule.component.html.ts @@ -16,7 +16,7 @@ export const LIST_REPLICATION_RULE_TEMPLATE: string = ` {{p.name}} - {{p.projects?.length>0 ? p.projects[0].name : ''}} + {{p.projects?.length>0 ? p.projects[0].name : ''}} {{p.description ? trancatedDescription(p.description) : '-'}} diff --git a/src/ui_ng/package.json b/src/ui_ng/package.json index 04c4ae3152..dfa4fe6a51 100644 --- a/src/ui_ng/package.json +++ b/src/ui_ng/package.json @@ -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",