Skip to content

Commit fb2fa91

Browse files
HweinstockJadenSimonjustinmk3Weinstock
authored
feat(ec2): adopt icons from CodeCatalyst and reinforce state via text. (#3687)
## Problem Potential UX Improvements. ## Solution ![image](https://github.com/aws/aws-toolkit-vscode/assets/42325418/505b3ada-7d9c-4221-94bb-186837a9242d) ![image](https://github.com/aws/aws-toolkit-vscode/assets/42325418/76f7fac8-38eb-496a-a8db-f584b025e6b0) <!--- REMINDER: - Read CONTRIBUTING.md first. - Add test coverage for your changes. - Update the changelog using `npm run newChange`. - Link to related issues/commits. - Testing: how did you test your changes? - Screenshots --> ## License By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: JadenSimon <[email protected]> Co-authored-by: Justin M. Keyes <[email protected]> Co-authored-by: Weinstock <[email protected]>
1 parent e527132 commit fb2fa91

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

packages/core/src/awsService/ec2/explorer/ec2InstanceNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class Ec2InstanceNode extends AWSTreeNodeBase implements AWSResourceNode
3535

3636
public updateInstance(newInstance: SafeEc2Instance) {
3737
this.setInstanceStatus(newInstance.LastSeenStatus)
38-
this.label = `${this.name} (${this.InstanceId})`
38+
this.label = `${this.name} (${this.InstanceId}) ${this.instance.LastSeenStatus.toUpperCase()}`
3939
this.contextValue = this.getContext()
4040
this.iconPath = new vscode.ThemeIcon(getIconCode(this.instance))
4141
this.tooltip = `${this.name}\n${this.InstanceId}\n${this.instance.LastSeenStatus}\n${this.arn}`

packages/core/src/awsService/ec2/prompter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ export interface Ec2Selection {
2020
export class Ec2Prompter {
2121
public constructor(protected filter?: instanceFilter) {}
2222

23-
protected static asQuickPickItem(instance: SafeEc2Instance): DataQuickPickItem<string> {
23+
public static getLabel(instance: SafeEc2Instance) {
2424
const icon = `$(${getIconCode(instance)})`
25+
return `${instance.Name ?? '(no name)'} \t ${icon} ${instance.LastSeenStatus.toUpperCase()}`
26+
}
27+
28+
protected static asQuickPickItem(instance: SafeEc2Instance): DataQuickPickItem<string> {
2529
return {
26-
label: `${icon} \t ${instance.Name ?? '(no name)'}`,
30+
label: Ec2Prompter.getLabel(instance),
2731
detail: instance.InstanceId,
2832
data: instance.InstanceId,
2933
}

packages/core/src/awsService/ec2/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { SafeEc2Instance } from '../../shared/clients/ec2Client'
77

88
export function getIconCode(instance: SafeEc2Instance) {
99
if (instance.LastSeenStatus === 'running') {
10-
return 'check'
10+
return 'pass'
1111
}
1212

1313
if (instance.LastSeenStatus === 'stopped') {
14-
return 'stop'
14+
return 'circle-slash'
1515
}
1616

1717
return 'loading~spin'

packages/core/src/test/awsService/ec2/explorer/ec2InstanceNode.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ describe('ec2InstanceNode', function () {
4848
})
4949

5050
it('initializes the label', async function () {
51-
assert.strictEqual(testNode.label, `${getNameOfInstance(testInstance)} (${testInstance.InstanceId})`)
51+
assert.strictEqual(
52+
testNode.label,
53+
`${getNameOfInstance(testInstance)} (${testInstance.InstanceId}) ${testInstance.LastSeenStatus.toUpperCase()}`
54+
)
5255
})
5356

5457
it('initializes the functionName', async function () {

packages/core/src/test/awsService/ec2/prompter.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import assert from 'assert'
66
import { Ec2Prompter, instanceFilter } from '../../../awsService/ec2/prompter'
77
import { SafeEc2Instance } from '../../../shared/clients/ec2Client'
88
import { RegionSubmenuResponse } from '../../../shared/ui/common/regionSubmenu'
9-
import { getIconCode } from '../../../awsService/ec2/utils'
109
import { Ec2Selection } from '../../../awsService/ec2/prompter'
1110
import { AsyncCollection } from '../../../shared/utilities/asyncCollection'
1211
import { intoCollection } from '../../../shared/utilities/collectionUtils'
@@ -60,7 +59,7 @@ describe('Ec2Prompter', async function () {
6059

6160
const result = prompter.testAsQuickPickItem(testInstance)
6261
const expected = {
63-
label: `$(${getIconCode(testInstance)}) \t ${testInstance.Name}`,
62+
label: Ec2Prompter.getLabel(testInstance),
6463
detail: testInstance.InstanceId,
6564
data: testInstance.InstanceId,
6665
}
@@ -75,7 +74,7 @@ describe('Ec2Prompter', async function () {
7574

7675
const result = prompter.testAsQuickPickItem(testInstance)
7776
const expected = {
78-
label: `$(${getIconCode(testInstance)}) \t (no name)`,
77+
label: Ec2Prompter.getLabel(testInstance),
7978
detail: testInstance.InstanceId,
8079
data: testInstance.InstanceId,
8180
}
@@ -144,17 +143,17 @@ describe('Ec2Prompter', async function () {
144143
it('returns items mapped to QuickPick items without filter', async function () {
145144
const expected = [
146145
{
147-
label: `$(${getIconCode(prompter.instances[0])}) \t ${prompter.instances[0].Name!}`,
146+
label: Ec2Prompter.getLabel(prompter.instances[0]),
148147
detail: prompter.instances[0].InstanceId!,
149148
data: prompter.instances[0].InstanceId!,
150149
},
151150
{
152-
label: `$(${getIconCode(prompter.instances[1])}) \t ${prompter.instances[1].Name!}`,
151+
label: Ec2Prompter.getLabel(prompter.instances[1]),
153152
detail: prompter.instances[1].InstanceId!,
154153
data: prompter.instances[1].InstanceId!,
155154
},
156155
{
157-
label: `$(${getIconCode(prompter.instances[2])}) \t ${prompter.instances[2].Name!}`,
156+
label: Ec2Prompter.getLabel(prompter.instances[2]),
158157
detail: prompter.instances[2].InstanceId!,
159158
data: prompter.instances[2].InstanceId!,
160159
},
@@ -169,12 +168,12 @@ describe('Ec2Prompter', async function () {
169168

170169
const expected = [
171170
{
172-
label: `$(${getIconCode(prompter.instances[0])}) \t ${prompter.instances[0].Name!}`,
171+
label: Ec2Prompter.getLabel(prompter.instances[0]),
173172
detail: prompter.instances[0].InstanceId!,
174173
data: prompter.instances[0].InstanceId!,
175174
},
176175
{
177-
label: `$(${getIconCode(prompter.instances[2])}) \t ${prompter.instances[2].Name!}`,
176+
label: Ec2Prompter.getLabel(prompter.instances[2]),
178177
detail: prompter.instances[2].InstanceId!,
179178
data: prompter.instances[2].InstanceId!,
180179
},
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "ec2 instance status is reinforced with icons and text"
4+
}

0 commit comments

Comments
 (0)