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

feat: adds a hotkey to open dev menu #167

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
"enablement": "!RNIDE.extensionIsActive"
}
],
"keybindings": [
{
"command": "RNIDE.openDevMenu",
"key": "ctrl+alt+z",
"mac": "ctrl+cmd+z"
}
],
watadarkstar marked this conversation as resolved.
Show resolved Hide resolved
"configuration": {
"title": "React Native IDE",
"properties": {
Expand Down
6 changes: 6 additions & 0 deletions packages/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { SidePanelViewProvider } from "./panels/SidepanelViewProvider";
import { PanelLocation } from "./common/WorkspaceConfig";
import { getLaunchConfiguration } from "./utilities/launchConfiguration";
import { getTelemetryReporter } from "./utilities/telemetry";
import { Project } from "./project/project";

const BIN_MODIFICATION_DATE_KEY = "bin_modification_date";
const OPEN_PANEL_ON_ACTIVATION = "open_panel_on_activation";
Expand Down Expand Up @@ -86,6 +87,7 @@ export async function activate(context: ExtensionContext) {
{ webviewOptions: { retainContextWhenHidden: true } }
)
);
context.subscriptions.push(commands.registerCommand("RNIDE.openDevMenu", openDevMenu));
context.subscriptions.push(commands.registerCommand("RNIDE.openPanel", showIDEPanel));
context.subscriptions.push(commands.registerCommand("RNIDE.showPanel", showIDEPanel));
context.subscriptions.push(
Expand Down Expand Up @@ -230,6 +232,10 @@ async function findAppRootFolder() {
return undefined;
}

async function openDevMenu() {
Project.openDevMenu();
watadarkstar marked this conversation as resolved.
Show resolved Hide resolved
}

async function diagnoseWorkspaceStructure() {
const appRootFolder = await configureAppRootFolder();
if (appRootFolder) {
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-extension/src/panels/SidepanelViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SidePanelViewProvider implements WebviewViewProvider, Disposable {
public static readonly viewType = "ReactNativeIDE.view";
public static currentProvider: SidePanelViewProvider | undefined;
private _view: any = null;
private webviewController: any = null;
private webviewController: WebviewController | null = null;
watadarkstar marked this conversation as resolved.
Show resolved Hide resolved

constructor(private readonly context: ExtensionContext) {
SidePanelViewProvider.currentProvider = this;
Expand Down Expand Up @@ -48,7 +48,7 @@ export class SidePanelViewProvider implements WebviewViewProvider, Disposable {
}

if (fileName !== undefined && lineNumber !== undefined) {
SidePanelViewProvider.currentProvider.webviewController.project.startPreview(
SidePanelViewProvider.currentProvider.webviewController?.project.startPreview(
`preview:/${fileName}:${lineNumber}`
);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/vscode-extension/src/project/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ export class Project implements Disposable, MetroDelegate, ProjectInterface {
this.deviceSession?.openNavigation(navigationItemID);
}

public static async openDevMenu() {
if (!Project.currentProject) {
Logger.error("Current project is not defined.");
return;
}
await Project.currentProject?.deviceSession?.openDevMenu();
watadarkstar marked this conversation as resolved.
Show resolved Hide resolved
}

public async openDevMenu() {
await this.deviceSession?.openDevMenu();
}
Expand Down