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 21 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 @@ -14,6 +14,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",
"classnames": "^2.3.1",
"configcat-js": "^6.0.0",
Expand Down Expand Up @@ -41,6 +42,7 @@
"react-router-dom": "^5.2.0",
"setimmediate": "^1.0.5",
"stream-browserify": "^2.0.1",
"ua-parser-js": "^1.0.36",
"url": "^0.11.1",
"util": "^0.11.1",
"validator": "^13.9.0",
Expand Down
12 changes: 12 additions & 0 deletions components/dashboard/src/icons/Flash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions components/dashboard/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
button:disabled {
@apply cursor-default opacity-50 pointer-events-none;
}
button.reset {
@apply bg-transparent border-none p-0 m-0 text-inherit cursor-pointer focus:outline-none focus:ring;
}

button.gp-link {
@apply bg-transparent hover:bg-transparent p-0 font-normal rounded-none;
Expand Down
97 changes: 97 additions & 0 deletions components/dashboard/src/workspaces/BrowserExtensionBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* 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, useState } from "react";
import UAParser from "ua-parser-js";
import flashIcon from "../icons/Flash.svg";

interface 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",
},
};

interface BrowserExtensionBannerProps {
parser?: UAParser;
}

export function BrowserExtensionBanner({ parser = new UAParser() }: BrowserExtensionBannerProps) {
filiptronicek marked this conversation as resolved.
Show resolved Hide resolved
const [isVisible, setIsVisible] = useState(false);

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

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

const handleClose = () => {
localStorage.setItem("browser-extension-banner-dismissed", "true");
setIsVisible(false);
};

if (!isVisible) {
return null;
}

const browserName = parser.getBrowser().name?.toLowerCase();
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="hidden p-4 sm:block sm:absolute sm:bottom-2 sm:left-2">
<div className="grid h-28 w-72 grid-cols-12 items-end gap-x-2 rounded-xl border-2 border-dashed border-[#dadada] bg-[#fafaf9] dark:bg-gray-800 dark:border-gray-600 p-4">
<div className="col-span-2">
<img src={flashIcon} alt="" className="h-8 w-8" />
</div>

<div className="col-span-9">
<p className="text-sm font-medium leading-5 text-[#666564]">
Open workspaces directly from your source control repository.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we know what SCMs the user has registered the message would be clearer if it would say:
Open workspaces directly from github.com.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, think that it will make it clearer, and we can leave this as the fallback.

cc @loujaybee?

</p>
</div>
<div className="col-span-1 flex justify-end items-start h-full pt-1">
<button className="reset right-8 top-6 text-gray-500 dark:text-gray-200" onClick={handleClose}>
filiptronicek marked this conversation as resolved.
Show resolved Hide resolved
&#10005;
</button>
</div>
<div className="col-span-2"></div>

<div className="col-span-10">
<a
href={browserOption.url}
className="text-sm font-semibold text-blue-500"
target="_blank"
rel="noreferrer"
>
Try the browser extension →
</a>
</div>
</div>
</section>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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";

export function CreateWorkspacePage() {
Expand Down Expand Up @@ -359,7 +360,7 @@ export function CreateWorkspacePage() {
}

return (
<div className="flex flex-col mt-32 mx-auto ">
<div className="flex flex-col mt-32 mx-auto">
<div className="flex flex-col max-h-screen max-w-lg mx-auto items-center w-full">
<Heading1>New Workspace</Heading1>
<div className="text-gray-500 text-center text-base">
Expand Down Expand Up @@ -441,6 +442,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 @@ -3667,6 +3667,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 @@ -14552,6 +14557,11 @@ typescript@~4.2.3:
resolved "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==

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