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

Add feature to be able to set a device as the current active device via the Device tree view. Also added command to clear the active device. #597

Merged
merged 2 commits into from
Oct 2, 2024
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
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,12 @@
"description": "Clear the BrightScript extension's global state.",
"category": "Brightscript"
},
{
"command": "extension.brightscript.clearActiveDevice",
"title": "Clear Active Device",
"description": "Clear the BrightScript extension's active device.",
"category": "Brightscript"
},
{
"command": "extension.brightscript.toggleXML",
"title": "Toggle XML/BRS",
Expand Down
17 changes: 17 additions & 0 deletions src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,23 @@ export class BrightScriptCommands {
}
});

this.registerCommand('setActiveDevice', async (device: string) => {
if (!device) {
device = await this.userInputManager.promptForHost();
}
if (!device) {
throw new Error('Tried to set active device but failed.');
} else {
await this.context.workspaceState.update('remoteHost', device);
await vscode.window.showInformationMessage(`BrightScript Language extension active device set to: ${device}`);
}
});

this.registerCommand('clearActiveDevice', async () => {
await this.context.workspaceState.update('remoteHost', '');
await vscode.window.showInformationMessage('BrightScript Language extension active device cleared');
});

this.registerCommand('showReleaseNotes', () => {
this.whatsNewManager.showReleaseNotes();
});
Expand Down
14 changes: 14 additions & 0 deletions src/viewProviders/OnlineDevicesViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ export class OnlineDevicesViewProvider implements vscode.TreeDataProvider<vscode
})
);

result.unshift(
this.createDeviceInfoTreeItem({
label: '⭐ Set as Active Device',
parent: element,
collapsibleState: vscode.TreeItemCollapsibleState.None,
tooltip: 'Set as active device',
command: {
command: 'extension.brightscript.setActiveDevice',
title: 'Set Active Device',
arguments: [device.ip]
}
})
);

if (semver.satisfies(element.details['software-version'], '>=11')) {
// TODO: add ECP system hooks here in the future (like registry call, etc...)
result.unshift(
Expand Down