-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Closed
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b84d909
Browser Extension in-app banner
filiptronicek 3906bbf
add icons
filiptronicek eb36507
Prevent undefined browsers
filiptronicek d70d278
Merge branch 'main' into ft/browser-extension-nudge
filiptronicek 9978c61
Local storage control
filiptronicek 0af1e90
use sessionstorage
filiptronicek 969510d
Tweak colors and hide on small viewports
filiptronicek fb2d0a7
Dismiss button
filiptronicek d324f0c
Universal icon
filiptronicek 9158eb9
Merge branch 'main' into ft/browser-extension-nudge
filiptronicek 7be56cb
fix icon
filiptronicek a5ebd3e
reset button
filiptronicek c80b0f3
Remove unused class
filiptronicek 6ad0f38
Fix close button?
filiptronicek 9bac699
Modify layout
filiptronicek 32f71f2
add missing browsers
filiptronicek 8734871
Fix extra whitespace
filiptronicek 15448ca
do not show when autostarting
filiptronicek 72b17ce
remove duplicate type dep
filiptronicek c574479
Prevent flashing
filiptronicek d879903
Apply new copy
filiptronicek ea80759
Address review comments
filiptronicek 0dc30e2
Fix svg path
filiptronicek 3b9f2fa
fix colors
filiptronicek ffd5481
Layout
filiptronicek 00f6553
Merge branch 'main' into ft/browser-extension-nudge
filiptronicek 9a04142
minor changis
filiptronicek eb69108
🤷♂️
filiptronicek fba7bae
Fix spacing and max width
filiptronicek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
components/dashboard/src/workspaces/BrowserExtensionBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* 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"; | ||
import flashIcon from "../icons/Flash.svg"; | ||
import { ReactComponent as CloseIcon } from "../images/x.svg"; | ||
import classNames from "classnames"; | ||
|
||
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", | ||
}, | ||
}; | ||
|
||
export function BrowserExtensionBanner() { | ||
const parser = useMemo(() => new UAParser(), []); | ||
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 content-center 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 self-center"> | ||
<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. | ||
</p> | ||
</div> | ||
<div className="col-span-1 flex justify-end items-start h-full pt-1"> | ||
<button | ||
className={classNames( | ||
"cursor-pointer p-2 ml-2 -mt-1", | ||
"bg-transparent hover:bg-transparent", | ||
"text-gray-500 hover:text-gray-300 dark:text-gray-200 dark:hover:text-gray-600", | ||
)} | ||
onClick={handleClose} | ||
> | ||
<CloseIcon /> | ||
</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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?