Skip to content

Commit

Permalink
Merge pull request goharbor#9663 from AllForNothing/nav-modify
Browse files Browse the repository at this point in the history
Modify harbor-shell UI
  • Loading branch information
AllForNothing authored Nov 1, 2019
2 parents 02dab35 + b4fa143 commit 1c8105e
Show file tree
Hide file tree
Showing 34 changed files with 380 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<clr-control-helper class="config-subtext"> {{ 'PROJECT_CONFIG.CONTENT_TRUST_POLCIY' | translate }}
</clr-control-helper>
</clr-checkbox-container>
<clr-checkbox-container id="prevent-vulenrability-image" *ngIf="withNotary">
<label><span *ngIf="!withNotary">{{ 'PROJECT_CONFIG.SECURITY' | translate }}</span></label>
<clr-checkbox-container id="prevent-vulenrability-image">
<label><span>{{ 'PROJECT_CONFIG.SECURITY' | translate }}</span></label>
<clr-checkbox-wrapper>
<input type="checkbox" clrCheckbox [(ngModel)]="projectPolicy.PreventVulImg"
name="prevent-vulenrability-image-input" [disabled]="!hasChangeConfigRole" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class ProjectPolicyConfigComponent implements OnInit {
projectPolicy = new ProjectPolicy();
hasChangeConfigRole: boolean;
severityOptions = [
{severity: 'critical', severityLevel: 'VULNERABILITY.SEVERITY.CRITICAL'},
{severity: 'high', severityLevel: 'VULNERABILITY.SEVERITY.HIGH'},
{severity: 'medium', severityLevel: 'VULNERABILITY.SEVERITY.MEDIUM'},
{severity: 'low', severityLevel: 'VULNERABILITY.SEVERITY.LOW'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
</span>
</clr-dg-cell>
<clr-dg-cell [ngSwitch]="res.severity">
<span *ngSwitchCase="'Critical'" class="label label-critical">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'High'" class="label label-danger">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Medium'" class="label label-medium">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Low'" class="label label-low">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Negligible'" class="label label-negligible">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Unknown'" class="label label-unknown">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Critical'" class="label label-critical no-border">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'High'" class="label label-danger no-border">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Medium'" class="label label-medium no-border">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Low'" class="label label-low no-border">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Negligible'" class="label label-negligible no-border">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchCase="'Unknown'" class="label label-unknown no-border">{{severityText(res.severity) | translate}}</span>
<span *ngSwitchDefault>{{severityText(res.severity) | translate}}</span>
</clr-dg-cell>
<clr-dg-cell>{{res.package}}</clr-dg-cell>
Expand Down
3 changes: 3 additions & 0 deletions src/portal/lib/src/vulnerability-scanning/scanning.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,6 @@ hr{
.margin-top-m15{
margin-top: -15px;
}
.no-border {
border: none;
}
9 changes: 8 additions & 1 deletion src/portal/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import { VulnerabilityPageComponent } from './vulnerability-page/vulnerability-p
import { GcPageComponent } from './gc-page/gc-page.component';
import { OidcOnboardModule } from './oidc-onboard/oidc-onboard.module';
import { LicenseModule } from './license/license.module';
import { InterrogationServicesComponent } from "./interrogation-services/interrogation-services.component";
import { LabelsComponent } from './labels/labels.component';
import { ProjectQuotasComponent } from './project-quotas/project-quotas.component';

registerLocaleData(zh, 'zh-cn');
registerLocaleData(es, 'es-es');
registerLocaleData(localeFr, 'fr-fr');
Expand All @@ -61,7 +65,10 @@ export function getCurrentLanguage(translateService: TranslateService) {
AppComponent,
ProjectConfigComponent,
VulnerabilityPageComponent,
GcPageComponent
GcPageComponent,
InterrogationServicesComponent,
LabelsComponent,
ProjectQuotasComponent
],
imports: [
BrowserModule,
Expand Down
30 changes: 16 additions & 14 deletions src/portal/src/app/base/harbor-shell/harbor-shell.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,28 @@
<clr-icon shape="cloud-traffic" clrVerticalNavIcon></clr-icon>
{{'SIDE_NAV.SYSTEM_MGMT.REPLICATION' | translate}}
</a>
</clr-vertical-nav-group-children>
</clr-vertical-nav-group>
<clr-vertical-nav-group *ngIf="isSystemAdmin && hasAdminRole" routerLinkActive="active">
<clr-icon shape="event" clrVerticalNavIcon></clr-icon>
{{'SIDE_NAV.TASKS' | translate}}
<a routerLink="#" hidden aria-hidden="true"></a>
<clr-vertical-nav-group-children *clrIfExpanded="true">
<a clrVerticalNavLink routerLink="/harbor/vulnerability"
routerLinkActive="active">
{{'SIDE_NAV.SYSTEM_MGMT.VULNERABILITY' | translate}}
<a *ngIf="!withAdmiral" clrVerticalNavLink routerLink="/harbor/labels" routerLinkActive="active">
<clr-icon shape="tag" clrVerticalNavIcon></clr-icon>
{{'CONFIG.LABEL' | translate }}
</a>
<a clrVerticalNavLink routerLink="/harbor/project-quotas" routerLinkActive="active">
<clr-icon shape="volume" clrVerticalNavIcon></clr-icon>
{{'CONFIG.PROJECT_QUOTAS' | translate }}
</a>
<a clrVerticalNavLink routerLink="/harbor/interrogation-services" routerLinkActive="active">
<clr-icon shape="shield" clrVerticalNavIcon></clr-icon>
{{'SIDE_NAV.SYSTEM_MGMT.INTERROGATION_SERVICES' | translate}}
</a>
<a clrVerticalNavLink *ngIf="hasAdminRole" routerLink="/harbor/gc" routerLinkActive="active">
<clr-icon shape="trash" clrVerticalNavIcon></clr-icon>
{{'SIDE_NAV.SYSTEM_MGMT.GARBAGE_COLLECTION' | translate}}
</a>
<a clrVerticalNavLink routerLinkActive="active" routerLink="/harbor/configs">
<clr-icon shape="cog" clrVerticalNavIcon></clr-icon>
{{'SIDE_NAV.SYSTEM_MGMT.CONFIG' | translate}}
</a>
</clr-vertical-nav-group-children>
</clr-vertical-nav-group>
<a *ngIf="isSystemAdmin" clrVerticalNavLink routerLinkActive="active" routerLink="/harbor/configs">
<clr-icon shape="cog" clrVerticalNavIcon></clr-icon>
{{'SIDE_NAV.SYSTEM_MGMT.CONFIG' | translate}}
</a>
</div>
<div class="vertical-nav-footer">
<a clrVerticalNavLink target="_blank" routerLink="/devcenter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ export class HarborShellComponent implements OnInit, OnDestroy {
return this.session.getCurrentUser() &&
this.session.getCurrentUser().has_admin_role;
}

public get withAdmiral(): boolean {
return this.appConfigService.getConfig().with_admiral;
}
// Open modal dialog
openModal(event: ModalEvent): void {
switch (event.modalName) {
Expand Down
26 changes: 1 addition & 25 deletions src/portal/src/app/config/config.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h2 class="custom-h2 config-title">{{'CONFIG.TITLE' | translate }}</h2>
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span>
<h2 class="custom-h2 config-title">{{'CONFIG.TITLE' | translate }}<span class="spinner spinner-inline ml-1 v-mid" [hidden]="inProgress === false"></span></h2>
<clr-tabs>
<clr-tab>
<button id="config-auth" clrTabLink>{{'CONFIG.AUTH' | translate}}</button>
Expand All @@ -21,29 +20,6 @@ <h2 class="custom-h2 config-title">{{'CONFIG.TITLE' | translate }}</h2>
<system-settings [(systemSettings)]="allConfig" [hasAdminRole]="hasAdminRole" (reloadSystemConfig)="handleAppConfig($event)" (readOnlyChange)="handleReadyOnlyChange($event)" [hasCAFile]="hasCAFile"></system-settings>
</clr-tab-content>
</clr-tab>
<clr-tab *ngIf="!withAdmiral">
<button id="config-label" clrTabLink>{{'CONFIG.LABEL' | translate }}</button>
<ng-template [(clrIfActive)]="labelActive">
<clr-tab-content id="system_label" *ngIf="!withAdmiral">
<hbr-label [scope]="'g'"
[hasCreateLabelPermission]="true"
[hasUpdateLabelPermission]="true"
[hasDeleteLabelPermission]="true"></hbr-label>
</clr-tab-content>
</ng-template>
</clr-tab>
<clr-tab>
<button id="config-quotas" clrTabLink>{{'CONFIG.PROJECT_QUOTAS' | translate }}</button>
<clr-tab-content id="project_quotas" *clrIfActive>
<project-quotas [(allConfig)]="allConfig" (refreshAllconfig)="refreshAllconfig()"></project-quotas>
</clr-tab-content>
</clr-tab>
<clr-tab>
<button id="config-scanners" clrTabLink>{{'SCANNER.SCANNERS' | translate}}</button>
<clr-tab-content id="scanners" *clrIfActive>
<config-scanner></config-scanner>
</clr-tab-content>
</clr-tab>
</clr-tabs>
</div>
</div>
5 changes: 4 additions & 1 deletion src/portal/src/app/config/config.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ clr-icon:hover {
}
.clr-form-control-disabled {
opacity: 1;
}
}
.v-mid {
vertical-align: middle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
{{'SCANNER.NO_SCANNER' | translate}}
</clr-dg-placeholder>
<clr-dg-row *clrDgItems="let scanner of scanners" [clrDgItem]="scanner">
<clr-dg-cell>
<clr-dg-cell class="position-relative">
<span>{{scanner.name}}</span>
<span *ngIf="scanner.is_default" class="label label-info ml-1 label-in-cell">{{'SCANNER.DEFAULT' | translate}}</span>
</clr-dg-cell>
<clr-dg-cell>{{scanner.url}}</clr-dg-cell>
<clr-dg-cell>
<clr-dg-cell class="position-relative">
<span *ngIf="scanner.loadingMetadata;else elseBlockLoading" class="spinner spinner-inline ml-2"></span>
<ng-template #elseBlockLoading>
<span *ngIf="scanner.metadata;else elseBlock" class="label label-success label-in-cell">{{'SCANNER.HEALTHY' | translate}}</span>
Expand Down
5 changes: 2 additions & 3 deletions src/portal/src/app/gc-page/gc-page.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h2 class="custom-h2 gc-title">{{'CONFIG.GC' | translate }}</h2>
<span class="spinner spinner-inline" [hidden]="!inProgress"></span>
<h2 class="custom-h2 gc-title">{{'CONFIG.GC' | translate }}<span class="spinner spinner-inline ml-1 v-mid" [hidden]="!inProgress"></span></h2>
<clr-tabs>
<clr-tab *ngIf="hasAdminRole">
<button id="config-gc" clrTabLink>{{'CONFIG.GC' | translate }}</button>
Expand All @@ -21,4 +20,4 @@ <h2 class="custom-h2 gc-title">{{'CONFIG.GC' | translate }}</h2>
</clr-tab>
</clr-tabs>
</div>
</div>
</div>
5 changes: 4 additions & 1 deletion src/portal/src/app/gc-page/gc-page.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.gc-title {
display: inline-block;
}
}
.v-mid {
vertical-align: middle;
}
38 changes: 37 additions & 1 deletion src/portal/src/app/harbor-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ import { LicenseComponent } from './license/license.component';
import { SummaryComponent } from './project/summary/summary.component';
import { TagRetentionComponent } from './project/tag-retention/tag-retention.component';
import { ImmutableTagComponent } from './project/immutable-tag/immutable-tag.component';
import { USERSTATICPERMISSION } from '@harbor/ui';
import { USERSTATICPERMISSION, VulnerabilityConfigComponent } from '@harbor/ui';
import { ScannerComponent } from "./project/scanner/scanner.component";
import { InterrogationServicesComponent } from "./interrogation-services/interrogation-services.component";
import { ConfigurationScannerComponent } from "./config/scanner/config-scanner.component";
import { LabelsComponent } from "./labels/labels.component";
import { ProjectQuotasComponent } from "./project-quotas/project-quotas.component";


const harborRoutes: Routes = [
{ path: '', redirectTo: 'harbor', pathMatch: 'full' },
Expand Down Expand Up @@ -122,6 +127,37 @@ const harborRoutes: Routes = [
canActivate: [SystemAdminGuard],
canActivateChild: [SystemAdminGuard]
},
{
path: 'interrogation-services',
component: InterrogationServicesComponent,
canActivate: [SystemAdminGuard],
canActivateChild: [SystemAdminGuard],
children: [
{
path: 'scanners',
component: ConfigurationScannerComponent
},
{
path: 'vulnerability',
component: VulnerabilityConfigComponent
},
{
path: '',
redirectTo: 'scanners',
pathMatch: 'full'
},
]
},
{
path: 'labels',
component: LabelsComponent,
canActivate: [SystemAdminGuard],
},
{
path: 'project-quotas',
component: ProjectQuotasComponent,
canActivate: [SystemAdminGuard],
},
{
path: 'replications/:id/:tasks',
component: ReplicationTasksPageComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h2 class="custom-h2" sub-header-title>{{'SIDE_NAV.SYSTEM_MGMT.INTERROGATION_SERVICES' | translate}}</h2>
<nav class="subnav sub-nav-bg-color mt-1">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" routerLink="scanners" routerLinkActive="active">{{'SCANNER.SCANNERS' | translate }}</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="vulnerability" routerLinkActive="active">{{'CONFIG.VULNERABILITY' | translate }}</a>
</li>
</ul>
</nav>
<router-outlet></router-outlet>


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.sub-header-title {
margin-top: 12px;
margin-bottom: 12px;
}

.sub-nav-bg-color {
background-color: #fafafa;
}

.subnav {
.nav {
padding-left: 0;
}
}

.role-label {
color: #CCCCCC;
font-size: 14px;
font-style: italic;
letter-spacing: 0.01em;
}
.backStyle{
color: #007cbb;
font-size: 12px;
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { InterrogationServicesComponent } from './interrogation-services.component';
import { SharedModule } from "../shared/shared.module";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { ClarityModule } from "@clr/angular";
import { TranslateService } from "@ngx-translate/core";
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";

describe('InterrogationServicesComponent', () => {
let component: InterrogationServicesComponent;
let fixture: ComponentFixture<InterrogationServicesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule,
BrowserAnimationsModule,
ClarityModule,
],
declarations: [ InterrogationServicesComponent ],
providers: [TranslateService],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(InterrogationServicesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-interrogation-services',
templateUrl: './interrogation-services.component.html',
styleUrls: ['./interrogation-services.component.scss']
})
export class InterrogationServicesComponent implements OnInit {

constructor(
) {}

ngOnInit() {
}
}
5 changes: 5 additions & 0 deletions src/portal/src/app/labels/labels.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h2 class="custom-h2" sub-header-title>{{'CONFIG.LABEL' | translate }}</h2>
<hbr-label [scope]="'g'"
[hasCreateLabelPermission]="true"
[hasUpdateLabelPermission]="true"
[hasDeleteLabelPermission]="true"></hbr-label>
Loading

0 comments on commit 1c8105e

Please sign in to comment.