Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a Welcome view in the vRO Explorer when there is no active profile #76

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
10 changes: 10 additions & 0 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