Skip to content

Commit

Permalink
Communicate with Gitpod instances
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Sep 25, 2023
1 parent 4d05d61 commit 28c4f0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/button/button-contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export const isSiteSuitable = (): boolean => {
return allowedApps.includes(appName);
}

/**
* Checks if the current site is a Gitpod instance.
*/
export const isSiteGitpod = (): boolean => {
return !!document.head.querySelector("meta[name=Gitpod]");
}

export interface ButtonContributionParams {
/**
* A unique id for the button contribution. Used to identify the button in the UI.
Expand Down
5 changes: 4 additions & 1 deletion src/contents/button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PlasmoCSConfig, PlasmoGetInlineAnchor } from "plasmo";
import cssText from "data-text:../button/button.css"
import { buttonContributions, type ButtonContributionParams, isSiteSuitable } from "../button/button-contributions";
import { buttonContributions, type ButtonContributionParams, isSiteSuitable, isSiteGitpod } from "../button/button-contributions";
import { GitpodButton } from "../button/button";
import { type ReactElement } from "react";
import React from "react";
Expand Down Expand Up @@ -30,6 +30,9 @@ class ButtonContributionManager {
const isSuitable = isSiteSuitable();
if (!isSuitable) {
this._disabled = true;
if (isSiteGitpod()) {
localStorage.setItem("browser-extension-installed", "true");
}
}
}

Expand Down

0 comments on commit 28c4f0a

Please sign in to comment.