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

Browser Extension in-app banner #18796

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b84d909
Browser Extension in-app banner
filiptronicek Sep 25, 2023
3906bbf
add icons
filiptronicek Sep 25, 2023
eb36507
Prevent undefined browsers
filiptronicek Sep 25, 2023
d70d278
Merge branch 'main' into ft/browser-extension-nudge
filiptronicek Sep 25, 2023
9978c61
Local storage control
filiptronicek Sep 25, 2023
0af1e90
use sessionstorage
filiptronicek Sep 25, 2023
969510d
Tweak colors and hide on small viewports
filiptronicek Sep 26, 2023
fb2d0a7
Dismiss button
filiptronicek Sep 26, 2023
d324f0c
Universal icon
filiptronicek Oct 1, 2023
9158eb9
Merge branch 'main' into ft/browser-extension-nudge
filiptronicek Oct 1, 2023
7be56cb
fix icon
filiptronicek Oct 1, 2023
a5ebd3e
reset button
filiptronicek Oct 1, 2023
c80b0f3
Remove unused class
filiptronicek Oct 1, 2023
6ad0f38
Fix close button?
filiptronicek Oct 1, 2023
9bac699
Modify layout
filiptronicek Oct 1, 2023
32f71f2
add missing browsers
filiptronicek Oct 1, 2023
8734871
Fix extra whitespace
filiptronicek Oct 1, 2023
15448ca
do not show when autostarting
filiptronicek Oct 1, 2023
72b17ce
remove duplicate type dep
filiptronicek Oct 1, 2023
c574479
Prevent flashing
filiptronicek Oct 1, 2023
d879903
Apply new copy
filiptronicek Oct 2, 2023
ea80759
Address review comments
filiptronicek Oct 2, 2023
0dc30e2
Fix svg path
filiptronicek Oct 2, 2023
3b9f2fa
fix colors
filiptronicek Oct 2, 2023
ffd5481
Layout
filiptronicek Oct 2, 2023
00f6553
Merge branch 'main' into ft/browser-extension-nudge
filiptronicek Apr 22, 2024
9a04142
minor changis
filiptronicek Apr 22, 2024
eb69108
🤷‍♂️
filiptronicek Apr 22, 2024
fba7bae
Fix spacing and max width
filiptronicek Apr 22, 2024
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
2 changes: 2 additions & 0 deletions components/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@tanstack/react-query-devtools": "^4.29.19",
"@tanstack/react-query-persist-client": "^4.29.19",
"@types/react-datepicker": "^4.8.0",
"@types/ua-parser-js": "^0.7.37",
"buffer": "^4.3.0",
"class-variance-authority": "^0.7.0",
"classnames": "^2.3.1",
Expand Down Expand Up @@ -54,6 +55,7 @@
"react-router-dom": "^5.2.0",
"setimmediate": "^1.0.5",
"stream-browserify": "^2.0.1",
"ua-parser-js": "^1.0.36",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.7",
"url": "^0.11.1",
Expand Down
77 changes: 77 additions & 0 deletions components/dashboard/src/workspaces/BrowserExtensionBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License.AGPL.txt in the project root for license information.
*/

import { useEffect, useMemo, useState } from "react";
import UAParser from "ua-parser-js";

type BrowserOption = {
aliases?: string[];
url: string;
};

const installationOptions: Record<string, BrowserOption> = {
firefox: {
url: "https://addons.mozilla.org/en-US/firefox/addon/gitpod/",
},
chrome: {
aliases: ["edge", "brave", "chromium", "vivaldi", "opera"],
url: "https://chrome.google.com/webstore/detail/gitpod-always-ready-to-co/dodmmooeoklaejobgleioelladacbeki",
},
};

export function BrowserExtensionBanner() {
const parser = useMemo(() => new UAParser(), []);
const browserName = useMemo(() => parser.getBrowser().name?.toLowerCase(), [parser]);

const [isVisible, setIsVisible] = useState(false);

useEffect(() => {
const installedOrDismissed =
sessionStorage.getItem("browser-extension-installed") ||
localStorage.getItem("browser-extension-banner-dismissed");

setIsVisible(!installedOrDismissed);
}, []);

// Todo: Implement the x button
// const handleClose = () => {
// localStorage.setItem("browser-extension-banner-dismissed", "true");
// setIsVisible(false);
// };

if (!isVisible) {
return null;
}

if (!browserName) {
return null;
}

let browserOption: BrowserOption | undefined = installationOptions[browserName];
if (!browserOption) {
browserOption = Object.values(installationOptions).find(
(opt) => opt.aliases && opt.aliases.includes(browserName),
);
if (!browserOption) {
return null;
}
}

return (
<section className="sm:flex justify-between border-2 rounded-xl m-4 hidden max-w-xl mt-4">
<div className="flex flex-col gap-1 py-4 px-2 justify-center">
<span className="text-lg font-semibold">Open from Github</span>
<span>
<a href={browserOption.url} className="gp-link">
Install the Gitpod extension
</a>
to launch workspaces from Github.
</span>
</div>
<img alt="A button that says Gitpod" src="https://picsum.photos/151/88" />
</section>
);
}
2 changes: 2 additions & 0 deletions components/dashboard/src/workspaces/CreateWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { StartWorkspaceOptions } from "../start/start-workspace-options";
import { UserContext, useCurrentUser } from "../user-context";
import { SelectAccountModal } from "../user-settings/SelectAccountModal";
import { settingsPathIntegrations } from "../user-settings/settings.routes";
import { BrowserExtensionBanner } from "./BrowserExtensionBanner";
import { WorkspaceEntry } from "./WorkspaceEntry";
import { AuthProviderType } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb";
import {
Expand Down Expand Up @@ -565,6 +566,7 @@ export function CreateWorkspacePage() {
)}
</div>
</div>
{!autostart && <BrowserExtensionBanner />}
</div>
);
}
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4076,6 +4076,11 @@
resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.3.tgz#a136f83b0758698df454e328759dbd3d44555311"
integrity sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==

"@types/ua-parser-js@^0.7.37":
version "0.7.37"
resolved "https://registry.yarnpkg.com/@types/ua-parser-js/-/ua-parser-js-0.7.37.tgz#2e45bf948a6a94391859a1b0682104ae3c13ba72"
integrity sha512-4sOxS3ZWXC0uHJLYcWAaLMxTvjRX3hT96eF4YWUh1ovTaenvibaZOE5uXtIp4mksKMLRwo7YDiCBCw6vBiUPVg==

"@types/[email protected]", "@types/uuid@^8.3.1":
version "8.3.1"
resolved "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz"
Expand Down Expand Up @@ -15068,6 +15073,11 @@ typescript@^4.2.4, typescript@~4.4.2, typescript@~4.4.4:
resolved "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz"
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==

ua-parser-js@^1.0.36:
version "1.0.36"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.36.tgz#a9ab6b9bd3a8efb90bb0816674b412717b7c428c"
integrity sha512-znuyCIXzl8ciS3+y3fHJI/2OhQIXbXw9MWC/o3qwyR+RGppjZHrM27CGFSKCJXi2Kctiz537iOu2KnXs1lMQhw==

uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
Expand Down
Loading