Commit 8bf77d01 authored by AllForNothing's avatar AllForNothing
Browse files

Fix bugs with label 'target 2.0.1'


Signed-off-by: default avatarAllForNothing <sshijun@vmware.com>
parent f5d48285
......@@ -20,8 +20,7 @@ export class ScannerMetadataComponent implements OnInit {
loading: boolean = false;
scannerMetadata: ScannerMetadata;
constructor(private configScannerService: ConfigScannerService,
private errorHandler: ErrorHandler,
private translate: TranslateService) {
private errorHandler: ErrorHandler) {
}
ngOnInit(): void {
this.loading = true;
......@@ -35,7 +34,7 @@ export class ScannerMetadataComponent implements OnInit {
}
parseDate(item: any): string {
if (this.hasValue(item) && this.hasDateValue(item)) {
return new DatePipe(this.translate.currentLang).transform(item.value, 'short');
return new DatePipe('en-us').transform(item.value, 'short');
}
if (this.hasValue(item)) {
return item.value;
......
......@@ -8,4 +8,4 @@
</div>
</clr-alert>
</div>
<div *ngIf="globalMessageOpened" class="mask-layer"></div>
\ No newline at end of file
<div *ngIf="globalMessageOpened && needAuth" class="mask-layer"></div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Component, Input, OnInit, OnDestroy, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import { Subscription } from "rxjs";
import { ElementRef } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ClarityModule } from "@clr/angular";
import { ClarityModule } from '@clr/angular';
import { Message } from './message';
import { MessageService } from './message.service';
import { MessageComponent } from './message.component';
import { AlertType } from '../shared/shared.const';
describe('MessageComponent', () => {
let component: MessageComponent;
......@@ -39,4 +38,22 @@ describe('MessageComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
it('should open mask layer when unauthorized', async () => {
component.globalMessageOpened = true;
component.globalMessage = Message.newMessage(401, "unauthorized", AlertType.DANGER);
fixture.detectChanges();
await fixture.whenStable();
const ele: HTMLDivElement = fixture.nativeElement.querySelector(".mask-layer");
expect(ele).toBeTruthy();
});
it("should not open mask layer when it's not unauthorized", async () => {
component.globalMessageOpened = true;
component.globalMessage = Message.newMessage(403, "forbidden", AlertType.WARNING);
fixture.detectChanges();
await fixture.whenStable();
const ele: HTMLDivElement = fixture.nativeElement.querySelector(".mask-layer");
expect(ele).toBeFalsy();
});
});
......@@ -320,7 +320,12 @@ const harborRoutes: Routes = [
}
},
component: ScannerComponent
}
},
{
path: '',
redirectTo: 'repositories',
pathMatch: 'full'
},
]
},
{
......
......@@ -2,10 +2,10 @@
<div class="breadcrumb">
<a (click)="gotoProjectList()"> {{ 'SIDE_NAV.PROJECTS'| translate}} </a>
&lt;
<a (click)="gotoChartList()">{{ 'HELM_CHART.HELMCHARTS'| translate}}</a>
<a (click)="gotoChartList()">{{ projectName }}</a>
&lt;
<a (click)="gotoChartVersion()">{{ 'HELM_CHART.CHARTVERSIONS'| translate}}</a>
</div>
<hbr-chart-detail [projectId]="projectId" [project]="project" [chartName]="chartName" [chartVersion]="chartVersion"
[roleName]="roleName"></hbr-chart-detail>
</div>
\ No newline at end of file
</div>
......@@ -13,6 +13,7 @@ export class HelmChartDetailComponent implements OnInit {
projectId: number | string;
project: Project;
projectName: string;
chartName: string;
chartVersion: string;
currentUser: SessionUser;
......@@ -36,6 +37,7 @@ export class HelmChartDetailComponent implements OnInit {
if (resolverData) {
this.project = <Project>(resolverData["projectResolver"]);
this.roleName = this.project.role_name;
this.projectName = this.project.name;
this.hasProjectAdminRole = this.project.has_project_admin_role;
}
}
......
......@@ -8,7 +8,7 @@
<div *ngIf="readme" class="md-div" [innerHTML]="readme | markdown"></div>
<div *ngIf="!readme">{{'HELM_CHART.NO_README' | translate}}</div>
</div>
<div class="col-md-4 summary-container">
<div class="col-md-4 summary-container mt-1">
<div class="col-md-12 content-group">
<div>
<label>{{'HELM_CHART.OVERVIEW' | translate }}</label>
......@@ -55,7 +55,7 @@
<tr>
<td class="left cmd-title">{{'HELM_CHART.ADD_REPO' | translate }}</td>
<td class="left cmd-content">
<input class="cmd-content" type="text" [(ngModel)]="addCMD" #addCMDInput readonly />
<input class="cmd-content clr-input" type="text" [(ngModel)]="addCMD" #addCMDInput readonly />
</td>
<td class="left">
<span>
......@@ -67,7 +67,7 @@
<tr>
<td class="left cmd-title">{{'HELM_CHART.INSTALL_CHART' | translate }}</td>
<td class="left">
<input class="cmd-content" type="text" [(ngModel)]="installCMD" #installCMDInput readonly />
<input class="cmd-content clr-input" type="text" [(ngModel)]="installCMD" #installCMDInput readonly />
</td>
<td class="left">
<span>
......@@ -79,7 +79,7 @@
<tr *ngIf="prov_ready">
<td class="left cmd-title">{{'HELM_CHART.VERIFY_CHART' | translate }}</td>
<td class="left">
<input class="cmd-content" type="text" [(ngModel)]="verifyCMD" #verifyCMDInput readonly />
<input class="cmd-content clr-input" type="text" [(ngModel)]="verifyCMD" #verifyCMDInput readonly />
</td>
<td class="left">
<span>
......
......@@ -2,12 +2,11 @@
margin-top: 20px;
padding: 0 0 0 15px;
.md-container {
border: solid 1px #ddd;
border: solid 1px;
}
.summary-container {
padding: 0;
table {
background-color: #f2f2f2;
margin-top: 0.5rem;
}
.content-group {
......@@ -36,45 +35,3 @@
}
}
}
%code-block {
background: #ddd;
border-radius: 2px;
padding: 2px 4px;
}
.md-div {
::ng-deep {
code:not([class*="language-"]) {
@extend %code-block;
color: #657b83;
}
pre:not([class*="language-"]) {
background: #fdf6e3;
code:not([class*="language-"]) {
@extend %code-block;
background: transparent;
}
}
table {
display: block;
width: 100%;
overflow: auto;
padding: 0;
border-spacing: 0;
border-collapse: collapse;
margin-bottom: 16px;
td,
th {
padding: 6px 13px;
border: 1px solid #ddd;
@include align-text-mixin(left, right, center);
}
tr {
&:nth-child(2n) {
background-color: #f2f2f2;
}
}
}
}
}
......@@ -2,7 +2,7 @@
<div class="breadcrumb">
<a href="javascript:void(0)" (click)="gotoProjectList()"> {{ 'SIDE_NAV.PROJECTS'| translate}} </a>
&lt;
<a href="javascript:void(0)" (click)="gotoChartList()">{{ 'HELM_CHART.HELMCHARTS'| translate}}</a>
<a href="javascript:void(0)" (click)="gotoChartList()">{{ projectName }}</a>
</div>
<hbr-helm-chart-version
[projectId]='projectId'
......@@ -13,4 +13,4 @@
(versionClickEvt)='onVersionClick($event)'
(backEvt)='gotoChartList()'>
</hbr-helm-chart-version>
</div>
\ No newline at end of file
</div>
......@@ -96,11 +96,7 @@ export class ListProjectComponent implements OnDestroy {
}
get withChartMuseum(): boolean {
if (this.appConfigService.getConfig().with_chartmuseum) {
return true;
} else {
return false;
}
return this.appConfigService.getConfig().with_chartmuseum;
}
public get isSystemAdmin(): boolean {
......@@ -129,7 +125,7 @@ export class ListProjectComponent implements OnDestroy {
goToLink(proId: number): void {
this.searchTrigger.closeSearch(true);
let linkUrl = ["harbor", "projects", proId, "summary"];
let linkUrl = ["harbor", "projects", proId];
this.router.navigate(linkUrl);
}
......
......@@ -2,7 +2,7 @@
<div class="breadcrumb" *ngIf="!withAdmiral">
<a (click)="goProBack()">{{'SIDE_NAV.PROJECTS'| translate}}</a>
<span class="back-icon"><</span>
<a (click)="watchGoBackEvt(projectId)">{{'REPOSITORY.REPOSITORIES'| translate}}</a>
<a (click)="watchGoBackEvt(projectId)">{{projectName}}</a>
<span *ngIf="depth">&lt;<a (click)="backInitRepo()">{{repoName}}</a></span>
<span *ngIf="referArtifactNameArray?.length>=1" >
<span *ngFor="let digest of referArtifactNameArray;let i = index">
......
......@@ -28,6 +28,7 @@ import { Project } from "../../project";
export class ArtifactListPageComponent implements OnInit {
projectId: number;
projectName: string;
projectMemberRoleId: number;
repoName: string;
referArtifactNameArray: string[] = [];
......@@ -60,6 +61,7 @@ export class ArtifactListPageComponent implements OnInit {
}
let resolverData = this.route.snapshot.data;
if (resolverData) {
this.projectName = (<Project>resolverData['projectResolver']).name;
this.hasProjectAdminRole = (<Project>resolverData['projectResolver']).has_project_admin_role;
this.isGuest = (<Project>resolverData['projectResolver']).current_user_role_id === 3;
this.projectMemberRoleId = (<Project>resolverData['projectResolver']).current_user_role_id;
......
......@@ -264,7 +264,7 @@
<span *ngIf="!hasVul(artifact)">
{{'ARTIFACT.SCAN_UNSUPPORTED' | translate}}
</span>
<hbr-vulnerability-bar *ngIf="hasVul(artifact)" [scanner]="handleScanOverview(artifact.scan_overview)?.scanner"
<hbr-vulnerability-bar (scanFinished)="scanFinished($event)" *ngIf="hasVul(artifact)" [scanner]="handleScanOverview(artifact.scan_overview)?.scanner"
(submitFinish)="submitFinish($event)" [projectName]="projectName" [repoName]="repoName"
[artifactDigest]="artifact.digest" [summary]="handleScanOverview(artifact.scan_overview)">
</hbr-vulnerability-bar>
......
......@@ -981,4 +981,15 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
get isFilterReadonly() {
return this.filterByType === 'labels' ? 'readonly' : null;
}
// when finished, remove it from selectedRow
scanFinished(artifact: Artifact) {
if (this.selectedRow && this.selectedRow.length) {
for ( let i = 0; i < this.selectedRow.length; i++) {
if (artifact.digest === this.selectedRow[i].digest) {
this.selectedRow.splice(i, 1);
break;
}
}
}
}
}
......@@ -10,10 +10,10 @@
<clr-datagrid [clrDgLoading]="loading">
<clr-dg-action-bar>
<div class="clr-row center">
<div class="clr-col-1">
<div class="ml-05">
<button (click)="scanNow()" type="button" class="btn btn-secondary" [clrLoading]="scanBtnState" [disabled]="!(hasEnabledScanner && hasScanningPermission && !onSendingScanCommand)"><clr-icon shape="shield-check" size="16"></clr-icon>&nbsp;{{'VULNERABILITY.SCAN_NOW' | translate}}</button>
</div>
<div class="clr-col">
<div class="ml-1">
<div [hidden]="!shouldShowBar()">
<hbr-vulnerability-bar [summary]="handleScanOverview(artifact?.scan_overview)" [scanner]="scanner"
(submitFinish)="submitFinish($event)" [projectName]="projectName" [repoName]="repoName"
......
......@@ -45,4 +45,7 @@
}
.no-border {
border: none;
}
\ No newline at end of file
}
.ml-05 {
margin-left: 0.5rem;
}
......@@ -24,7 +24,7 @@ export class ArtifactCommonPropertiesComponent implements OnInit, OnChanges {
@Input() artifactDetails: Artifact;
commonProperties: { [key: string]: any } = {};
constructor(private translate: TranslateService) {
constructor() {
}
ngOnInit() {
......@@ -44,7 +44,7 @@ export class ArtifactCommonPropertiesComponent implements OnInit, OnChanges {
}
}
if (name === Types.CREATED) {
this.commonProperties[name] = new DatePipe(this.translate.currentLang)
this.commonProperties[name] = new DatePipe('en-us')
.transform(this.commonProperties[name], 'short');
}
}
......
<div class="arrow-block" *ngIf="!withAdmiral">
<a class="pl-0" (click)="goBackPro()">{{'SIDE_NAV.PROJECTS'| translate}}</a>
<span class="back-icon"><</span>
<a (click)="goBackRep()">{{'REPOSITORY.REPOSITORIES'| translate}}</a>
<a (click)="goBackRep()">{{projectName}}</a>
<span class="back-icon"><</span>
<a (click)="goBack()">{{repositoryName}}</a>
......
......@@ -30,12 +30,14 @@
<clr-dg-column [clrDgField]="'name'">{{'REPOSITORY.NAME' | translate}}</clr-dg-column>
<clr-dg-column>{{'REPOSITORY.ARTIFACTS_COUNT' | translate}}</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'pull_count'">{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'update_time'">{{'REPOSITORY.LAST_MODIFIED' | translate}}</clr-dg-column>
<clr-dg-placeholder>{{'REPOSITORY.PLACEHOLDER' | translate }}</clr-dg-placeholder>
<clr-dg-row *ngFor="let r of repositories" [clrDgItem]="r">
<clr-dg-cell><a href="javascript:void(0)" (click)="goIntoRepo(r)"><span *ngIf="withAdmiral" class="list-img"><img [src]="getImgLink(r)"/></span>{{r.name}}</a></clr-dg-cell>
<!-- to do -->
<clr-dg-cell>{{r.artifact_count}}</clr-dg-cell>
<clr-dg-cell>{{r.pull_count}}</clr-dg-cell>
<clr-dg-cell>{{r.update_time | date:'short'}}</clr-dg-cell>
</clr-dg-row>
<clr-dg-footer>
<span *ngIf="totalCount">{{pagination.firstItem + 1}} - {{pagination.lastItem + 1}} {{'REPOSITORY.OF' | translate}}</span>
......@@ -72,12 +74,16 @@
</div>
<div class="form-group">
<label>{{'REPOSITORY.ARTIFACTS_COUNT' | translate}}</label>
<div>{{item.tags_count}}</div>
<div>{{item.artifact_count}}</div>
</div>
<div class="form-group">
<label>{{'REPOSITORY.PULL_COUNT' | translate}}</label>
<div>{{item.pull_count}}</div>
</div>
<div class="form-group">
<label>{{'REPOSITORY.LAST_MODIFIED' | translate}}</label>
<div>{{item.update_time | date: 'short'}}</div>
</div>
</div>
<div class="card-footer">
<clr-dropdown [clrCloseMenuOnItemClick]="false">
......
......@@ -76,7 +76,7 @@
}
.form-group > label {
width: 100px;
width: 142px;
}
.card-media-block > img {
......@@ -131,4 +131,4 @@
.repository-box {
margin-top: 5px;
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment