Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Hide deployment info card if not space developer
Browse files Browse the repository at this point in the history
- fixes #4322
  • Loading branch information
richard-cox committed Jun 9, 2020
1 parent d1237cc commit 3af3d39
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@
</mat-card-content>
</mat-card>
</app-tile>
<app-tile id="app-build-tab-deployment-info">
<app-tile id="app-build-tab-deployment-info" *ngIf="(deploySource$ | async) as deploySource">
<mat-card>
<mat-card-header>
<mat-card-title>Deployment Info</mat-card-title>
</mat-card-header>
<mat-card-content *ngIf="(deploySource$ | async) as deploySource; else notDeployedFromStratos">
<mat-card-content>
<span [ngSwitch]="deploySource.type">
<app-metadata-item *ngSwitchCase="'giturl'" icon="code" label="Git Url">
<div matTooltip="{{ deploySource.branch + ' ' + (deploySource.commit | slice:0:8)}}"
Expand Down Expand Up @@ -183,9 +183,6 @@
</app-metadata-item>
</span>
</mat-card-content>
<ng-template #notDeployedFromStratos>
<mat-card-content>None</mat-card-content>
</ng-template>
</mat-card>
</app-tile>
</app-tile-group>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Component, Inject, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
import { combineLatest, delay, distinct, filter, first, map, mergeMap, startWith, tap } from 'rxjs/operators';
import { combineLatest as observableCombineLatest, Observable, of as observableOf, of } from 'rxjs';
import { combineLatest, delay, distinct, filter, first, map, mergeMap, startWith, switchMap, tap } from 'rxjs/operators';

import { AppMetadataTypes } from '../../../../../../../../cloud-foundry/src/actions/app-metadata.actions';
import { UpdateExistingApplication } from '../../../../../../../../cloud-foundry/src/actions/application.actions';
import { CFAppState } from '../../../../../../../../cloud-foundry/src/cf-app-state';
import {
CurrentUserPermissionsService,
} from '../../../../../../../../core/src/core/permissions/current-user-permissions.service';
import { getFullEndpointApiUrl } from '../../../../../../../../core/src/features/endpoints/endpoint-helpers';
import { ConfirmationDialogConfig } from '../../../../../../../../core/src/shared/components/confirmation-dialog.config';
import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service';
Expand Down Expand Up @@ -58,6 +61,7 @@ const appRestageConfirmation = new ConfirmationDialogConfig(
export class BuildTabComponent implements OnInit {
public isBusyUpdating$: Observable<{ updating: boolean }>;
public manageAppPermission = CfCurrentUserPermissions.APPLICATION_MANAGE;

constructor(
public applicationService: ApplicationService,
private scmService: GitSCMService,
Expand All @@ -66,7 +70,7 @@ export class BuildTabComponent implements OnInit {
private route: ActivatedRoute,
private router: Router,
private confirmDialog: ConfirmationDialogService,

private cups: CurrentUserPermissionsService
) { }

cardTwoFetching$: Observable<boolean>;
Expand Down Expand Up @@ -108,8 +112,17 @@ export class BuildTabComponent implements OnInit {
})
);

this.deploySource$ = this.applicationService.applicationStratProject$.pipe(
combineLatest(this.applicationService.application$)
const canSeeEnvVars$ = this.applicationService.appSpace$.pipe(
switchMap(space => this.cups.can(
CfCurrentUserPermissions.APPLICATION_VIEW_ENV_VARS,
this.applicationService.cfGuid,
space.metadata.guid)
)
)

const deploySource$ = observableCombineLatest(
this.applicationService.applicationStratProject$,
this.applicationService.application$
).pipe(
map(([project, app]) => {
if (!!project) {
Expand Down Expand Up @@ -149,6 +162,10 @@ export class BuildTabComponent implements OnInit {
}
}),
startWith({ type: 'loading' })
)

this.deploySource$ = canSeeEnvVars$.pipe(
switchMap(canSeeEnvVars => canSeeEnvVars ? deploySource$ : of(null)),
);
}

Expand Down

0 comments on commit 3af3d39

Please sign in to comment.