Skip to content

Commit

Permalink
Added improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
nang-dev committed Nov 2, 2024
1 parent 26ae331 commit 1e18b2d
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
25 changes: 25 additions & 0 deletions src/vs/workbench/browser/parts/overlay/pearOverlayActions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { registerAction2, Action2 } from "vs/platform/actions/common/actions";
import { ServicesAccessor } from "vs/platform/instantiation/common/instantiation";
import { IPearOverlayService } from "./pearOverlayService";
Expand Down Expand Up @@ -45,5 +49,26 @@ export class TogglePearOverlayAction extends Action2 {
}
}

class UpdatePathnameAction extends Action2 {
static readonly ID = "workbench.action.updatePathname";

constructor() {
super({
id: UpdatePathnameAction.ID,
title: {
value: "Update PearAI Pathname",
original: "Update PearAI Pathname",
},
f1: true,
});
}

run(accessor: ServicesAccessor, pathname: string): void {
const pearaiOverlayService = accessor.get(IPearOverlayService);
pearaiOverlayService.updatePathname(pathname);
}
}

registerAction2(TogglePearOverlayAction);
registerAction2(ClosePearOverlayAction);
registerAction2(UpdatePathnameAction);
15 changes: 15 additions & 0 deletions src/vs/workbench/browser/parts/overlay/pearOverlayPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ export class PearOverlayPart extends Part {

private state: "loading" | "open" | "closed" = "loading";

private _pathname: string = "";

get pathname(): string {
return this._pathname;
}

set pathname(value: string) {
this._pathname = value;
}

constructor(
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
Expand Down Expand Up @@ -226,8 +236,13 @@ export class PearOverlayPart extends Part {
container.style.borderRadius = "12px";
container.style.backgroundColor = "var(--vscode-editor-background)";
container.style.zIndex = "1000";
console.dir("IM HERE I GOT OPENE");
console.dir(this._pathname);
this.fullScreenOverlay?.addEventListener("click", () => {
// If we are in the tutorial, don't close
console.dir("IM HERE I GOT CLICEKD");
// print the _pathname
console.dir(this._pathname);
this.close();
});

Expand Down
52 changes: 48 additions & 4 deletions src/vs/workbench/browser/parts/overlay/pearOverlayService.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import {
registerSingleton,
InstantiationType,
Expand Down Expand Up @@ -43,6 +47,16 @@ export interface IPearOverlayService extends IDisposable {
* Returns true if the PearAI popup is visible.
*/
isVisible(): boolean;

/**
* Updates the pathname for the PearAI popup.
*/
updatePathname(pathname: string): void;

/**
* Gets the current pathname for the PearAI popup.
*/
getPathname(): string;
}

export class PearOverlayService
Expand All @@ -53,6 +67,8 @@ export class PearOverlayService

private readonly _pearOverlayPart: PearOverlayPart;

private _pathname: string = "";

Check failure on line 70 in src/vs/workbench/browser/parts/overlay/pearOverlayService.ts

View workflow job for this annotation

GitHub Actions / hygiene

'_pathname' is declared but its value is never read.

constructor(
@IInstantiationService
private readonly instantiationService: IInstantiationService,
Expand Down Expand Up @@ -83,25 +99,37 @@ export class PearOverlayService

private registerCommands(): void {
// Register commands for external use e.g. in pearai submodule
CommandsRegistry.registerCommand('pearai.isOverlayVisible', (accessor) => {
CommandsRegistry.registerCommand("pearai.isOverlayVisible", (accessor) => {
const overlayService = accessor.get(IPearOverlayService);
return overlayService.isVisible();
});

CommandsRegistry.registerCommand('pearai.showOverlay', (accessor) => {
CommandsRegistry.registerCommand("pearai.showOverlay", (accessor) => {
const overlayService = accessor.get(IPearOverlayService);
overlayService.show();
});

CommandsRegistry.registerCommand('pearai.hideOverlay', (accessor) => {
CommandsRegistry.registerCommand("pearai.hideOverlay", (accessor) => {
const overlayService = accessor.get(IPearOverlayService);
overlayService.hide();
});

CommandsRegistry.registerCommand('pearai.toggleOverlay', (accessor) => {
CommandsRegistry.registerCommand("pearai.toggleOverlay", (accessor) => {
const overlayService = accessor.get(IPearOverlayService);
overlayService.toggle();
});
CommandsRegistry.registerCommand(
"pearai.updatePathname",
(accessor, pathname) => {
const overlayService = accessor.get(IPearOverlayService);
console.dir("HOLY SHIT IM IN REGISTER COMMAND");
console.dir(pathname);
if (typeof pathname === "string") {
console.dir("HOLY SHIT IM UPDATEING");
overlayService.updatePathname(pathname);
}
},
);
}

get pearOverlayPart(): PearOverlayPart {
Expand Down Expand Up @@ -129,6 +157,22 @@ export class PearOverlayService
return this._pearOverlayPart.isVisible();
}

/**
* Updates the pathname for the PearAI popup.
*/
updatePathname(pathname: string): void {
console.dir("8888IMSETTING PATHNAME");
this._pearOverlayPart.pathname = pathname;
console.dir("8888IMSETTING PATHNAME SET");
console.dir(this._pearOverlayPart.pathname);
}

/**
* Gets the current pathname for the PearAI popup.
*/
getPathname(): string {
return this._pearOverlayPart.pathname;
}
}

registerSingleton(
Expand Down

0 comments on commit 1e18b2d

Please sign in to comment.