-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core/serverGroup): Extract capacity details components to re…
…use across providers (#7182)
- Loading branch information
1 parent
20df06e
commit 6630f9b
Showing
15 changed files
with
126 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/scripts/modules/amazon/src/serverGroup/details/sections/AmazonCapacityDetailsSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as React from 'react'; | ||
|
||
import { CollapsibleSection, NgReact, Overridable, ICapacity, CapacityDetailsSection } from '@spinnaker/core'; | ||
|
||
import { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps'; | ||
import { AmazonResizeServerGroupModal } from '../resize/AmazonResizeServerGroupModal'; | ||
|
||
@Overridable('amazon.serverGroup.CapacityDetailsSection') | ||
export class AmazonCapacityDetailsSection extends React.Component<IAmazonServerGroupDetailsSectionProps> { | ||
public render(): JSX.Element { | ||
const { serverGroup, app: application } = this.props; | ||
const { ViewScalingActivitiesLink } = NgReact; | ||
|
||
const capacity: ICapacity = { | ||
min: serverGroup.asg.minSize, | ||
max: serverGroup.asg.maxSize, | ||
desired: serverGroup.asg.desiredCapacity, | ||
}; | ||
|
||
return ( | ||
<CollapsibleSection heading="Capacity" defaultExpanded={true}> | ||
<CapacityDetailsSection current={serverGroup.instances.length} capacity={capacity} /> | ||
|
||
<div> | ||
<a className="clickable" onClick={() => AmazonResizeServerGroupModal.show({ application, serverGroup })}> | ||
Resize Server Group | ||
</a> | ||
</div> | ||
|
||
<div> | ||
<ViewScalingActivitiesLink serverGroup={serverGroup} /> | ||
</div> | ||
</CollapsibleSection> | ||
); | ||
} | ||
} |
49 changes: 0 additions & 49 deletions
49
app/scripts/modules/amazon/src/serverGroup/details/sections/CapacityDetailsSection.tsx
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
app/scripts/modules/amazon/src/serverGroup/details/sections/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/scripts/modules/core/src/serverGroup/details/capacity/CapacityDetailsSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as React from 'react'; | ||
|
||
import { ICapacity } from '../../serverGroupWriter.service'; | ||
import { CurrentCapacity } from './CurrentCapacity'; | ||
import { DesiredCapacity } from './DesiredCapacity'; | ||
|
||
interface ICapacityDetailsSectionProps { | ||
capacity: ICapacity; | ||
current: number; | ||
} | ||
|
||
export function CapacityDetailsSection(props: ICapacityDetailsSectionProps) { | ||
const { capacity, current } = props; | ||
const simpleMode = capacity.max === capacity.max; | ||
return ( | ||
<dl className="dl-horizontal dl-flex"> | ||
<DesiredCapacity capacity={capacity} simpleMode={simpleMode} /> | ||
<CurrentCapacity currentCapacity={current} /> | ||
</dl> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
app/scripts/modules/core/src/serverGroup/details/capacity/CurrentCapacity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
|
||
export function CurrentCapacity(props: { currentCapacity: number }) { | ||
return ( | ||
<> | ||
<dt>Current</dt> | ||
<dd>{props.currentCapacity}</dd> | ||
</> | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
app/scripts/modules/core/src/serverGroup/details/capacity/DesiredCapacity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { ICapacity } from '../../serverGroupWriter.service'; | ||
|
||
export function DesiredCapacity(props: { capacity: ICapacity; simpleMode: boolean }) { | ||
const SimpleCapacity = () => ( | ||
<> | ||
<dt>Min/Max</dt> | ||
<dd>{props.capacity.desired}</dd> | ||
</> | ||
); | ||
|
||
const AdvancedCapacity = () => ( | ||
<> | ||
<dt>Min</dt> | ||
<dd>{props.capacity.min}</dd> | ||
<dt>Desired</dt> | ||
<dd>{props.capacity.desired}</dd> | ||
<dt>Max</dt> | ||
<dd>{props.capacity.max}</dd> | ||
</> | ||
); | ||
|
||
return props.simpleMode ? <SimpleCapacity /> : <AdvancedCapacity />; | ||
} |
3 changes: 3 additions & 0 deletions
3
app/scripts/modules/core/src/serverGroup/details/capacity/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './CapacityDetailsSection'; | ||
export * from './CurrentCapacity'; | ||
export * from './DesiredCapacity'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from './ServerGroupDetails'; | ||
export * from './ServerGroupDetails'; | ||
export * from './ServerGroupDetailsWrapper'; | ||
export * from './ShowUserData'; | ||
export * from './capacity'; | ||
export * from './scalingActivities'; | ||
export * from './serverGroupWarningMessage.service'; |
1 change: 1 addition & 0 deletions
1
app/scripts/modules/core/src/serverGroup/details/scalingActivities/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ViewScalingActivitiesLink'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
export * from './ServerGroup'; | ||
export * from './ServerGroupHeader'; | ||
export * from './configure/common'; | ||
export * from './details/ServerGroupDetails'; | ||
export * from './details/ServerGroupDetailsWrapper'; | ||
export * from './details/ShowUserData'; | ||
export * from './details/serverGroupWarningMessage.service'; | ||
export * from './details'; | ||
export * from './metrics/CloudMetricsReader'; | ||
export * from './resize/MinMaxDesiredChanges'; | ||
export * from './resize'; | ||
export * from './serverGroupReader.service'; | ||
export * from './serverGroupWriter.service'; | ||
export * from './templates'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './MinMaxDesiredChanges'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { TITUS_MODULE } from './titus.module'; | ||
|
||
export * from './titus.settings'; | ||
export * from './reactShims'; | ||
export * from './serverGroup/details'; | ||
export * from './titus.settings'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './TitusCapacityDetailsSection'; | ||
export * from './TitusSecurityGroups'; | ||
export * from './resize/TitusResizeServerGroupModal'; |