Skip to content

Commit

Permalink
fix(amazon/loadBalancer): Disable CLB deletion if instances exist (#7509
Browse files Browse the repository at this point in the history
)
  • Loading branch information
caseyhebebrand authored and christopherthielen committed Oct 11, 2019
1 parent d03ce48 commit e4e3c46
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Dropdown } from 'react-bootstrap';
import { get } from 'lodash';
import { get, values } from 'lodash';

import {
Application,
Expand Down Expand Up @@ -104,9 +104,13 @@ export class LoadBalancerActions extends React.Component<ILoadBalancerActionsPro
public render() {
const { app, loadBalancer } = this.props;
const { application } = this.state;

const { AddEntityTagLinks } = NgReact;

const { loadBalancerType, instances, instanceCounts } = loadBalancer;
const clbInstances =
loadBalancerType === 'classic' && values(instanceCounts).filter((v: number | undefined) => v).length;
const allowDeletion = !clbInstances && !instances.length;

return (
<div style={{ display: 'inline-block' }}>
<Dropdown className="dropdown" id="load-balancer-actions-dropdown">
Expand All @@ -119,14 +123,14 @@ export class LoadBalancerActions extends React.Component<ILoadBalancerActionsPro
Edit Load Balancer
</a>
</li>
{!loadBalancer.instances.length && (
{allowDeletion && (
<li>
<a className="clickable" onClick={this.deleteLoadBalancer}>
Delete Load Balancer
</a>
</li>
)}
{loadBalancer.instances.length > 0 && (
{!allowDeletion && (
<li className="disabled">
<a className="clickable" onClick={this.deleteLoadBalancer}>
Delete Load Balancer{' '}
Expand Down

0 comments on commit e4e3c46

Please sign in to comment.