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

[WIP] Update plugin webview: Fix open plugin button #1755

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
13 changes: 5 additions & 8 deletions src/features/contentCreator/addPluginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<span class="codicon codicon-clear-all"></span>
&nbsp; Clear Logs
</vscode-button>
<vscode-button id="open-folder-button" form="init-form" disabled>
<vscode-button id="open-file-button" form="init-form" disabled>
<span class="codicon codicon-go-to-file"></span>
&nbsp; Open Plugin
</vscode-button>
Expand Down Expand Up @@ -225,9 +225,9 @@
await this.runAddCommand(payload, webview);
return;

case "init-open-scaffolded-folder":
case "init-open-scaffolded-file":
payload = message.payload;
await this.openFolderInWorkspace(
await this.openFileInWorkspace(

Check warning on line 230 in src/features/contentCreator/addPluginPage.ts

View check run for this annotation

Codecov / codecov/patch

src/features/contentCreator/addPluginPage.ts#L230

Added line #L230 was not covered by tests
payload.projectUrl,
payload.pluginName,
payload.pluginType,
Expand Down Expand Up @@ -344,21 +344,18 @@
`Open plugin file ↗`,
);
if (selection === "Open plugin file ↗") {
this.openFolderInWorkspace(destinationPathUrl, pluginName, pluginType);
this.openFileInWorkspace(destinationPathUrl, pluginName, pluginType);

Check warning on line 347 in src/features/contentCreator/addPluginPage.ts

View check run for this annotation

Codecov / codecov/patch

src/features/contentCreator/addPluginPage.ts#L347

Added line #L347 was not covered by tests
}
}
}

public async openFolderInWorkspace(
public async openFileInWorkspace(
folderUrl: string,
pluginName: string,
pluginType: string,
) {
const folderUri = vscode.Uri.parse(expandPath(folderUrl));

// add folder to a new workspace
// vscode.workspace.updateWorkspaceFolders(0, 1, { uri: folderUri });

if (vscode.workspace.workspaceFolders?.length === 0) {
vscode.workspace.updateWorkspaceFolders(0, null, { uri: folderUri });
} else {
Expand Down
18 changes: 9 additions & 9 deletions src/webview/apps/contentCreator/addPluginPageApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let initCollectionPathElement: HTMLElement;

let initLogsTextArea: TextArea;
let initClearLogsButton: Button;
let initOpenScaffoldedFolderButton: Button;
let initOpenPluginFileButton: Button;

let projectUrl = "";

Expand All @@ -57,8 +57,8 @@ function main() {

initLogsTextArea = document.getElementById("log-text-area") as TextArea;
initClearLogsButton = document.getElementById("clear-logs-button") as Button;
initOpenScaffoldedFolderButton = document.getElementById(
"open-folder-button",
initOpenPluginFileButton = document.getElementById(
"open-file-button",
) as Button;

pluginNameTextField.addEventListener("input", toggleCreateButton);
Expand All @@ -72,9 +72,9 @@ function main() {
initClearButton.addEventListener("click", handleInitClearClick);

initClearLogsButton.addEventListener("click", handleInitClearLogsClick);
initOpenScaffoldedFolderButton.addEventListener(
initOpenPluginFileButton.addEventListener(
"click",
handleInitOpenScaffoldedFolderClick,
handleInitOpenPluginFileClick,
);

initCollectionPathDiv = document.getElementById("full-collection-path");
Expand Down Expand Up @@ -183,9 +183,9 @@ function handleInitCreateClick() {
message.arguments.status &&
message.arguments.status === "passed"
) {
initOpenScaffoldedFolderButton.disabled = false;
initOpenPluginFileButton.disabled = false;
} else {
initOpenScaffoldedFolderButton.disabled = true;
initOpenPluginFileButton.disabled = true;
}

projectUrl = message.arguments.projectUrl
Expand All @@ -204,9 +204,9 @@ function handleInitClearLogsClick() {
initLogsTextArea.value = "";
}

function handleInitOpenScaffoldedFolderClick() {
function handleInitOpenPluginFileClick() {
vscode.postMessage({
command: "init-open-scaffolded-folder",
command: "init-open-scaffolded-file",
payload: {
projectUrl: projectUrl,
},
Expand Down