-
Notifications
You must be signed in to change notification settings - Fork 900
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 MinMaxDesiredChanges component (#…
- Loading branch information
1 parent
3a390c9
commit 97c4aed
Showing
4 changed files
with
66 additions
and
50 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
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export * from './serverGroupReader.service'; | ||
export * from './serverGroupWriter.service'; | ||
export * from './details/serverGroupWarningMessage.service'; | ||
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 './metrics/CloudMetricsReader'; | ||
export * from './configure/common'; | ||
export * from './resize/MinMaxDesiredChanges'; | ||
export * from './serverGroupReader.service'; | ||
export * from './serverGroupWriter.service'; | ||
export * from './templates'; | ||
export * from './ServerGroup'; | ||
export * from './ServerGroupHeader'; |
35 changes: 35 additions & 0 deletions
35
app/scripts/modules/core/src/serverGroup/resize/MinMaxDesiredChanges.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,35 @@ | ||
import * as React from 'react'; | ||
import { startCase } from 'lodash'; | ||
import { ICapacity } from '@spinnaker/core'; | ||
|
||
export interface IMinMaxDesiredChangesProps { | ||
current: ICapacity; | ||
next: ICapacity; | ||
} | ||
|
||
export function MinMaxDesiredChanges(props: IMinMaxDesiredChangesProps) { | ||
const { current, next } = props; | ||
const fields: Array<keyof ICapacity> = ['min', 'max', 'desired']; | ||
|
||
const changedCapacityFields = fields | ||
.map(field => { | ||
const hasChanged = current[field] !== next[field]; | ||
return hasChanged ? { field, currentValue: current[field], nextValue: next[field] } : null; | ||
}) | ||
.filter(x => !!x); | ||
|
||
if (!changedCapacityFields.length) { | ||
return <span>No changes</span>; | ||
} | ||
|
||
return ( | ||
<> | ||
{changedCapacityFields.map(field => ( | ||
<div key={field.field}> | ||
{startCase(field.field)}: <b>{field.currentValue}</b> <i className="fa fa-long-arrow-alt-right" />{' '} | ||
<b>{field.nextValue}</b> | ||
</div> | ||
))} | ||
</> | ||
); | ||
} |