Skip to content

Commit

Permalink
refactor(aws): move Resize item in the AmazonServerGroupAction dropdo…
Browse files Browse the repository at this point in the history
…wn into separate component
  • Loading branch information
Siyuan Fu authored and christopherthielen committed Oct 17, 2019
1 parent 17be6af commit 6186e40
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,39 @@ import {
ReactInjector,
ServerGroupWarningMessageService,
SETTINGS,
Overridable,
} from '@spinnaker/core';

import { IAmazonServerGroup, IAmazonServerGroupView } from 'amazon/domain';
import { AmazonCloneServerGroupModal } from 'amazon/serverGroup/configure/wizard/AmazonCloneServerGroupModal';
import { AwsReactInjector } from 'amazon/reactShims';
import { IAmazonServerGroupCommand } from '../configure';
import { AmazonResizeServerGroupModal } from './resize/AmazonResizeServerGroupModal';
import {
AmazonResizeServerGroupModal,
IAmazonResizeServerGroupModalProps,
} from './resize/AmazonResizeServerGroupModal';

export interface IAmazonServerGroupActionsProps extends IServerGroupActionsProps {
serverGroup: IAmazonServerGroupView;
}

@Overridable('AmazonServerGroupActions.resize')
export class AmazonServerGroupActionsResize extends React.Component<IAmazonResizeServerGroupModalProps> {
private resizeServerGroup = (): void => {
AmazonResizeServerGroupModal.show(this.props);
};

public render(): JSX.Element {
return (
<li>
<a className="clickable" onClick={this.resizeServerGroup}>
Resize
</a>
</li>
);
}
}

export class AmazonServerGroupActions extends React.Component<IAmazonServerGroupActionsProps> {
private isEnableLocked(): boolean {
if (this.props.serverGroup.isDisabled) {
Expand Down Expand Up @@ -255,11 +276,6 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup
});
};

private resizeServerGroup = (): void => {
const { app, serverGroup } = this.props;
AmazonResizeServerGroupModal.show({ application: app, serverGroup });
};

private cloneServerGroup = (): void => {
const { app, serverGroup } = this.props;
AwsReactInjector.awsServerGroupCommandBuilder
Expand Down Expand Up @@ -289,11 +305,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup
</li>
)}
{this.isRollbackEnabled() && <li role="presentation" className="divider" />}
<li>
<a className="clickable" onClick={this.resizeServerGroup}>
Resize
</a>
</li>
<AmazonServerGroupActionsResize application={app} serverGroup={serverGroup} />
{!serverGroup.isDisabled && (
<li>
<a className="clickable" onClick={this.disableServerGroup}>
Expand Down

0 comments on commit 6186e40

Please sign in to comment.