mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 04:35:16 +01:00
Abstract repo click as a output event
This commit is contained in:
parent
debcf7858a
commit
557c68a57c
@ -93,6 +93,12 @@ On specific project mode, without need projectId, but also need to provide proje
|
|||||||
|
|
||||||
* **Repository and Tag Management View**
|
* **Repository and Tag Management View**
|
||||||
|
|
||||||
|
The `hbr-repository-stackview` directive is deprecated. Using `hbr-repository-listview` and `hbr-repository` instead. You should define two routers one for render
|
||||||
|
`hbr-repository-listview` the other is for `hbr-repository`. `hbr-repository-listview` will output an event, you need catch this event and redirect to related
|
||||||
|
page contains `hbr-repository`.
|
||||||
|
|
||||||
|
**hbr-repository-listview Directive**
|
||||||
|
|
||||||
**projectId** is used to specify which projects the repositories are from.
|
**projectId** is used to specify which projects the repositories are from.
|
||||||
|
|
||||||
**projectName** is used to generate the related commands for pushing images.
|
**projectName** is used to generate the related commands for pushing images.
|
||||||
@ -101,18 +107,52 @@ On specific project mode, without need projectId, but also need to provide proje
|
|||||||
|
|
||||||
**hasProjectAdminRole** is a user session related property to determined whether the current user has project administrator role. Some action menus might be disabled based on this property.
|
**hasProjectAdminRole** is a user session related property to determined whether the current user has project administrator role. Some action menus might be disabled based on this property.
|
||||||
|
|
||||||
**tagClickEvent** is an @output event emitter for you to catch the tag click events.
|
**repoClickEvent** is an @output event emitter for you to catch the repository click events.
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
<hbr-repository-stackview [projectId]="..." [projectName]="" [hasSignedIn]="..." [hasProjectAdminRole]="..." (tagClickEvent)="watchTagClickEvent($event)"></hbr-repository-stackview>
|
<hbr-repository-listview [projectId]="" [projectName]="" [hasSignedIn]="" [hasProjectAdminRole]=""
|
||||||
|
(repoClickEvent)="watchRepoClickEvent($event)"></hbr-repository-listview>
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
watchTagClickEvent(tag: Tag): void {
|
|
||||||
//Process tag
|
watchRepoClickEvent(repo: RepositoryItem): void {
|
||||||
|
//Process repo
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
**hbr-repository Directive**
|
||||||
|
|
||||||
|
**projectId** is used to specify which projects the repositories are from.
|
||||||
|
|
||||||
|
**repoName** is used to generate the related commands for pushing images.
|
||||||
|
|
||||||
|
**hasSignedIn** is a user session related property to determined whether a valid user signed in session existing. This component supports anonymous user.
|
||||||
|
|
||||||
|
**hasProjectAdminRole** is a user session related property to determined whether the current user has project administrator role. Some action menus might be disabled based on this property.
|
||||||
|
|
||||||
|
**withClair** is Clair installed
|
||||||
|
|
||||||
|
**withNotary** is Notary installed
|
||||||
|
|
||||||
|
**tagClickEvent** is an @output event emitter for you to catch the tag click events.
|
||||||
|
|
||||||
|
**goBackClickEvent** is an @output event emitter for you to catch the go back events.
|
||||||
|
|
||||||
|
```
|
||||||
|
<hbr-repository [projectId]="" [repoName]="" [hasSignedIn]="" [hasProjectAdminRole]="" [withClair]="" [withNotary]=""
|
||||||
|
(tagClickEvent)="watchTagClickEvt($event)" (backEvt)="watchGoBackEvt($event)" ></hbr-repository>
|
||||||
|
|
||||||
|
watchTagClickEvt(tagEvt: TagClickEvent): void {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watchGoBackEvt(projectId: string): void {
|
||||||
|
...
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Tag detail view**
|
* **Tag detail view**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "harbor-ui",
|
"name": "harbor-ui",
|
||||||
"version": "0.6.45",
|
"version": "0.6.52",
|
||||||
"description": "Harbor shared UI components based on Clarity and Angular4",
|
"description": "Harbor shared UI components based on Clarity and Angular4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ng serve --host 0.0.0.0 --port 4500 --proxy-config proxy.config.json",
|
"start": "ng serve --host 0.0.0.0 --port 4500 --proxy-config proxy.config.json",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "harbor-ui",
|
"name": "harbor-ui",
|
||||||
"version": "0.6.45",
|
"version": "0.6.52",
|
||||||
"description": "Harbor shared UI components based on Clarity and Angular4",
|
"description": "Harbor shared UI components based on Clarity and Angular4",
|
||||||
"author": "VMware",
|
"author": "VMware",
|
||||||
"module": "index.js",
|
"module": "index.js",
|
||||||
|
@ -20,7 +20,7 @@ export const REPOSITORY_LISTVIEW_TEMPLATE = `
|
|||||||
<clr-dg-column [clrDgSortBy]="pullCountComparator">{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
|
<clr-dg-column [clrDgSortBy]="pullCountComparator">{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
|
||||||
<clr-dg-placeholder>{{'REPOSITORY.PLACEHOLDER' | translate }}</clr-dg-placeholder>
|
<clr-dg-placeholder>{{'REPOSITORY.PLACEHOLDER' | translate }}</clr-dg-placeholder>
|
||||||
<clr-dg-row *ngFor="let r of repositories" [clrDgItem]="r">
|
<clr-dg-row *ngFor="let r of repositories" [clrDgItem]="r">
|
||||||
<clr-dg-cell><a href="javascript:void(0)" (click)="gotoLink(projectId || r.project_id, r.name || r.repository_name)">{{r.name}}</a></clr-dg-cell>
|
<clr-dg-cell><a href="javascript:void(0)" (click)="watchRepoClickEvt(r)">{{r.name}}</a></clr-dg-cell>
|
||||||
<clr-dg-cell>{{r.tags_count}}</clr-dg-cell>
|
<clr-dg-cell>{{r.tags_count}}</clr-dg-cell>
|
||||||
<clr-dg-cell>{{r.pull_count}}</clr-dg-cell>
|
<clr-dg-cell>{{r.pull_count}}</clr-dg-cell>
|
||||||
</clr-dg-row>
|
</clr-dg-row>
|
||||||
|
@ -60,14 +60,14 @@ export class RepositoryListviewComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
@Input() hasSignedIn: boolean;
|
@Input() hasSignedIn: boolean;
|
||||||
@Input() hasProjectAdminRole: boolean;
|
@Input() hasProjectAdminRole: boolean;
|
||||||
@Output() tagClickEvent = new EventEmitter<TagClickEvent>();
|
@Output() repoClickEvent = new EventEmitter<RepositoryItem>();
|
||||||
|
|
||||||
lastFilteredRepoName: string;
|
lastFilteredRepoName: string;
|
||||||
repositories: RepositoryItem[];
|
repositories: RepositoryItem[];
|
||||||
systemInfo: SystemInfo;
|
systemInfo: SystemInfo;
|
||||||
selectedRow: RepositoryItem[] = [];
|
selectedRow: RepositoryItem[] = [];
|
||||||
|
|
||||||
loading: boolean = true;
|
loading = true;
|
||||||
|
|
||||||
@ViewChild('confirmationDialog')
|
@ViewChild('confirmationDialog')
|
||||||
confirmationDialog: ConfirmationDialogComponent;
|
confirmationDialog: ConfirmationDialogComponent;
|
||||||
@ -279,19 +279,15 @@ export class RepositoryListviewComponent implements OnChanges, OnInit {
|
|||||||
this.doSearchRepoNames('');
|
this.doSearchRepoNames('');
|
||||||
}
|
}
|
||||||
|
|
||||||
watchTagClickEvt(tagClickEvt: TagClickEvent): void {
|
|
||||||
this.tagClickEvent.emit(tagClickEvt);
|
|
||||||
}
|
|
||||||
|
|
||||||
clrLoad(state: State): void {
|
clrLoad(state: State): void {
|
||||||
this.selectedRow = [];
|
this.selectedRow = [];
|
||||||
//Keep it for future filtering and sorting
|
// Keep it for future filtering and sorting
|
||||||
this.currentState = state;
|
this.currentState = state;
|
||||||
|
|
||||||
let pageNumber: number = calculatePage(state);
|
let pageNumber: number = calculatePage(state);
|
||||||
if (pageNumber <= 0) { pageNumber = 1; }
|
if (pageNumber <= 0) { pageNumber = 1; }
|
||||||
|
|
||||||
//Pagination
|
// Pagination
|
||||||
let params: RequestQueryParams = new RequestQueryParams();
|
let params: RequestQueryParams = new RequestQueryParams();
|
||||||
params.set("page", '' + pageNumber);
|
params.set("page", '' + pageNumber);
|
||||||
params.set("page_size", '' + this.pageSize);
|
params.set("page_size", '' + this.pageSize);
|
||||||
@ -307,7 +303,7 @@ export class RepositoryListviewComponent implements OnChanges, OnInit {
|
|||||||
this.repositories = repo.data;
|
this.repositories = repo.data;
|
||||||
|
|
||||||
this.signedCon = {};
|
this.signedCon = {};
|
||||||
//Do filtering and sorting
|
// Do filtering and sorting
|
||||||
this.repositories = doFiltering<RepositoryItem>(this.repositories, state);
|
this.repositories = doFiltering<RepositoryItem>(this.repositories, state);
|
||||||
this.repositories = doSorting<RepositoryItem>(this.repositories, state);
|
this.repositories = doSorting<RepositoryItem>(this.repositories, state);
|
||||||
|
|
||||||
@ -318,7 +314,7 @@ export class RepositoryListviewComponent implements OnChanges, OnInit {
|
|||||||
this.errorHandler.error(error);
|
this.errorHandler.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Force refresh view
|
// Force refresh view
|
||||||
let hnd = setInterval(() => this.ref.markForCheck(), 100);
|
let hnd = setInterval(() => this.ref.markForCheck(), 100);
|
||||||
setTimeout(() => clearInterval(hnd), 5000);
|
setTimeout(() => clearInterval(hnd), 5000);
|
||||||
}
|
}
|
||||||
@ -331,7 +327,7 @@ export class RepositoryListviewComponent implements OnChanges, OnInit {
|
|||||||
let targetPageNumber: number = this.currentPage;
|
let targetPageNumber: number = this.currentPage;
|
||||||
|
|
||||||
if (this.currentPage > totalPages) {
|
if (this.currentPage > totalPages) {
|
||||||
targetPageNumber = totalPages;//Should == currentPage -1
|
targetPageNumber = totalPages; // Should == currentPage -1
|
||||||
}
|
}
|
||||||
|
|
||||||
let st: State = this.currentState;
|
let st: State = this.currentState;
|
||||||
@ -344,8 +340,8 @@ export class RepositoryListviewComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
public gotoLink(projectId: number, repoName: string): void {
|
|
||||||
let linkUrl = [this.router.url, repoName];
|
watchRepoClickEvt(repo: RepositoryItem) {
|
||||||
this.router.navigate(linkUrl);
|
this.repoClickEvent.emit(repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
<div style="margin-top: 24px;">
|
<div style="margin-top: 24px;">
|
||||||
<hbr-repository-listview [projectId]="projectId" [projectName]="projectName" [hasSignedIn]="hasSignedIn" [hasProjectAdminRole]="hasProjectAdminRole" (tagClickEvent)="watchTagClickEvent($event)"></hbr-repository-listview>
|
<hbr-repository-listview [projectId]="projectId" [projectName]="projectName" [hasSignedIn]="hasSignedIn" [hasProjectAdminRole]="hasProjectAdminRole"
|
||||||
|
(repoClickEvent)="watchRepoClickEvent($event)"></hbr-repository-listview>
|
||||||
</div>
|
</div>
|
@ -17,7 +17,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { Project } from '../project/project';
|
import { Project } from '../project/project';
|
||||||
import { SessionService } from '../shared/session.service';
|
import { SessionService } from '../shared/session.service';
|
||||||
|
|
||||||
import { TagClickEvent } from 'harbor-ui';
|
import { TagClickEvent, RepositoryItem } from 'harbor-ui';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'repository',
|
selector: 'repository',
|
||||||
@ -47,8 +47,8 @@ export class RepositoryPageComponent implements OnInit {
|
|||||||
this.hasSignedIn = this.session.getCurrentUser() !== null;
|
this.hasSignedIn = this.session.getCurrentUser() !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
watchTagClickEvent(tagEvt: TagClickEvent): void {
|
watchRepoClickEvent(repoEvt: RepositoryItem): void {
|
||||||
let linkUrl = ['harbor', 'projects', tagEvt.project_id, 'repositories', tagEvt.repository_name];
|
let linkUrl = ['harbor', 'projects', repoEvt.project_id, 'repositories', repoEvt.name];
|
||||||
this.router.navigate(linkUrl);
|
this.router.navigate(linkUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<hbr-repository (tagClickEvent)="watchTagClickEvt($event)" (backEvt)="goBack($event)" [repoName]="repoName" [withClair]="withClair" [withNotary]="withNotary" [withAdmiral]="withAdmiral" [hasSignedIn]="hasSignedIn" [hasProjectAdminRole]="hasProjectAdminRole" [isGuest]="isGuest" [projectId]="projectId"></hbr-repository>
|
<hbr-repository [repoName]="repoName"
|
||||||
|
[withClair]="withClair" [withNotary]="withNotary" [withAdmiral]="withAdmiral"
|
||||||
|
[hasSignedIn]="hasSignedIn" [hasProjectAdminRole]="hasProjectAdminRole" [projectId]="projectId" [isGuest]="isGuest"
|
||||||
|
(tagClickEvent)="watchTagClickEvt($event)" (backEvt)="watchGoBackEvt($event)" ></hbr-repository>
|
||||||
</div>
|
</div>
|
@ -84,7 +84,7 @@ export class TagRepositoryComponent implements OnInit {
|
|||||||
this.router.navigate(linkUrl);
|
this.router.navigate(linkUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
goBack(tag: string): void {
|
watchGoBackEvt(projectId: string): void {
|
||||||
this.router.navigate(["harbor", "projects", this.projectId, "repositories"]);
|
this.router.navigate(["harbor", "projects", projectId, "repositories"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user