Skip to content

Commit

Permalink
Merge pull request #3242 from cloudfoundry-incubator/deploy-app-notif…
Browse files Browse the repository at this point in the history
…ication

Deploy App: Add notification toast
  • Loading branch information
richard-cox authored Dec 5, 2018
2 parents b3b36a0 + d1472cf commit 7948017
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class DeployApplicationStep3Component implements OnDestroy {
constructor(
private store: Store<AppState>,
private snackBar: MatSnackBar,
public cfOrgSpaceService: CfOrgSpaceDataService,
public cfOrgSpaceService: CfOrgSpaceDataService
) {
this.valid$ = observableOf(false);
this.closeable$ = observableOf(false);
Expand Down Expand Up @@ -96,11 +96,28 @@ export class DeployApplicationStep3Component implements OnDestroy {
ngOnDestroy() {
this.store.dispatch(new DeleteDeployAppSection());
this.destroyDeployer();
if (this.deployer) {
if (this.deployer && !this.deployer.deploying) {
this.deployer.close();
} else {
this.setupCompletionNotification();
}
}

private setupCompletionNotification() {
this.deployer.status$.pipe(
filter(status => !status.deploying),
first()
).subscribe(status => {
if (status.error) {
this.snackBar.open(status.errorMsg, 'Dismiss');
} else {
const ref = this.snackBar.open('Application deployment complete', 'View', { duration: 5000 });
ref.onAction().subscribe(() => { this.goToAppSummary(); });
}
this.deployer.close();
});
}

onEnter = (fsDeployer: DeployApplicationDeployer) => {
// If we were passed data, then we came from the File System step
if (fsDeployer) {
Expand All @@ -122,14 +139,18 @@ export class DeployApplicationStep3Component implements OnDestroy {
onNext: StepOnNextFunction = () => {
// Delete Deploy App Section
this.store.dispatch(new DeleteDeployAppSection());
this.goToAppSummary();
return observableOf({ success: true });
}

goToAppSummary() {
// Take user to applications
const { cfGuid } = this.deployer;
this.store.dispatch(new RouterNav({ path: ['applications', cfGuid, this.appGuid] }));
if (this.appGuid) {
this.store.dispatch(new GetAppEnvVarsAction(this.appGuid, cfGuid));
// Ensure the application package_state is correct
this.store.dispatch(new GetApplication(this.appGuid, cfGuid));
this.store.dispatch(new RouterNav({ path: ['applications', cfGuid, this.appGuid] }));
}
return observableOf({ success: true });
}
}

0 comments on commit 7948017

Please sign in to comment.