-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* added components tree view and made minor changes to namings + return types * added localize() usage and reworked usage of dapr client * minor refactoring * removed token Co-authored-by: Phillip Hoff <phillip@orst.edu>
- Loading branch information
1 parent
01f5fda
commit 6aea135
Showing
7 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,41 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import * as vscode from 'vscode'; | ||
import * as nls from 'vscode-nls'; | ||
import TreeNode from "../treeNode"; | ||
import { DaprApplication } from '../../services/daprApplicationProvider'; | ||
import DaprMetadataNode from './daprMetadataNode'; | ||
import { DaprClient } from '../../services/daprClient'; | ||
import { getLocalizationPathForFile } from '../../util/localization'; | ||
|
||
const localize = nls.loadMessageBundle(getLocalizationPathForFile(__filename)); | ||
|
||
|
||
export default class DaprComponentsNode implements TreeNode { | ||
constructor(private readonly application: DaprApplication, private readonly daprClient: DaprClient) { | ||
} | ||
|
||
getTreeItem(): Promise<vscode.TreeItem> { | ||
const label = localize('views.applications.daprComponentsNode.componentNode', 'Components'); | ||
|
||
const item = new vscode.TreeItem(label, vscode.TreeItemCollapsibleState.Collapsed); | ||
|
||
item.contextValue = 'components'; | ||
|
||
item.iconPath = new vscode.ThemeIcon('archive'); | ||
|
||
return Promise.resolve(item); | ||
} | ||
|
||
async getChildren(): Promise<TreeNode[]> { | ||
const label = localize('views.applications.daprComponentsNode.noComponents', 'There are no components in use.'); | ||
const responseData = await this.daprClient.getMetadata(this.application); | ||
const components = responseData.components; | ||
if(components.length > 0) { | ||
return components.map(comp => new DaprMetadataNode(comp.name, 'database')); | ||
} | ||
return [new DaprMetadataNode(label, 'warning')]; | ||
} | ||
} | ||
|
This file contains 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,22 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import * as vscode from 'vscode'; | ||
import TreeNode from "../treeNode"; | ||
|
||
export default class DaprMetadataNode implements TreeNode { | ||
constructor(private readonly metadata: string, private readonly themeIconId: string) { | ||
} | ||
|
||
getTreeItem(): Promise<vscode.TreeItem> { | ||
const item = new vscode.TreeItem(this.metadata); | ||
|
||
item.contextValue = 'metadata'; | ||
|
||
item.iconPath = new vscode.ThemeIcon(this.themeIconId); | ||
|
||
return Promise.resolve(item); | ||
} | ||
|
||
|
||
} |
This file contains 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