Skip to content

Commit

Permalink
Merge pull request #1490 from posit-dev/dotnomad/open-action
Browse files Browse the repository at this point in the history
Open Project Files on click
  • Loading branch information
dotNomad authored May 1, 2024
2 parents 1fd25cc + b14d980 commit 4c31e4f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
14 changes: 12 additions & 2 deletions extensions/vscode/src/types/messages/webviewToHostMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum WebviewToHostMessageType {
NAVIGATE = "navigate",
SAVE_DEPLOYMENT_BUTTON_EXPANDED = "saveDeploymentButtonExpanded",
SAVE_SELECTION_STATE = "saveSelectionState",
VSCODE_OPEN = "vscode.open",
}

export type AnyWebviewToHostMessage<
Expand All @@ -32,7 +33,8 @@ export type WebviewToHostMessage =
| NewConfigurationMsg
| NavigateMsg
| SaveDeploymentButtonExpandedMsg
| SaveSelectionStatedMsg;
| SaveSelectionStatedMsg
| VsCodeOpenMsg;

export function isWebviewToHostMessage(msg: any): msg is WebviewToHostMessage {
return (
Expand All @@ -43,7 +45,8 @@ export function isWebviewToHostMessage(msg: any): msg is WebviewToHostMessage {
msg.kind === WebviewToHostMessageType.NEW_CONFIGURATION ||
msg.kind === WebviewToHostMessageType.NEW_DEPLOYMENT ||
msg.kind === WebviewToHostMessageType.SAVE_DEPLOYMENT_BUTTON_EXPANDED ||
msg.kind === WebviewToHostMessageType.SAVE_SELECTION_STATE
msg.kind === WebviewToHostMessageType.SAVE_SELECTION_STATE ||
msg.kind === WebviewToHostMessageType.VSCODE_OPEN
);
}

Expand Down Expand Up @@ -85,3 +88,10 @@ export type SaveSelectionStatedMsg = AnyWebviewToHostMessage<
state: HomeViewState;
}
>;

export type VsCodeOpenMsg = AnyWebviewToHostMessage<
WebviewToHostMessageType.VSCODE_OPEN,
{
uri: string;
}
>;
5 changes: 5 additions & 0 deletions extensions/vscode/src/views/homeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export class HomeViewProvider implements WebviewViewProvider {
return await this._onSaveDeploymentButtonExpandedMsg(msg);
case WebviewToHostMessageType.SAVE_SELECTION_STATE:
return await this._onSaveSelectionState(msg);
case WebviewToHostMessageType.VSCODE_OPEN:
return commands.executeCommand(
"vscode.open",
Uri.parse(msg.content.uri),
);
default:
throw new Error(
`Error: _onConduitMessage unhandled msg: ${JSON.stringify(msg)}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<template #default="{ indentLevel }">
<TreeItem
v-for="file in home.includedFiles"
@click="
sendMsg({
kind: WebviewToHostMessageType.VSCODE_OPEN,
content: { uri: file.abs },
})
"
:key="file.id"
:title="file.base"
codicon="codicon-debug-stackframe-dot"
Expand All @@ -40,6 +46,12 @@
<template #default="{ indentLevel }">
<TreeItem
v-for="file in home.excludedFiles"
@click="
sendMsg({
kind: WebviewToHostMessageType.VSCODE_OPEN,
content: { uri: file.abs },
})
"
:key="file.id"
:title="file.base"
codicon="codicon-debug-stackframe-dot"
Expand All @@ -65,12 +77,15 @@
import { ref } from "vue";
import { FileMatchSource } from "../../../../../src/api";
import { WebviewToHostMessageType } from "../../../../../src/types/messages/webviewToHostMessages";
import TreeItem from "src/components/TreeItem.vue";
import TreeSection from "src/components/TreeSection.vue";
import { useHomeStore } from "src/stores/home";
import { useHostConduitService } from "src/HostConduitService";
const home = useHomeStore();
const { sendMsg } = useHostConduitService();
const includedExpanded = ref(true);
const excludedExpanded = ref(true);
Expand Down

0 comments on commit 4c31e4f

Please sign in to comment.