Merge pull request #11648 from jwangyangls/add-sign-pop-when-delete

[feat] Add pop up command when delete signed tag
This commit is contained in:
jwangyangls 2020-04-17 13:14:19 +08:00 committed by GitHub
commit 981cae9f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import { ErrorHandler } from "../../../../../lib/utils/error-handler";
import { ArtifactService } from '../../../../../../ng-swagger-gen/services/artifact.service';
import { OperationService } from "../../../../../lib/components/operation/operation.service";
import { CURRENT_BASE_HREF } from "../../../../../lib/utils/utils";
import { USERSTATICPERMISSION, UserPermissionService, UserPermissionDefaultService } from '../../../../../lib/services';
import { USERSTATICPERMISSION, UserPermissionService, UserPermissionDefaultService, SystemInfoService } from '../../../../../lib/services';
import { delay } from 'rxjs/operators';
import { AppConfigService } from "../../../../services/app-config.service";
@ -29,6 +29,9 @@ describe('ArtifactTagComponent', () => {
const config: IServiceConfig = {
repositoryBaseEndpoint: CURRENT_BASE_HREF + "/repositories/testing"
};
const mockSystemInfoService = {
getSystemInfo: () => of( false )
};
const mockAppConfigService = {
getConfig: () => {
return {
@ -64,6 +67,7 @@ describe('ArtifactTagComponent', () => {
{ provide: mockErrorHandler, useValue: ErrorHandler },
{ provide: ArtifactService, useValue: mockArtifactService },
{ provide: AppConfigService, useValue: mockAppConfigService },
{ provide: SystemInfoService, useValue: mockSystemInfoService },
{ provide: UserPermissionService, useClass: UserPermissionDefaultService },
{ provide: OperationService },
]

View File

@ -18,7 +18,7 @@ import { ArtifactFront as Artifact } from "../artifact";
import { ArtifactService } from '../../../../../../ng-swagger-gen/services/artifact.service';
import { Tag } from '../../../../../../ng-swagger-gen/models/tag';
import {
UserPermissionService, USERSTATICPERMISSION
UserPermissionService, USERSTATICPERMISSION, SystemInfoService, SystemInfo
} from "../../../../../lib/services";
import { ClrDatagridStateInterface } from '@clr/angular';
import {
@ -33,12 +33,13 @@ import { AppConfigService } from "../../../../services/app-config.service";
class InitTag {
name = "";
}
const DeleteTagWithNotoryCommand1 = 'notary -s https://';
const DeleteTagWithNotoryCommand2 = ':4443 -d ~/.docker/trust remove -p ';
@Component({
selector: 'artifact-tag',
templateUrl: './artifact-tag.component.html',
styleUrls: ['./artifact-tag.component.scss']
})
export class ArtifactTagComponent implements OnInit, OnDestroy {
@Input() artifactDetails: Artifact;
@Input() projectName: string;
@ -66,11 +67,13 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
tagNameChecker: Subject<string> = new Subject<string>();
tagNameCheckSub: Subscription;
tagNameCheckOnGoing = false;
systemInfo: SystemInfo;
constructor(
private operationService: OperationService,
private artifactService: ArtifactService,
private translateService: TranslateService,
private userPermissionService: UserPermissionService,
private systemInfoService: SystemInfoService,
private appConfigService: AppConfigService,
private errorHandlerService: ErrorHandler
@ -78,6 +81,8 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
ngOnInit() {
this.getImagePermissionRule(this.projectId);
this.invalidCreateTag();
this.systemInfoService.getSystemInfo()
.subscribe(systemInfo => this.systemInfo = systemInfo, error => this.errorHandlerService.error(error));
}
checkTagName(name) {
let listArtifactParams: ArtifactService.ListArtifactsParams = {
@ -258,6 +263,18 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
operMessage.state = OperationState.progressing;
operMessage.data.name = tag.name;
this.operationService.publishInfo(operMessage);
if (tag.signature) {
forkJoin(this.translateService.get("BATCH.DELETED_FAILURE"),
this.translateService.get("REPOSITORY.DELETION_SUMMARY_TAG_DENIED")).subscribe(res => {
let wrongInfo: string = res[1] + DeleteTagWithNotoryCommand1 + this.registryUrl +
DeleteTagWithNotoryCommand2 +
this.registryUrl + "/" + this.repositoryName +
" " + name;
operateChanges(operMessage, OperationState.failure, wrongInfo);
});
return of(null);
} else {
const deleteTagParams: ArtifactService.DeleteTagParams = {
projectName: this.projectName,
repositoryName: dbEncodeURIComponent(this.repositoryName),
@ -278,6 +295,7 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
);
return of(error);
}));
}
}
existValid(name) {
@ -306,4 +324,7 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
get withNotary(): boolean {
return this.appConfigService.getConfig().with_notary;
}
public get registryUrl(): string {
return this.systemInfo ? this.systemInfo.registry_url : '';
}
}