Skip to content

[dashboard] Next steps nudge for local-preview #11434

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

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 24 additions & 1 deletion components/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import { StartWorkspaceModal } from "./workspaces/StartWorkspaceModal";
import { parseProps } from "./start/StartWorkspace";
import SelectIDEModal from "./settings/SelectIDEModal";
import { StartPage, StartPhase } from "./start/StartPage";
import { isGitpodIo } from "./utils";
import { isGitpodIo, isLocalPreview } from "./utils";
import Alert from "./components/Alert";
import { BlockedRepositories } from "./admin/BlockedRepositories";
import { AppNotifications } from "./AppNotifications";

Expand Down Expand Up @@ -347,6 +348,28 @@ function App() {
<Route>
<div className="container">
<Menu />
{isLocalPreview() && (
<div className="app-container mt-2">
<Alert type="warning" className="app-container rounded-md">
You are using a <b>local preview</b> installation, intended for exploring the product on a
single machine without requiring a Kubernetes cluster.{" "}
<a
className="gp-link hover:text-gray-600"
href="https://www.gitpod.io/community-license?utm_source=local-preview"
>
Request a community license
</a>{" "}
or{" "}
<a
className="gp-link hover:text-gray-600"
href="https://www.gitpod.io/contact/sales?utm_source=local-preview"
>
contact sales
</a>{" "}
to get a professional license for running Gitpod in production.
</Alert>
</div>
)}
<AppNotifications />
<Switch>
<Route path={projectsPathNew} exact component={NewProject} />
Expand Down
10 changes: 7 additions & 3 deletions components/dashboard/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ export function isGitpodIo() {
);
}

export function isLocalPreview() {
return window.location.hostname === "preview.gitpod-self-hosted.com";
}

function trimResource(resource: string): string {
return resource.split('/').filter(Boolean).join('/');
return resource.split("/").filter(Boolean).join("/");
}

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

// Checks if a path is part of a resource.
// E.g. "api/userspace/resource" path is a part of resource "api/userspace"
return resources.map(res => trimmedResource.startsWith(trimResource(res))).some(Boolean)
return resources.map((res) => trimmedResource.startsWith(trimResource(res))).some(Boolean);
}
4 changes: 2 additions & 2 deletions install/preview/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

set -e

# Set Domain to `127-0-0-1.nip.io` if not set
# Set Domain to `preview.gitpod-self-hosted.com` if not set
if [ -z "${DOMAIN}" ]; then
export DOMAIN="127-0-0-1.nip.io"
export DOMAIN="preview.gitpod-self-hosted.com"
fi

# Create a USER_ID to be used everywhere
Expand Down
14 changes: 7 additions & 7 deletions install/preview/manifests/coredns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ metadata:
namespace: kube-system
data:
gitpod.db: |
; 127-0-0-1.nip.io test file
127-0-0-1.nip.io. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600
127-0-0-1.nip.io. IN CNAME proxy.default.svc.cluster.local.
*.127-0-0-1.nip.io. IN CNAME proxy.default.svc.cluster.local.
*.ws.127-0-0-1.nip.io. IN CNAME proxy.default.svc.cluster.local.
; preview.gitpod-self-hosted.com test file
preview.gitpod-self-hosted.com. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600
preview.gitpod-self-hosted.com. IN CNAME proxy.default.svc.cluster.local.
*.preview.gitpod-self-hosted.com. IN CNAME proxy.default.svc.cluster.local.
*.ws.preview.gitpod-self-hosted.com. IN CNAME proxy.default.svc.cluster.local.
Corefile: |
.:53 {
errors
health
ready
# extra configuration for `127-0-0-1.nip.io`
file /etc/coredns/gitpod.db 127-0-0-1.nip.io
# extra configuration for `preview.gitpod-self-hosted.com`
file /etc/coredns/gitpod.db preview.gitpod-self-hosted.com
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
Expand Down