-
Notifications
You must be signed in to change notification settings - Fork 90
VSCODE-163: Add resources/help panel #166
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a717269
Add buttons for links
9742c31
Add help explorer and tree items with first pass links and text
42500ec
Update ordering and add atlas link
076aa65
Add telemetry events to help panel clicks
d2d15cc
Add icons for help items and tests for telemetry clicks
a13bf05
Add atlas icon
d29e872
Re-add removed test config params
99f7fc5
Update tests and tweak atlas icon
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,35 @@ | ||
import * as vscode from 'vscode'; | ||
import HelpTree from './helpTree'; | ||
import { createLogger } from '../logging'; | ||
import { TelemetryController } from '../telemetry'; | ||
|
||
const log = createLogger('help and info explorer controller'); | ||
|
||
export default class HelpExplorer { | ||
_treeController: HelpTree; | ||
_treeView?: vscode.TreeView<vscode.TreeItem>; | ||
|
||
constructor() { | ||
log.info('activate help explorer'); | ||
this._treeController = new HelpTree(); | ||
} | ||
|
||
activateHelpTreeView(telemetryController: TelemetryController): void { | ||
if (!this._treeView) { | ||
this._treeView = vscode.window.createTreeView('mongoDBHelpExplorer', { | ||
treeDataProvider: this._treeController | ||
}); | ||
this._treeController.activateTreeViewEventHandlers( | ||
this._treeView, | ||
telemetryController | ||
); | ||
} | ||
} | ||
|
||
deactivate(): void { | ||
if (this._treeView) { | ||
this._treeView.dispose(); | ||
delete this._treeView; | ||
} | ||
} | ||
} |
This file contains hidden or 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,133 @@ | ||
import * as vscode from 'vscode'; | ||
const path = require('path'); | ||
|
||
import { getImagesPath } from '../extensionConstants'; | ||
import { TelemetryController } from '../telemetry'; | ||
|
||
const HELP_LINK_CONTEXT_VALUE = 'HELP_LINK'; | ||
|
||
export class HelpLinkTreeItem extends vscode.TreeItem { | ||
iconName?: string; | ||
contextValue = HELP_LINK_CONTEXT_VALUE; | ||
linkId: string; | ||
url: string; | ||
|
||
constructor(title: string, url: string, linkId: string, iconName?: string) { | ||
super(title, vscode.TreeItemCollapsibleState.None); | ||
|
||
this.linkId = linkId; | ||
this.iconName = iconName; | ||
this.url = url; | ||
} | ||
|
||
get iconPath(): | ||
| string | ||
| vscode.Uri | ||
| { light: string | vscode.Uri; dark: string | vscode.Uri } { | ||
if (!this.iconName || this.iconName === '') { | ||
return ''; | ||
} | ||
|
||
const LIGHT = path.join(getImagesPath(), 'light'); | ||
const DARK = path.join(getImagesPath(), 'dark'); | ||
|
||
return { | ||
light: path.join(LIGHT, 'help', `${this.iconName}.svg`), | ||
dark: path.join(DARK, 'help', `${this.iconName}.svg`) | ||
}; | ||
} | ||
} | ||
|
||
export default class HelpTree | ||
implements vscode.TreeDataProvider<vscode.TreeItem> { | ||
contextValue = 'helpTree'; | ||
|
||
getTreeItem(element: vscode.TreeItem): vscode.TreeItem { | ||
return element; | ||
} | ||
|
||
activateTreeViewEventHandlers = ( | ||
treeView: vscode.TreeView<vscode.TreeItem>, | ||
telemetryController: TelemetryController | ||
): void => { | ||
treeView.onDidChangeSelection(async (event: any) => { | ||
if (event.selection && event.selection.length === 1) { | ||
const selectedItem = event.selection[0]; | ||
|
||
await this.onClickHelpItem(selectedItem, telemetryController); | ||
} | ||
}); | ||
}; | ||
|
||
async getChildren(element?: any): Promise<any[]> { | ||
// When no element is present we are at the root. | ||
if (!element) { | ||
const whatsNew = new HelpLinkTreeItem( | ||
'What\'s New', | ||
'https://github.com/mongodb-js/vscode/blob/master/CHANGELOG.md', | ||
'whatsNew', | ||
'megaphone' | ||
); | ||
|
||
const extensionDocs = new HelpLinkTreeItem( | ||
'Extension Documentation', | ||
'https://docs.mongodb.com/mongodb-vscode/', | ||
'extensionDocumentation', | ||
'book' | ||
); | ||
|
||
const mdbDocs = new HelpLinkTreeItem( | ||
'MongoDB Documentation', | ||
'https://docs.mongodb.com/manual/', | ||
'mongoDBDocumentation', | ||
'leaf' | ||
); | ||
|
||
const feedback = new HelpLinkTreeItem( | ||
'Suggest a Feature', | ||
'https://feedback.mongodb.com/forums/929236-mongodb-for-vs-code/', | ||
'feedback', | ||
'lightbulb' | ||
); | ||
|
||
const reportBug = new HelpLinkTreeItem( | ||
'Report a Bug', | ||
'https://github.com/mongodb-js/vscode/issues', | ||
'reportABug', | ||
'report' | ||
); | ||
|
||
const atlas = new HelpLinkTreeItem( | ||
'Create Free Atlas Cluster', | ||
'https://www.mongodb.com/cloud/atlas/register?utm_source=vscode&utm_medium=product&utm_campaign=VS%20code%20extension', | ||
'freeClusterCTA', | ||
'atlas' | ||
); | ||
|
||
return Promise.resolve([ | ||
whatsNew, | ||
extensionDocs, | ||
mdbDocs, | ||
feedback, | ||
reportBug, | ||
atlas | ||
]); | ||
} | ||
|
||
return element.getChildren(); | ||
} | ||
|
||
async onClickHelpItem(helpItem: HelpLinkTreeItem, telemetryController: TelemetryController): Promise<void> { | ||
if (helpItem.contextValue === HELP_LINK_CONTEXT_VALUE) { | ||
telemetryController.trackLinkClicked( | ||
'helpPanel', | ||
helpItem.linkId | ||
); | ||
|
||
await vscode.commands.executeCommand( | ||
'vscode.open', | ||
vscode.Uri.parse(helpItem.url) | ||
); | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -25,7 +25,7 @@ export default class PlaygroundsExplorer { | |
} | ||
}; | ||
|
||
public async activatePlaygroundsTreeView(): Promise<void> { | ||
public activatePlaygroundsTreeView(): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
this.createPlaygroundsTreeView(); | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wonder what will happen if we do not dispose when deactivate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, disposing cleans up the listeners we create in
activateTreeViewEventHandlers
(treeView.onDidChangeSelection
)https://vscode-docs.readthedocs.io/en/stable/extensions/patterns-and-principles/#disposables
I think it's something we want to keep, just to make sure we clean up a bit.