mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
Updates for verfied tags deletion.
This commit is contained in:
parent
e80840c2d3
commit
959af275d8
@ -1,10 +0,0 @@
|
||||
import { VerifiedSignature } from './verified-signature';
|
||||
|
||||
export const verifiedSignatures: VerifiedSignature[] = [
|
||||
{
|
||||
"tag": "latest",
|
||||
"hashes": {
|
||||
"sha256": "E1lggRW5RZnlZBY4usWu8d36p5u5YFfr9B68jTOs+Kc="
|
||||
}
|
||||
}
|
||||
];
|
@ -5,8 +5,6 @@ import { Repository } from './repository';
|
||||
import { Tag } from './tag';
|
||||
import { VerifiedSignature } from './verified-signature';
|
||||
|
||||
import { verifiedSignatures } from './mock-verfied-signature';
|
||||
|
||||
import { Observable } from 'rxjs/Observable'
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/operator/mergeMap';
|
||||
@ -43,25 +41,23 @@ export class RepositoryService {
|
||||
|
||||
listTagsWithVerifiedSignatures(repoName: string): Observable<Tag[]> {
|
||||
return this.http
|
||||
.get(`/api/repositories/tags?repo_name=${repoName}&detail=1`)
|
||||
.map(response=>response.json())
|
||||
.catch(error=>Observable.throw(error))
|
||||
.flatMap((tags: Tag[])=>
|
||||
this.http
|
||||
.get(`/api/repositories/signatures?repo_name=${repoName}`)
|
||||
.map(res=>{
|
||||
let signatures = res.json();
|
||||
tags.forEach(t=>{
|
||||
for(let i = 0; i < signatures.length; i++) {
|
||||
if(signatures[i].tag === t.tag) {
|
||||
t.verified = true;
|
||||
break;
|
||||
}
|
||||
.get(`/api/repositories/signatures?repo_name=${repoName}`)
|
||||
.map(response=>response)
|
||||
.flatMap(res=>
|
||||
this.listTags(repoName)
|
||||
.map((tags: Tag[])=>{
|
||||
let signatures = res.json();
|
||||
tags.forEach(t=>{
|
||||
for(let i = 0; i < signatures.length; i++) {
|
||||
if(signatures[i].tag === t.tag) {
|
||||
t.verified = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
return tags;
|
||||
})
|
||||
.catch(error=>Observable.throw(error))
|
||||
}
|
||||
});
|
||||
return tags;
|
||||
})
|
||||
.catch(error=>Observable.throw(error))
|
||||
)
|
||||
.catch(error=>Observable.throw(error));
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
<clr-dg-cell>{{t.architecture}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{t.os}}
|
||||
<harbor-action-overflow>
|
||||
<a href="javascript:void(0)" class="dropdown-item" (click)="deleteTag(t.tag)">{{'REPOSITORY.DELETE' | translate}}</a>
|
||||
<a href="javascript:void(0)" class="dropdown-item" (click)="deleteTag(t)">{{'REPOSITORY.DELETE' | translate}}</a>
|
||||
</harbor-action-overflow>
|
||||
</clr-dg-cell>
|
||||
</clr-dg-row>
|
||||
|
@ -32,16 +32,24 @@ export class TagRepositoryComponent implements OnInit, OnDestroy {
|
||||
private repositoryService: RepositoryService) {
|
||||
this.subscription = this.deletionDialogService.deletionConfirm$.subscribe(
|
||||
message=>{
|
||||
let tagName = message.data;
|
||||
this.repositoryService
|
||||
.deleteRepoByTag(this.repoName, tagName)
|
||||
.subscribe(
|
||||
response=>{
|
||||
this.retrieve();
|
||||
console.log('Deleted repo:' + this.repoName + ' with tag:' + tagName);
|
||||
},
|
||||
error=>this.messageService.announceMessage(error.status, 'Failed to delete tag:' + tagName + ' under repo:' + this.repoName, AlertType.DANGER)
|
||||
);
|
||||
let tag = message.data;
|
||||
if(tag) {
|
||||
if(tag.verified) {
|
||||
return;
|
||||
} else {
|
||||
let tagName = tag.tag;
|
||||
this.repositoryService
|
||||
.deleteRepoByTag(this.repoName, tagName)
|
||||
.subscribe(
|
||||
response=>{
|
||||
this.retrieve();
|
||||
console.log('Deleted repo:' + this.repoName + ' with tag:' + tagName);
|
||||
},
|
||||
error=>this.messageService.announceMessage(error.status, 'Failed to delete tag:' + tagName + ' under repo:' + this.repoName, AlertType.DANGER)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -58,8 +66,9 @@ export class TagRepositoryComponent implements OnInit, OnDestroy {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
retrieve() {
|
||||
this.tags = [];
|
||||
this.repositoryService
|
||||
.listTagsWithVerifiedSignatures(this.repoName)
|
||||
.subscribe(
|
||||
@ -81,11 +90,19 @@ export class TagRepositoryComponent implements OnInit, OnDestroy {
|
||||
error=>this.messageService.announceMessage(error.status, 'Failed to list tags with repo:' + this.repoName, AlertType.DANGER));
|
||||
}
|
||||
|
||||
deleteTag(tagName: string) {
|
||||
let message = new DeletionMessage(
|
||||
'REPOSITORY.DELETION_TITLE_TAG', 'REPOSITORY.DELETION_SUMMARY_TAG',
|
||||
tagName, tagName, DeletionTargets.TAG);
|
||||
this.deletionDialogService.openComfirmDialog(message);
|
||||
deleteTag(tag: TagView) {
|
||||
if(tag) {
|
||||
let titleKey: string, summaryKey: string;
|
||||
if (tag.verified) {
|
||||
titleKey = 'REPOSITORY.DELETION_TITLE_TAG_DENIED';
|
||||
summaryKey = 'REPOSITORY.DELETION_SUMMARY_TAG_DENIED';
|
||||
} else {
|
||||
titleKey = 'REPOSITORY.DELETION_TITLE_TAG';
|
||||
summaryKey = 'REPOSITORY.DELETION_SUMMARY_TAG';
|
||||
}
|
||||
let message = new DeletionMessage(titleKey, summaryKey, tag.tag, tag, DeletionTargets.TAG);
|
||||
this.deletionDialogService.openComfirmDialog(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -256,6 +256,8 @@
|
||||
"DELETION_SUMMARY_REPO": "Do you want to delete repository {{param}}?",
|
||||
"DELETION_TITLE_TAG": "Confirm Tag Deletion",
|
||||
"DELETION_SUMMARY_TAG": "Do you want to delete tag {{param}}?",
|
||||
"DELETION_TITLE_TAG_DENIED": "Signed Tag can't be deleted",
|
||||
"DELETION_SUMMARY_TAG_DENIED": "The tag must be removed from Notary before they can be deleted.",
|
||||
"FILTER_FOR_REPOSITORIES": "Filter for repositories",
|
||||
"TAG": "Tag",
|
||||
"VERIFIED": "Verified",
|
||||
|
@ -256,6 +256,8 @@
|
||||
"DELETION_SUMMARY_REPO": "确认删除镜像仓库 {{param}}?",
|
||||
"DELETION_TITLE_TAG": "删除镜像标签确认",
|
||||
"DELETION_SUMMARY_TAG": "确认删除镜像标签 {{param}}?",
|
||||
"DELETION_TITLE_TAG_DENIED": "已签名的镜像不能被删除",
|
||||
"DELETION_SUMMARY_TAG_DENIED": "要删除此镜像标签必须首先从Notary中删除。",
|
||||
"FILTER_FOR_REPOSITORIES": "过滤镜像仓库",
|
||||
"TAG": "标签",
|
||||
"VERIFIED": "已验证",
|
||||
|
Loading…
Reference in New Issue
Block a user