Skip to content

Commit

Permalink
Merge branch 'master' into retain-blueprint-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nblagoev authored Jul 22, 2020
2 parents 95292f6 + deff5a6 commit ad0f693
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 27 deletions.
16 changes: 10 additions & 6 deletions common/src/rest/VraNgRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { VraNgAuth } from "./auth"
import { VraAuthType } from "../types"
import { Blueprint, Deployment, PagedResult, Project, Token } from "./vra-model"

const VMWARE_CLOUD_HOST = "www.mgmt.cloud.vmware.com"
const VMWARE_CLOUD_API = "api.mgmt.cloud.vmware.com"
const VMWARE_CLOUD_CSP = "console.cloud.vmware.com"

export interface TokenPair {
Expand Down Expand Up @@ -51,8 +51,12 @@ export interface VraIdentityIO {
export class VraNgRestClient {
constructor(private host: string, private port: number, private identity: VraIdentityIO) {
if (host === VMWARE_CLOUD_CSP) {
// CSP is only for identity operations, switch to management portal
this.host = VMWARE_CLOUD_HOST
// CSP is only for identity operations, switch to management api
this.host = VMWARE_CLOUD_API
}

if (host === "cloud.vmware.com" || host === "mgmt.cloud.vmware.com" || host === "www.mgmt.cloud.vmware.com") {
this.host = VMWARE_CLOUD_API
}

if (!port || port <= 0) {
Expand Down Expand Up @@ -137,7 +141,7 @@ export class VraNgRestClient {

async login(grant: AuthGrant): Promise<Token> {
const baseUrl =
this.host === VMWARE_CLOUD_HOST ? `https://${VMWARE_CLOUD_CSP}` : `https://${this.host}:${this.port}`
this.host === VMWARE_CLOUD_API ? `https://${VMWARE_CLOUD_CSP}` : `https://${this.host}:${this.port}`

let uri: string
const options: any = {}
Expand Down Expand Up @@ -177,7 +181,7 @@ export class VraNgRestClient {
}

async getLoggedInUser(): Promise<any> {
const baseUrl = this.host === VMWARE_CLOUD_HOST ? `https://${VMWARE_CLOUD_CSP}` : ""
const baseUrl = this.host === VMWARE_CLOUD_API ? `https://${VMWARE_CLOUD_CSP}` : ""
const uri = `${baseUrl}/csp/gateway/am/api/loggedin/user`
return this.send("GET", uri)
}
Expand Down Expand Up @@ -212,7 +216,7 @@ export class VraNgRestClient {
deploymentName: string
projectId: string
blueprintId?: string
content?: string,
content?: string
inputs?: object
}): Promise<Deployment> {
return this.send("POST", "/blueprint/api/blueprint-requests", { body })
Expand Down
19 changes: 15 additions & 4 deletions extension/src/client/provider/explorer/ExplorerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,36 @@ export class ExplorerProvider implements vscode.TreeDataProvider<AbstractNode>,
)

context.subscriptions.push(this, this.tree, refreshCommand, revealItem, onDidChangeSelection)

this.config.onDidChangeConfig(this.onConfigurationChanged, this, context.subscriptions)
}

dispose() {
// empty
}

refresh(): void {
// TODO: refresh on `vrdev.views.explorer.*` configuration change
this.rootNodes.forEach(node => this.onDidChangeTreeDataEmitter.fire(node))
this.onDidChangeTreeDataEmitter.fire(undefined) // trigger on root
}

getTreeItem(element: AbstractNode): Promise<vscode.TreeItem> {
return element.asTreeItem()
}

getChildren(element?: AbstractNode): Promise<AbstractNode[]> {
getChildren(element?: AbstractNode): Promise<AbstractNode[] | undefined> {
return element ? element.getChildren() : this.getRootNodes()
}

getParent(element: AbstractNode): AbstractNode | undefined {
return element.parent
}

private onConfigurationChanged(event: vscode.ConfigurationChangeEvent) {
if (event.affectsConfiguration("vrdev.maven.profile") || event.affectsConfiguration("vrdev.views.explorer")) {
this.refresh()
}
}

private onDidChangeSelection(event: vscode.TreeViewSelectionChangeEvent<AbstractNode>): void {
const node = event.selection.length > 0 ? event.selection[0] : undefined

Expand All @@ -93,7 +100,11 @@ export class ExplorerProvider implements vscode.TreeDataProvider<AbstractNode>,
}
}

private async getRootNodes(): Promise<AbstractNode[]> {
private async getRootNodes(): Promise<AbstractNode[] | undefined> {
if (!this.config.hasActiveProfile()) {
return undefined // show Welcome view
}

this.rootNodes = [
new CategoriesRootNode(
"Workflows",
Expand Down
6 changes: 5 additions & 1 deletion extension/src/client/provider/explorer/PropertiesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ export class PropertiesProvider implements vscode.TreeDataProvider<AbstractNode>
return element.asTreeItem()
}

async getChildren(element?: AbstractNode): Promise<AbstractNode[]> {
async getChildren(element?: AbstractNode): Promise<AbstractNode[] | undefined> {
if (!element) {
if (!this.rootNode) {
return undefined // show Welcome view
}

const properties = this.rootNode ? await this.rootNode.getProperties() : []
vscode.commands.executeCommand(
BuiltInCommands.SetContext,
Expand Down
1 change: 0 additions & 1 deletion extension/src/client/system/ConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { Registrable } from "../Registrable"

@AutoWire
export class ConfigurationManager extends BaseConfiguration implements Registrable {

private homeDir = process.env[process.platform === "win32" ? "USERPROFILE" : "HOME"] || "~"
private readonly logger = Logger.get("ConfigurationManager")

Expand Down
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
}
]
},
"viewsWelcome": [
{
"view": "vrdev.views.explorer",
"contents": "Connect to vRealize Orchetsrator by selecting a maven profile.\n\n[Select Profile](command:vrdev.change.profile)"
},
{
"view": "vrdev.views.properties",
"contents": "Select a node in the Explorer to view its properties."
}
],
"commands": [
{
"command": "vrdev.views.explorer.refresh",
Expand Down Expand Up @@ -553,7 +563,7 @@
"@types/vscode": "1.40.0",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"codecov": "^3.6.5",
"codecov": "^3.7.1",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-header": "^3.0.0",
Expand Down Expand Up @@ -581,7 +591,7 @@
"glob": "^7.1.6",
"jsonc-parser": "^2.1.0",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.15",
"lodash": "^4.17.19",
"micromatch": "^4.0.2",
"module-alias": "^2.2.2",
"moment": "^2.24.0",
Expand Down
21 changes: 8 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1604,10 +1604,10 @@ code-point-at@^1.0.0:
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=

codecov@^3.6.5:
version "3.6.5"
resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.6.5.tgz#d73ce62e8a021f5249f54b073e6f2d6a513f172a"
integrity sha512-v48WuDMUug6JXwmmfsMzhCHRnhUf8O3duqXvltaYJKrO1OekZWpB/eH6iIoaxMl8Qli0+u3OxptdsBOYiD7VAQ==
codecov@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.1.tgz#434cb8d55f18ef01672e5739d3d266696bebc202"
integrity sha512-JHWxyPTkMLLJn9SmKJnwAnvY09kg2Os2+Ux+GG7LwZ9g8gzDDISpIN5wAsH1UBaafA/yGcd3KofMaorE8qd6Lw==
dependencies:
argv "0.0.2"
ignore-walk "3.0.3"
Expand Down Expand Up @@ -4307,15 +4307,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=

lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13:
version "4.17.13"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93"
integrity sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA==

lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=
lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==

lolex@^5.0.0:
version "5.1.2"
Expand Down

0 comments on commit ad0f693

Please sign in to comment.