Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/index.tsx
2498 views
1
/**
2
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
// this should stay at the top to enable monitoring as soon as possible
8
import "./service/metrics";
9
10
import "setimmediate"; // important!, required by vscode-jsonrpc
11
import dayjs from "dayjs";
12
import duration from "dayjs/plugin/duration";
13
import relativeTime from "dayjs/plugin/relativeTime";
14
import utc from "dayjs/plugin/utc";
15
import React from "react";
16
import ReactDOM from "react-dom";
17
import { BrowserRouter } from "react-router-dom";
18
import { RootAppRouter } from "./App";
19
import { QueryErrorBoundary } from "./components/error-boundaries/QueryErrorBoundary";
20
import { ReloadPageErrorBoundary } from "./components/error-boundaries/ReloadPageErrorBoundary";
21
import { ToastContextProvider } from "./components/toasts/Toasts";
22
import { ConfettiContextProvider } from "./contexts/ConfettiContext";
23
import { setupQueryClientProvider } from "./data/setup";
24
import "./index.css";
25
import { PaymentContextProvider } from "./payment-context";
26
import { ThemeContextProvider } from "./theme-context";
27
import { UserContextProvider } from "./user-context";
28
import { getURLHash, isGitpodIo, isWebsiteSlug } from "./utils";
29
30
const bootApp = () => {
31
// gitpod.io specific boot logic
32
if (isGitpodIo()) {
33
// Redirect to www website for any website slugs
34
if (isWebsiteSlug(window.location.pathname)) {
35
window.location.host = "www.gitpod.io";
36
return;
37
}
38
}
39
40
// Normalize github.dev urls to github.com
41
const hash = getURLHash();
42
if (/^(https:\/\/)?github\.dev\//i.test(hash)) {
43
window.location.hash = hash.replace(/^(https:\/\/)?github\.dev\//i, "https://github.com/");
44
} else if (/^([^/]+?=[^/]*?|prebuild)\/(https:\/\/)?github\.dev\//i.test(hash)) {
45
window.location.hash = hash.replace(
46
/^([^/]+?=[^/]*?|prebuild)\/(https:\/\/)?github\.dev\//i,
47
"$1/https://github.com/",
48
);
49
}
50
51
const GitpodQueryClientProvider = setupQueryClientProvider();
52
53
// Configure libraries
54
dayjs.extend(relativeTime);
55
dayjs.extend(utc);
56
dayjs.extend(duration);
57
58
// Render the App
59
ReactDOM.render(
60
<React.StrictMode>
61
<ThemeContextProvider>
62
<ReloadPageErrorBoundary>
63
<BrowserRouter>
64
<GitpodQueryClientProvider>
65
{/* This needs to be inside of the GitpodQueryClientProvider so it can reset queries if needed */}
66
<QueryErrorBoundary>
67
<ConfettiContextProvider>
68
<ToastContextProvider>
69
<UserContextProvider>
70
<PaymentContextProvider>
71
<RootAppRouter />
72
</PaymentContextProvider>
73
</UserContextProvider>
74
</ToastContextProvider>
75
</ConfettiContextProvider>
76
</QueryErrorBoundary>
77
</GitpodQueryClientProvider>
78
</BrowserRouter>
79
</ReloadPageErrorBoundary>
80
</ThemeContextProvider>
81
</React.StrictMode>,
82
document.getElementById("root"),
83
);
84
};
85
86
bootApp();
87
88