Skip to content

Commit 7d73e91

Browse files
committed
rebase
1 parent 26c83ee commit 7d73e91

File tree

7 files changed

+262
-22
lines changed

7 files changed

+262
-22
lines changed

packages/core/src/docdb/activation.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import { modifyInstance } from './commands/modifyInstance'
2121
import { rebootInstance } from './commands/rebootInstance'
2222
import { renameInstance } from './commands/renameInstance'
2323
import { addTag, listTags, removeTag } from './commands/tagCommands'
24-
import { env, Uri } from 'vscode'
24+
import { Uri } from 'vscode'
25+
import { openUrl } from '../shared/utilities/vsCodeUtils'
2526

2627
/**
2728
* Activates DocumentDB components.
@@ -85,13 +86,14 @@ export async function activate(ctx: ExtContext): Promise<void> {
8586
await removeTag(node)
8687
}),
8788

88-
Commands.register('aws.docdb.openBrowser', async (node?: DBResourceNode) => {
89+
Commands.register('aws.docdb.viewConsole', async (node?: DBResourceNode) => {
8990
await node?.openInBrowser()
9091
}),
9192

92-
Commands.register('aws.docdb.openHelp', async (node?: DBResourceNode) => {
93-
const url = Uri.parse('https://docs.aws.amazon.com/documentdb/latest/developerguide/get-started-guide.html')
94-
await env.openExternal(url)
93+
Commands.register('aws.docdb.viewDocs', async (node?: DBResourceNode) => {
94+
await openUrl(
95+
Uri.parse('https://docs.aws.amazon.com/documentdb/latest/developerguide/get-started-guide.html')
96+
)
9597
}),
9698

9799
Commands.register('aws.docdb.copyEndpoint', async (node?: DBResourceNode) => {

packages/core/src/docdb/explorer/dbClusterNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { PlaceholderNode } from '../../shared/treeview/nodes/placeholderNode'
1818
import { DBInstance, DocumentDBClient } from '../../shared/clients/docdbClient'
1919
import { DocDBContext } from './docdbContext'
2020
import { toTitleCase } from '../../shared'
21+
import { getAwsConsoleUrl } from '../../shared/awsConsole'
2122

2223
export type DBClusterRole = 'global' | 'regional' | 'primary' | 'secondary'
2324

@@ -136,10 +137,9 @@ export class DBClusterNode extends DBResourceNode {
136137
}
137138

138139
override getConsoleUrl() {
139-
const region = this.regionCode
140-
return vscode.Uri.parse(
141-
`https://${region}.console.aws.amazon.com/docdb/home?region=${region}#cluster-details/${this.name}`
142-
)
140+
return getAwsConsoleUrl('docdb', this.regionCode).with({
141+
fragment: `cluster-details/${this.name}`,
142+
})
143143
}
144144

145145
override copyEndpoint() {

packages/core/src/docdb/explorer/dbElasticClusterNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DBElasticCluster, DocumentDBClient } from '../../shared/clients/docdbCl
1111
import { DocDBContext } from './docdbContext'
1212
import { copyToClipboard } from '../../shared/utilities/messages'
1313
import { localize } from '../../shared/utilities/vsCodeUtils'
14+
import { getAwsConsoleUrl } from '../../shared/awsConsole'
1415

1516
/**
1617
* An AWS Explorer node representing DocumentDB elastic clusters.
@@ -77,10 +78,9 @@ export class DBElasticClusterNode extends DBResourceNode {
7778
}
7879

7980
override getConsoleUrl() {
80-
const region = this.regionCode
81-
return vscode.Uri.parse(
82-
`https://${region}.console.aws.amazon.com/docdb/home?region=${region}#elastic-cluster-details/${this.arn}`
83-
)
81+
return getAwsConsoleUrl('docdb', this.regionCode).with({
82+
fragment: `elastic-cluster-details/${this.arn}`,
83+
})
8484
}
8585

8686
override async copyEndpoint() {

packages/core/src/docdb/explorer/dbGlobalClusterNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { DBCluster, GlobalCluster, GlobalClusterMember, ModifyGlobalClusterMessa
1616
import { DBResourceNode } from './dbResourceNode'
1717
import { DocDBContext } from './docdbContext'
1818
import { copyToClipboard } from '../../shared/utilities/messages'
19+
import { getAwsConsoleUrl } from '../../shared/awsConsole'
1920

2021
function getRegionFromArn(arn: string) {
2122
const match = arn.match(/:rds:([^:]+):.*:cluster:/)
@@ -127,10 +128,9 @@ export class DBGlobalClusterNode extends DBResourceNode {
127128
}
128129

129130
override getConsoleUrl(): vscode.Uri {
130-
const region = this.regionCode
131-
return vscode.Uri.parse(
132-
`https://${region}.console.aws.amazon.com/docdb/home?region=${region}#global-cluster-details/${this.name}`
133-
)
131+
return getAwsConsoleUrl('docdb', this.regionCode).with({
132+
fragment: `global-cluster-details/${this.name}`,
133+
})
134134
}
135135

136136
public [inspect.custom](): string {

packages/core/src/docdb/explorer/dbInstanceNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { DBClusterNode } from './dbClusterNode'
1212
import { ModifyDBInstanceMessage } from '@aws-sdk/client-docdb'
1313
import { copyToClipboard } from '../../shared/utilities/messages'
1414
import { toTitleCase } from '../../shared'
15+
import { getAwsConsoleUrl } from '../../shared/awsConsole'
1516

1617
/**
1718
* An AWS Explorer node representing a DocumentDB instance.
@@ -70,10 +71,9 @@ export class DBInstanceNode extends DBResourceNode {
7071
}
7172

7273
override getConsoleUrl() {
73-
const region = this.regionCode
74-
return vscode.Uri.parse(
75-
`https://${region}.console.aws.amazon.com/docdb/home?region=${region}#instance-details/${this.name}`
76-
)
74+
return getAwsConsoleUrl('docdb', this.regionCode).with({
75+
fragment: `instance-details/${this.name}`,
76+
})
7777
}
7878

7979
override copyEndpoint() {

packages/core/src/shared/awsConsole.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
import * as vscode from 'vscode'
77

8-
export function getAwsConsoleUrl(service: 'ecr' | 'cloudformation' | 'ec2-launch', region: string): vscode.Uri {
8+
export function getAwsConsoleUrl(
9+
service: 'ecr' | 'cloudformation' | 'ec2-launch' | 'docdb',
10+
region: string
11+
): vscode.Uri {
912
switch (service) {
1013
case 'ecr':
1114
return vscode.Uri.parse(`https://${region}.console.aws.amazon.com/ecr/repositories?region=${region}`)
@@ -15,6 +18,8 @@ export function getAwsConsoleUrl(service: 'ecr' | 'cloudformation' | 'ec2-launch
1518
return vscode.Uri.parse(
1619
`https://${region}.console.aws.amazon.com/ec2/home?region=${region}#LaunchInstances:`
1720
)
21+
case 'docdb':
22+
return vscode.Uri.parse(`https://${region}.console.aws.amazon.com/docdb/home?region=${region}`)
1823
default:
1924
throw Error()
2025
}

packages/toolkit/package.json

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,90 @@
19831983
"command": "aws.codecatalyst.signout",
19841984
"when": "viewItem =~ /^awsCodeCatalystNode/&& !isCloud9 && aws.codecatalyst.connected",
19851985
"group": "0@2"
1986+
},
1987+
{
1988+
"command": "aws.docdb.createCluster",
1989+
"when": "view == aws.explorer && viewItem == awsDocDBNode",
1990+
"group": "inline@1"
1991+
},
1992+
{
1993+
"command": "aws.docdb.createCluster",
1994+
"when": "view == aws.explorer && viewItem == awsDocDBNode",
1995+
"group": "0@1"
1996+
},
1997+
{
1998+
"command": "aws.docdb.startCluster",
1999+
"when": "viewItem =~ /^awsDocDB-cluster-(regional|elastic)-stopped/",
2000+
"group": "inline@1"
2001+
},
2002+
{
2003+
"command": "aws.docdb.startCluster",
2004+
"when": "viewItem =~ /^awsDocDB-cluster-(regional|elastic)-stopped/"
2005+
},
2006+
{
2007+
"command": "aws.docdb.stopCluster",
2008+
"when": "viewItem =~ /^awsDocDB-cluster-(regional|elastic)-running/",
2009+
"group": "inline@1"
2010+
},
2011+
{
2012+
"command": "aws.docdb.stopCluster",
2013+
"when": "viewItem =~ /^awsDocDB-cluster-(regional|elastic)-running/"
2014+
},
2015+
{
2016+
"command": "aws.docdb.renameCluster",
2017+
"when": "viewItem =~ /^awsDocDB-cluster(?!.*-elastic.*)/",
2018+
"group": "0@2"
2019+
},
2020+
{
2021+
"command": "aws.docdb.deleteCluster",
2022+
"when": "viewItem =~ /^awsDocDB-cluster-(regional|elastic)/",
2023+
"group": "0@4"
2024+
},
2025+
{
2026+
"command": "aws.docdb.createInstance",
2027+
"when": "viewItem =~ /^awsDocDB-cluster-(?!elastic|global)(?!-stopped)/"
2028+
},
2029+
{
2030+
"command": "aws.docdb.renameInstance",
2031+
"when": " viewItem =~ /^awsDocDB-instance/",
2032+
"group": "0@2"
2033+
},
2034+
{
2035+
"command": "aws.docdb.modifyInstance",
2036+
"when": " viewItem =~ /^awsDocDB-instance/",
2037+
"group": "0@3"
2038+
},
2039+
{
2040+
"command": "aws.docdb.rebootInstance",
2041+
"when": "viewItem =~ /^awsDocDB-instance/",
2042+
"group": "inline@1"
2043+
},
2044+
{
2045+
"command": "aws.docdb.rebootInstance",
2046+
"when": "viewItem =~ /^awsDocDB-instance/"
2047+
},
2048+
{
2049+
"command": "aws.docdb.deleteInstance",
2050+
"when": " viewItem =~ /^awsDocDB-instance/",
2051+
"group": "0@4"
2052+
},
2053+
{
2054+
"command": "aws.docdb.listTags",
2055+
"when": "viewItem =~ /^awsDocDB-(?!cluster-global).*/"
2056+
},
2057+
{
2058+
"command": "aws.docdb.viewConsole",
2059+
"when": "viewItem =~ /^awsDocDB-/",
2060+
"group": "0@1"
2061+
},
2062+
{
2063+
"command": "aws.docdb.viewDocs",
2064+
"when": "viewItem == awsDocDBNode"
2065+
},
2066+
{
2067+
"command": "aws.docdb.copyEndpoint",
2068+
"when": "viewItem =~ /^awsDocDB-/",
2069+
"group": "0@1"
19862070
}
19872071
],
19882072
"aws.toolkit.auth": [
@@ -3538,6 +3622,155 @@
35383622
"category": "%AWS.title.cn%"
35393623
}
35403624
}
3625+
},
3626+
{
3627+
"command": "aws.docdb.createCluster",
3628+
"title": "%AWS.command.docdb.createCluster%",
3629+
"icon": "$(add)",
3630+
"category": "%AWS.title%",
3631+
"enablement": "isCloud9 || !aws.isWebExtHost",
3632+
"cloud9": {
3633+
"cn": {
3634+
"category": "%AWS.title.cn%"
3635+
}
3636+
}
3637+
},
3638+
{
3639+
"command": "aws.docdb.createInstance",
3640+
"title": "%AWS.command.docdb.createInstance%",
3641+
"icon": "$(add)",
3642+
"category": "%AWS.title%",
3643+
"enablement": "(isCloud9 || !aws.isWebExtHost)",
3644+
"cloud9": {
3645+
"cn": {
3646+
"category": "%AWS.title.cn%"
3647+
}
3648+
}
3649+
},
3650+
{
3651+
"command": "aws.docdb.deleteInstance",
3652+
"title": "%AWS.generic.promptDelete%",
3653+
"category": "%AWS.title%",
3654+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem == awsDocDB-instance-available",
3655+
"cloud9": {
3656+
"cn": {
3657+
"category": "%AWS.title.cn%"
3658+
}
3659+
}
3660+
},
3661+
{
3662+
"command": "aws.docdb.renameInstance",
3663+
"title": "%AWS.generic.promptRename%",
3664+
"category": "%AWS.title%",
3665+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem == awsDocDB-instance-available",
3666+
"cloud9": {
3667+
"cn": {
3668+
"category": "%AWS.title.cn%"
3669+
}
3670+
}
3671+
},
3672+
{
3673+
"command": "aws.docdb.modifyInstance",
3674+
"title": "%AWS.command.docdb.modifyInstance%",
3675+
"category": "%AWS.title%",
3676+
"enablement": "isCloud9 || !aws.isWebExtHost && viewItem == awsDocDB-instance-available",
3677+
"cloud9": {
3678+
"cn": {
3679+
"category": "%AWS.title.cn%"
3680+
}
3681+
}
3682+
},
3683+
{
3684+
"command": "aws.docdb.rebootInstance",
3685+
"title": "%AWS.command.docdb.rebootInstance%",
3686+
"icon": "$(debug-restart)",
3687+
"category": "%AWS.title%",
3688+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem == awsDocDB-instance-available",
3689+
"cloud9": {
3690+
"cn": {
3691+
"category": "%AWS.title.cn%"
3692+
}
3693+
}
3694+
},
3695+
{
3696+
"command": "aws.docdb.renameCluster",
3697+
"title": "%AWS.generic.promptRename%",
3698+
"category": "%AWS.title%",
3699+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem =~ /^awsDocDB-cluster.*-running/",
3700+
"cloud9": {
3701+
"cn": {
3702+
"category": "%AWS.title.cn%"
3703+
}
3704+
}
3705+
},
3706+
{
3707+
"command": "aws.docdb.startCluster",
3708+
"title": "%AWS.command.docdb.startCluster%",
3709+
"icon": "$(debug-start)",
3710+
"category": "%AWS.title%",
3711+
"enablement": "!aws.isWebExtHost && viewItem =~ /^awsDocDB-cluster.*-stopped/"
3712+
},
3713+
{
3714+
"command": "aws.docdb.stopCluster",
3715+
"title": "%AWS.command.docdb.stopCluster%",
3716+
"icon": "$(debug-pause)",
3717+
"category": "%AWS.title%",
3718+
"enablement": "!aws.isWebExtHost && viewItem =~ /^awsDocDB-cluster.*-running/"
3719+
},
3720+
{
3721+
"command": "aws.docdb.deleteCluster",
3722+
"title": "%AWS.generic.promptDelete%",
3723+
"category": "%AWS.title%",
3724+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem =~ /^awsDocDB-cluster.*-running/",
3725+
"cloud9": {
3726+
"cn": {
3727+
"category": "%AWS.title.cn%"
3728+
}
3729+
}
3730+
},
3731+
{
3732+
"command": "aws.docdb.listTags",
3733+
"title": "%AWS.command.docdb.tags%",
3734+
"category": "%AWS.title%",
3735+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem =~ /^awsDocDB/",
3736+
"cloud9": {
3737+
"cn": {
3738+
"category": "%AWS.title.cn%"
3739+
}
3740+
}
3741+
},
3742+
{
3743+
"command": "aws.docdb.viewConsole",
3744+
"title": "%AWS.command.docdb.open%",
3745+
"category": "%AWS.title%",
3746+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem =~ /^awsDocDB/",
3747+
"cloud9": {
3748+
"cn": {
3749+
"category": "%AWS.title.cn%"
3750+
}
3751+
}
3752+
},
3753+
{
3754+
"command": "aws.docdb.viewDocs",
3755+
"title": "%AWS.generic.viewDocs%",
3756+
"category": "%AWS.title%",
3757+
"enablement": "(isCloud9 || !aws.isWebExtHost)",
3758+
"cloud9": {
3759+
"cn": {
3760+
"category": "%AWS.title.cn%"
3761+
}
3762+
}
3763+
},
3764+
{
3765+
"command": "aws.docdb.copyEndpoint",
3766+
"title": "%AWS.command.docdb.copyEndpoint%",
3767+
"category": "%AWS.title%",
3768+
"enablement": "(isCloud9 || !aws.isWebExtHost) && viewItem =~ /^awsDocDB/",
3769+
"cloud9": {
3770+
"cn": {
3771+
"category": "%AWS.title.cn%"
3772+
}
3773+
}
35413774
}
35423775
],
35433776
"jsonValidation": [

0 commit comments

Comments
 (0)