Skip to content

Commit

Permalink
Update plugin webview: Fix open plugin button
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Jan 30, 2025
1 parent 0bac24a commit a1ac8f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
13 changes: 5 additions & 8 deletions src/features/contentCreator/addPluginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class AddPlugin {
<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 @@ -224,9 +224,9 @@ export class AddPlugin {
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 229 in src/features/contentCreator/addPluginPage.ts

View check run for this annotation

Codecov / codecov/patch

src/features/contentCreator/addPluginPage.ts#L229

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

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

View check run for this annotation

Codecov / codecov/patch

src/features/contentCreator/addPluginPage.ts#L346

Added line #L346 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

0 comments on commit a1ac8f2

Please sign in to comment.