Merge pull request #12532 from AllForNothing/proxy-sum

Get registrry from project summary api
This commit is contained in:
Will Sun 2020-07-22 11:01:39 +08:00 committed by GitHub
commit 46fa64462a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 28 deletions

View File

@ -1,9 +1,9 @@
<div class="summary summary-dark display-flex" *ngIf="summaryInformation">
<div class="summary-left">
<div class="display-flex project-detail pt-05" *ngIf="isSystemAdmin && endpoint">
<div class="display-flex project-detail pt-05" *ngIf="summaryInformation?.registry">
<h5 class="mt-0 width-7-5">{{'PROJECT.PROXY_CACHE_ENDPOINT' | translate}}</h5>
<ul class="list-unstyled">
<li id="endpoint">{{endpoint?.name}}-{{endpoint?.url}}</li>
<li id="endpoint">{{summaryInformation?.registry?.name}}-{{summaryInformation?.registry?.url}}</li>
</ul>
</div>
<div class="display-flex project-detail pt-05">

View File

@ -60,7 +60,11 @@ describe('SummaryComponent', () => {
chart_count: 0,
project_admin_count: 1,
maintainer_count: 0,
developer_count: 0
developer_count: 0,
registry: {
name: "test",
url: "https://test.com"
}
};
beforeEach(async(() => {

View File

@ -34,20 +34,10 @@ export class SummaryComponent implements OnInit {
private errorHandler: ErrorHandler,
private appConfigService: AppConfigService,
private route: ActivatedRoute,
private session: SessionService,
private endpointService: EndpointService
) { }
ngOnInit() {
this.projectId = this.route.snapshot.parent.params['id'];
const resolverData = this.route.snapshot.parent.data;
if (resolverData) {
const pro: Project = <Project>resolverData['projectResolver'];
if (pro && pro.registry_id && this.isSystemAdmin) {
this.getRegistry(pro.registry_id);
}
}
const permissions = [
{resource: USERSTATICPERMISSION.MEMBER.KEY, action: USERSTATICPERMISSION.MEMBER.VALUE.LIST},
{resource: USERSTATICPERMISSION.QUOTA.KEY, action: USERSTATICPERMISSION.QUOTA.VALUE.READ},
@ -64,15 +54,6 @@ export class SummaryComponent implements OnInit {
this.errorHandler.error(error);
});
}
getRegistry(registryId: number) {
this.endpointService.getEndpoint(registryId).subscribe(res => {
this.endpoint = res;
}, error => {
this.errorHandler.error(error);
});
}
getSuitableUnit(value) {
const QuotaUnitsCopy = clone(QuotaUnits);
return getSuitableUnitFn(value, QuotaUnitsCopy);
@ -85,10 +66,4 @@ export class SummaryComponent implements OnInit {
public get withHelmChart(): boolean {
return this.appConfigService.getConfig().with_chartmuseum;
}
public get isSystemAdmin(): boolean {
const account = this.session.getCurrentUser();
return account && account.has_admin_role;
}
}