Skip to content

Commit 62b0303

Browse files
committed
[local-preview] Add Website Nudge
Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent c3bac15 commit 62b0303

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

components/dashboard/src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { StartWorkspaceModal } from "./workspaces/StartWorkspaceModal";
4747
import { parseProps } from "./start/StartWorkspace";
4848
import SelectIDEModal from "./settings/SelectIDEModal";
4949
import { StartPage, StartPhase } from "./start/StartPage";
50-
import { isGitpodIo } from "./utils";
50+
import { isGitpodIo, isLocalPreview } from "./utils";
5151
import { BlockedRepositorySettings } from "./admin/BlockedRepositorySettings";
5252

5353
const Setup = React.lazy(() => import(/* webpackPrefetch: true */ "./Setup"));
@@ -277,6 +277,11 @@ function App() {
277277
return <div></div>;
278278
}
279279

280+
if (isLocalPreview()) {
281+
window.location.host = "www.gitpod.io";
282+
return <div></div>;
283+
}
284+
280285
if (isGitpodIo() && window.location.pathname === "/" && window.location.hash === "" && !loading && !user) {
281286
if (!GitpodCookie.isPresent(document.cookie)) {
282287
window.location.href = `https://www.gitpod.io`;

components/dashboard/src/Menu.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import FeedbackFormModal from "./feedback-form/FeedbackModal";
2828
import { inResource, isGitpodIo } from "./utils";
2929
import { FeatureFlagContext } from "./contexts/FeatureFlagContext";
3030
import { getExperimentsClient } from "./experiments/client";
31+
import Alert from "./components/Alert";
32+
import { isLocalPreview } from "./utils";
3133

3234
interface Entry {
3335
title: string;
@@ -112,6 +114,8 @@ export default function Menu() {
112114
const isWorkspacesUI = inResource(location.pathname, ["workspaces"]);
113115
const isAdminUI = inResource(window.location.pathname, ["admin"]);
114116

117+
const isLP = isLocalPreview();
118+
115119
const [teamMembers, setTeamMembers] = useState<Record<string, TeamMemberInfo[]>>({});
116120
useEffect(() => {
117121
if (!teams) {
@@ -489,6 +493,12 @@ export default function Menu() {
489493
))}
490494
</nav>
491495
)}
496+
{isLP && (
497+
<Alert type="warning" className="mt-4 w-96">
498+
Visit https://www.gitpod.io/community-license?utm_source=local-preview for next steps on running
499+
a Production version of Gitpod
500+
</Alert>
501+
)}
492502
</header>
493503
<Separator />
494504
</>

components/dashboard/src/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ export function isGitpodIo() {
5858
);
5959
}
6060

61+
export function isLocalPreview() {
62+
return window.location.hostname.endsWith("nip.io");
63+
}
64+
6165
function trimResource(resource: string): string {
62-
return resource.split('/').filter(Boolean).join('/');
66+
return resource.split("/").filter(Boolean).join("/");
6367
}
6468

6569
// Returns 'true' if a 'pathname' is a part of 'resources' provided.
@@ -69,9 +73,9 @@ function trimResource(resource: string): string {
6973
// 'pathname' arg can be provided via `location.pathname`.
7074
export function inResource(pathname: string, resources: string[]): boolean {
7175
// Removes leading and trailing '/'
72-
const trimmedResource = trimResource(pathname)
76+
const trimmedResource = trimResource(pathname);
7377

7478
// Checks if a path is part of a resource.
7579
// E.g. "api/userspace/resource" path is a part of resource "api/userspace"
76-
return resources.map(res => trimmedResource.startsWith(trimResource(res))).some(Boolean)
80+
return resources.map((res) => trimmedResource.startsWith(trimResource(res))).some(Boolean);
7781
}

0 commit comments

Comments
 (0)