Skip to content

Commit

Permalink
fix(amazon): Fixing load balancers isInternal flag (#6402)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmquach authored Jan 21, 2019
1 parent 56ce321 commit 879221b
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import * as classNames from 'classnames';
import { IPromise } from 'angular';
import { chain, isNil, uniq, groupBy } from 'lodash';
import { Field, FormikErrors } from 'formik';
import { Field, FormikErrors, FieldProps } from 'formik';
import { Observable, Subject } from 'rxjs';

import {
Expand Down Expand Up @@ -107,6 +107,7 @@ class LoadBalancerLocationImpl extends React.Component<ILoadBalancerLocationProp
private shouldHideInternalFlag(): boolean {
if (AWSProviderSettings) {
if (AWSProviderSettings.loadBalancers && AWSProviderSettings.loadBalancers.inferInternalFlagFromSubnet) {
// clouddriver will check the subnet if isInternal is competely omitted
delete this.props.formik.values.isInternal;
return true;
}
Expand Down Expand Up @@ -186,6 +187,10 @@ class LoadBalancerLocationImpl extends React.Component<ILoadBalancerLocationProp
subnet$.takeUntil(this.destroy$).subscribe(subnet => {
this.props.formik.setFieldValue('vpcId', subnet && subnet.vpcIds[0]);
this.props.formik.setFieldValue('subnetType', subnet && subnet.purpose);
if (!this.state.hideInternalFlag && !this.state.internalFlagToggled && subnet && subnet.purpose) {
// Even if inferInternalFlagFromSubnet is false, deck will still try to guess which the user wants unless explicitly toggled
this.props.formik.setFieldValue('isInternal', subnet.purpose.includes('internal'));
}
});

moniker$.takeUntil(this.destroy$).subscribe(moniker => {
Expand Down Expand Up @@ -374,7 +379,11 @@ class LoadBalancerLocationImpl extends React.Component<ILoadBalancerLocationProp
</div>
<div className="col-md-7 checkbox">
<label>
<input type="checkbox" name="isInternal" onChange={this.internalFlagChanged} />
<Field
name="isInternal"
onChange={this.internalFlagChanged}
render={({ field }: FieldProps) => <input type="checkbox" checked={!!field.value} />}
/>
Create an internal load balancer
</label>
</div>
Expand Down

0 comments on commit 879221b

Please sign in to comment.