mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-10 01:48:07 +01:00
Add restriction for repositories and tags.
This commit is contained in:
parent
01d9930b5a
commit
801a83ffd5
@ -3,7 +3,7 @@
|
|||||||
<clr-dg-column>{{'REPOSITORY.TAGS_COUNT' | translate}}</clr-dg-column>
|
<clr-dg-column>{{'REPOSITORY.TAGS_COUNT' | translate}}</clr-dg-column>
|
||||||
<clr-dg-column>{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
|
<clr-dg-column>{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
|
||||||
<clr-dg-row *ngFor="let r of repositories" [clrDgItem]='r'>
|
<clr-dg-row *ngFor="let r of repositories" [clrDgItem]='r'>
|
||||||
<clr-dg-action-overflow *ngIf="listFullMode">
|
<clr-dg-action-overflow *ngIf="listFullMode && hasProjectAdminRole">
|
||||||
<button class="action-item">{{'REPOSITORY.COPY_ID' | translate}}</button>
|
<button class="action-item">{{'REPOSITORY.COPY_ID' | translate}}</button>
|
||||||
<button class="action-item">{{'REPOSITORY.COPY_PARENT_ID' | translate}}</button>
|
<button class="action-item">{{'REPOSITORY.COPY_PARENT_ID' | translate}}</button>
|
||||||
<button class="action-item" (click)="deleteRepo(r.name)">{{'REPOSITORY.DELETE' | translate}}</button>
|
<button class="action-item" (click)="deleteRepo(r.name)">{{'REPOSITORY.DELETE' | translate}}</button>
|
||||||
|
@ -7,6 +7,9 @@ import { SearchTriggerService } from '../../base/global-search/search-trigger.se
|
|||||||
import { SessionService } from '../../shared/session.service';
|
import { SessionService } from '../../shared/session.service';
|
||||||
import { ListMode } from '../../shared/shared.const';
|
import { ListMode } from '../../shared/shared.const';
|
||||||
|
|
||||||
|
import { SessionUser } from '../../shared/session-user';
|
||||||
|
import { Member } from '../../project/member/member';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'list-repository',
|
selector: 'list-repository',
|
||||||
templateUrl: 'list-repository.component.html'
|
templateUrl: 'list-repository.component.html'
|
||||||
@ -25,10 +28,22 @@ export class ListRepositoryComponent {
|
|||||||
|
|
||||||
pageOffset: number = 1;
|
pageOffset: number = 1;
|
||||||
|
|
||||||
|
hasProjectAdminRole: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private searchTrigger: SearchTriggerService,
|
private searchTrigger: SearchTriggerService,
|
||||||
private session: SessionService) { }
|
private session: SessionService) {
|
||||||
|
//Get current user from registered resolver.
|
||||||
|
let currentUser = session.getCurrentUser();
|
||||||
|
let projectMembers: Member[] = session.getProjectMembers();
|
||||||
|
if(currentUser && projectMembers) {
|
||||||
|
let currentMember = projectMembers.find(m=>m.user_id === currentUser.user_id);
|
||||||
|
if(currentMember) {
|
||||||
|
this.hasProjectAdminRole = (currentMember.role_name === 'projectAdmin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deleteRepo(repoName: string) {
|
deleteRepo(repoName: string) {
|
||||||
this.delete.emit(repoName);
|
this.delete.emit(repoName);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<clr-dg-column>{{'REPOSITORY.ARCHITECTURE' | translate}}</clr-dg-column>
|
<clr-dg-column>{{'REPOSITORY.ARCHITECTURE' | translate}}</clr-dg-column>
|
||||||
<clr-dg-column>{{'REPOSITORY.OS' | translate}}</clr-dg-column>
|
<clr-dg-column>{{'REPOSITORY.OS' | translate}}</clr-dg-column>
|
||||||
<clr-dg-row *ngFor="let t of tags" [clrDgItem]='t'>
|
<clr-dg-row *ngFor="let t of tags" [clrDgItem]='t'>
|
||||||
<clr-dg-action-overflow>
|
<clr-dg-action-overflow *ngIf="hasProjectAdminRole">
|
||||||
<button class="action-item" (click)="deleteTag(t)">{{'REPOSITORY.DELETE' | translate}}</button>
|
<button class="action-item" (click)="deleteTag(t)">{{'REPOSITORY.DELETE' | translate}}</button>
|
||||||
</clr-dg-action-overflow>
|
</clr-dg-action-overflow>
|
||||||
<clr-dg-cell>{{t.tag}}</clr-dg-cell>
|
<clr-dg-cell>{{t.tag}}</clr-dg-cell>
|
||||||
|
@ -15,6 +15,9 @@ import { TagView } from '../tag-view';
|
|||||||
|
|
||||||
import { AppConfigService } from '../../app-config.service';
|
import { AppConfigService } from '../../app-config.service';
|
||||||
|
|
||||||
|
import { SessionService } from '../../shared/session.service';
|
||||||
|
import { Member } from '../../project/member/member';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
selector: 'tag-repository',
|
selector: 'tag-repository',
|
||||||
@ -26,6 +29,8 @@ export class TagRepositoryComponent implements OnInit, OnDestroy {
|
|||||||
projectId: number;
|
projectId: number;
|
||||||
repoName: string;
|
repoName: string;
|
||||||
|
|
||||||
|
hasProjectAdminRole: boolean;
|
||||||
|
|
||||||
tags: TagView[];
|
tags: TagView[];
|
||||||
registryUrl: string;
|
registryUrl: string;
|
||||||
withNotary: boolean;
|
withNotary: boolean;
|
||||||
@ -37,7 +42,18 @@ export class TagRepositoryComponent implements OnInit, OnDestroy {
|
|||||||
private messageService: MessageService,
|
private messageService: MessageService,
|
||||||
private deletionDialogService: ConfirmationDialogService,
|
private deletionDialogService: ConfirmationDialogService,
|
||||||
private repositoryService: RepositoryService,
|
private repositoryService: RepositoryService,
|
||||||
private appConfigService: AppConfigService) {
|
private appConfigService: AppConfigService,
|
||||||
|
private session: SessionService){
|
||||||
|
|
||||||
|
let currentUser = session.getCurrentUser();
|
||||||
|
let projectMembers: Member[] = session.getProjectMembers();
|
||||||
|
if(currentUser && projectMembers) {
|
||||||
|
let currentMember = projectMembers.find(m=>m.user_id === currentUser.user_id);
|
||||||
|
if(currentMember) {
|
||||||
|
this.hasProjectAdminRole = (currentMember.role_name === 'projectAdmin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.subscription = this.deletionDialogService.confirmationConfirm$.subscribe(
|
this.subscription = this.deletionDialogService.confirmationConfirm$.subscribe(
|
||||||
message => {
|
message => {
|
||||||
if (message &&
|
if (message &&
|
||||||
|
Loading…
Reference in New Issue
Block a user