-
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(aws/instance): Reactify instance tags and security groups (#…
…8686) * refactor(aws/instance): Instance tags and security groups
- Loading branch information
1 parent
9b8795d
commit d15ca2d
Showing
10 changed files
with
101 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { IInstance } from '@spinnaker/core'; | ||
import { IAmazonSecurityGroup } from './IAmazonSecurityGroup'; | ||
|
||
export interface IAmazonInstance extends IInstance { | ||
imageId?: string; | ||
instanceType?: string; | ||
securityGroups?: IAmazonSecurityGroup[]; | ||
subnetId?: string; | ||
targetGroups?: string[]; | ||
} |
4 changes: 4 additions & 0 deletions
4
app/scripts/modules/amazon/src/domain/IAmazonSecurityGroup.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,4 @@ | ||
export interface IAmazonSecurityGroup { | ||
groupId: string; | ||
groupName: string; | ||
} |
43 changes: 43 additions & 0 deletions
43
app/scripts/modules/amazon/src/instance/details/InstanceSecurityGroups.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,43 @@ | ||
import React from 'react'; | ||
import { UISref } from '@uirouter/react'; | ||
import { UIRouterContextComponent } from '@uirouter/react-hybrid'; | ||
import { orderBy } from 'lodash'; | ||
import { CollapsibleSection, FirewallLabels } from '@spinnaker/core'; | ||
import { IAmazonInstance } from '../../domain'; | ||
|
||
export interface IInstanceSecurityGroupsProps { | ||
instance: IAmazonInstance; | ||
} | ||
|
||
export const InstanceSecurityGroups = ({ instance }: IInstanceSecurityGroupsProps) => { | ||
const { account, region, provider, securityGroups, vpcId } = instance; | ||
const sortedSecurityGroups = orderBy(securityGroups, ['groupName'], ['asc']); | ||
const securityGroupLabel = FirewallLabels.get('Firewalls'); | ||
|
||
return ( | ||
<CollapsibleSection heading={securityGroupLabel} defaultExpanded={true}> | ||
<UIRouterContextComponent> | ||
<ul> | ||
{(sortedSecurityGroups || []).map((sg) => ( | ||
<li key={sg.groupId}> | ||
<UISref | ||
to="^.firewallDetails" | ||
params={{ | ||
name: sg.groupName, | ||
accountId: account, | ||
region, | ||
vpcId, | ||
provider, | ||
}} | ||
> | ||
<a> | ||
{sg.groupName} ({sg.groupId}) | ||
</a> | ||
</UISref> | ||
</li> | ||
))} | ||
</ul> | ||
</UIRouterContextComponent> | ||
</CollapsibleSection> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
app/scripts/modules/amazon/src/instance/details/InstanceTags.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 React from 'react'; | ||
import { orderBy } from 'lodash'; | ||
|
||
import { CollapsibleSection, LabeledValue } from '@spinnaker/core'; | ||
|
||
export interface IInstanceTagsProps { | ||
tags: Array<{ | ||
key: string; | ||
value: string; | ||
}>; | ||
} | ||
|
||
export const InstanceTags = ({ tags }: IInstanceTagsProps) => { | ||
const sortedTags = orderBy(tags, ['key'], ['asc']); | ||
return ( | ||
<CollapsibleSection heading="Tags" defaultExpanded={true}> | ||
{!tags.length && <div>No tags associated with this server</div>} | ||
{tags.length && sortedTags.map((tag) => <LabeledValue label={tag.key} value={tag.value} />)} | ||
</CollapsibleSection> | ||
); | ||
}; |
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
12 changes: 12 additions & 0 deletions
12
app/scripts/modules/amazon/src/instance/details/instanceSecurityGroups.component.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,12 @@ | ||
import { withErrorBoundary } from '@spinnaker/core'; | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
|
||
import { InstanceSecurityGroups } from './InstanceSecurityGroups'; | ||
|
||
export const INSTANCE_SECURITY_GROUPS_COMPONENT = 'spinnaker.application.instanceSecurityGroups.component'; | ||
|
||
module(INSTANCE_SECURITY_GROUPS_COMPONENT, []).component( | ||
'instanceSecurityGroups', | ||
react2angular(withErrorBoundary(InstanceSecurityGroups, 'instanceSecurityGroups'), ['instance']), | ||
); |
12 changes: 12 additions & 0 deletions
12
app/scripts/modules/amazon/src/instance/details/instanceTags.component.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,12 @@ | ||
import { withErrorBoundary } from '@spinnaker/core'; | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
|
||
import { InstanceTags } from './InstanceTags'; | ||
|
||
export const INSTANCE_TAGS_COMPONENT = 'spinnaker.application.instanceTags.component'; | ||
|
||
module(INSTANCE_TAGS_COMPONENT, []).component( | ||
'instanceTags', | ||
react2angular(withErrorBoundary(InstanceTags, 'instanceTags'), ['tags']), | ||
); |
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