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

Commit

Permalink
fix(sg): do not redirect to the new SG after its creation (#1147)
Browse files Browse the repository at this point in the history
PR Close #1096
  • Loading branch information
tamazlykar committed Jul 11, 2018
1 parent 0ce0c6f commit 3293e74
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 35 deletions.
10 changes: 1 addition & 9 deletions src/app/reducers/security-groups/redux/sg.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export class SecurityGroupEffects {
@Effect({ dispatch: false })
createSecurityGroupSuccess$: Observable<Action> = this.actions$
.ofType(securityGroup.CREATE_SECURITY_GROUP_SUCCESS)
.do((action: securityGroup.CreateSecurityGroupSuccess) =>
this.onSecurityGroupCreated(action.payload));
.do(() => this.dialog.closeAll());

@Effect()
deleteSecurityGroup$: Observable<Action> = this.actions$
Expand Down Expand Up @@ -159,13 +158,6 @@ export class SecurityGroupEffects {
}
}

private onSecurityGroupCreated(securityGroup: SecurityGroup): void {
this.dialog.closeAll();
this.router.navigate(['../security-group', securityGroup.id], {
queryParamsHandling: 'preserve'
});
}

private deleteSecurityGroup(securityGroup: SecurityGroup): Observable<any> {
return this.securityGroupService.deleteGroup(securityGroup);
}
Expand Down
8 changes: 8 additions & 0 deletions src/app/reducers/templates/redux/template.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ export class TemplateEffects {
});
});

@Effect({ dispatch: false })
registerAndCreateTemplateSuccess$: Observable<Action> = this.actions$
.ofType(
template.TEMPLATE_REGISTER_SUCCESS,
template.TEMPLATE_CREATE_SUCCESS
)
.do(() => this.dialog.closeAll());

@Effect()
setTemplateGroup$: Observable<Action> = this.actions$
.ofType(template.SET_TEMPLATE_GROUP)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component } from '@angular/core';
import { State } from '../../reducers/index';
import { Store } from '@ngrx/store';
import { Router } from '@angular/router';

import * as securityGroupActions from '../../reducers/security-groups/redux/sg.actions';
import * as fromSecurityGroups from '../../reducers/security-groups/redux/sg.reducers';
Expand All @@ -12,27 +11,17 @@ import * as fromSecurityGroups from '../../reducers/security-groups/redux/sg.red
<cs-security-group-creation
[mode]="viewMode$ | async"
[creationInProgress]="isLoading$ | async"
(cancel)="onCancel()"
(createSecurityGroup)="onSecurityGroupCreation($event)"
></cs-security-group-creation>`
})
export class SecurityGroupCreationContainerComponent {
readonly isLoading$ = this.store.select(fromSecurityGroups.isFormLoading);
readonly viewMode$ = this.store.select(fromSecurityGroups.viewMode);

constructor(
private store: Store<State>,
private router: Router
) {
constructor(private store: Store<State>) {
}

public onSecurityGroupCreation(creationParams) {
this.store.dispatch(new securityGroupActions.CreateSecurityGroup(creationParams));
}

public onCancel(): void {
this.router.navigate(['../security-group'], {
queryParamsHandling: 'preserve'
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog, MatDialogConfig } from '@angular/material';

import { SecurityGroupCreationContainerComponent } from '../containers/security-group-creation.container';


Expand All @@ -8,13 +10,19 @@ import { SecurityGroupCreationContainerComponent } from '../containers/security-
template: ``
})
export class SecurityGroupCreationDialogComponent {
constructor(private dialog: MatDialog) {
constructor(
private dialog: MatDialog,
private router: Router,
private route: ActivatedRoute
) {
this.dialog.open(SecurityGroupCreationContainerComponent, <MatDialogConfig>{
data: { },
disableClose: true,
width: '405px'
})
}).afterClosed()
.subscribe(() => this.router.navigate(['../'], {
queryParamsHandling: 'preserve',
relativeTo: this.route
}));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ <h3 *ngIf="isModeShared" class="mat-dialog-title">
mat-button
color="primary"
matDialogClose
(click)="cancel.emit()"
type="button"
>
{{ 'COMMON.CANCEL' | translate }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
EventEmitter,
Input,
Output
} from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { Rules } from '../../shared/components/security-group-builder/rules';
import { SecurityGroupViewMode } from '../sg-view-mode';

Expand All @@ -26,7 +20,6 @@ export interface SecurityGroupCreationParams {
export class SecurityGroupCreationComponent {
@Input() public creationInProgress = false;
@Input() public mode: SecurityGroupViewMode;
@Output() public cancel = new EventEmitter();
@Output() public createSecurityGroup = new EventEmitter<SecurityGroupCreationParams>();

public name = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export class TemplateCreationContainerComponent {
} else {
this.store.dispatch(new templateActions.RegisterTemplate(params));
}
this.dialogRef.close();
}
}

0 comments on commit 3293e74

Please sign in to comment.