Skip to content

Commit 523df41

Browse files
committed
[dashboard] update Install GitHub App
1 parent 61d50ae commit 523df41

File tree

1 file changed

+5
-95
lines changed

1 file changed

+5
-95
lines changed

components/dashboard/src/projects/InstallGitHubApp.tsx

Lines changed: 5 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -4,118 +4,28 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { useLocation } from "react-router";
87
import InfoBox from "../components/InfoBox";
9-
import Modal from "../components/Modal";
10-
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred";
11-
import { getGitpodService, gitpodHostUrl } from "../service/service";
12-
import { useState } from "react";
13-
import { openAuthorizeWindow } from "../provider-utils";
14-
15-
async function registerApp(installationId: string, setModal: (modal: "done" | string | undefined) => void) {
16-
try {
17-
await getGitpodService().server.registerGithubApp(installationId);
18-
19-
const result = new Deferred<void>(1000 * 60 * 10 /* 10 min */);
20-
21-
openAuthorizeWindow({
22-
host: "github.com",
23-
scopes: ["repo"],
24-
onSuccess: () => {
25-
setModal("done");
26-
result.resolve();
27-
},
28-
onError: (payload) => {
29-
let errorMessage: string;
30-
if (typeof payload === "string") {
31-
errorMessage = payload;
32-
} else {
33-
errorMessage = payload.description ? payload.description : `Error: ${payload.error}`;
34-
}
35-
setModal(errorMessage);
36-
},
37-
});
38-
39-
return result.promise;
40-
} catch (e) {
41-
setModal(e.message);
42-
}
43-
}
8+
import { gitpodHostUrl } from "../service/service";
449

4510
export default function InstallGitHubApp() {
46-
const location = useLocation();
47-
const [modal, setModal] = useState<"done" | string | undefined>();
48-
const params = new URLSearchParams(location.search);
49-
const installationId = params.get("installation_id") || undefined;
50-
if (!installationId) {
51-
return (
52-
<div className="app-container flex flex-col space-y-2">
53-
<div className="px-6 py-3 flex justify-between space-x-2 text-gray-400 border-t border-gray-200 dark:border-gray-800 h-96">
54-
<div className="flex flex-col items-center w-96 m-auto">
55-
<h3 className="text-center pb-3 text-gray-500 dark:text-gray-400">No Installation ID Found</h3>
56-
<div className="text-center pb-6 text-gray-500">
57-
Did you come here from the GitHub app's page?
58-
</div>
59-
</div>
60-
</div>
61-
</div>
62-
);
63-
}
64-
6511
const goToApp = () => (window.location.href = gitpodHostUrl.toString());
6612

6713
return (
6814
<>
6915
<div className="app-container flex flex-col space-y-2">
7016
<div className="px-6 py-3 flex justify-between space-x-2 text-gray-400">
7117
<div className="flex flex-col items-center m-auto max-w-lg mt-40">
72-
<h3 className="text-center pb-3 text-gray-500">Install GitHub App</h3>
18+
<h3 className="text-center pb-3 text-gray-500">GitHub App 🌅</h3>
7319
<div className="text-center pb-6 text-gray-500">
74-
You are about to install the GitHub app for Gitpod.
20+
You likely tried to install the GitHub App for Gitpod.
7521
</div>
76-
<InfoBox>
77-
This action will also allow Gitpod to access private repositories. You can edit Git provider
78-
permissions later in user settings.
79-
</InfoBox>
22+
<InfoBox>Gitpod no longer requires to install the GitHub App on repositories.</InfoBox>
8023
<div className="mt-6">
81-
<button className="secondary">Cancel</button>
82-
<button className="ml-2" onClick={() => registerApp(installationId, setModal)}>
83-
Install App
84-
</button>
24+
<button onClick={goToApp}>Go to Dashboard</button>
8525
</div>
8626
</div>
8727
</div>
8828
</div>
89-
<Modal
90-
title="Installation Successful"
91-
visible={modal === "done"}
92-
onClose={goToApp}
93-
buttons={<button onClick={goToApp}>Go to Dashboard</button>}
94-
>
95-
<div className="pb-6 text-gray-500">
96-
The GitHub app was installed successfully. Have a look at the{" "}
97-
<a className="text-blue-500" href="https://www.gitpod.io/docs/prebuilds/" rel="noopener">
98-
documentation
99-
</a>{" "}
100-
to find out how to configure it.
101-
</div>
102-
</Modal>
103-
<Modal
104-
title="Failed to Install"
105-
visible={!!modal && modal !== "done"}
106-
onClose={goToApp}
107-
buttons={[
108-
<button className="secondary" onClick={goToApp}>
109-
Cancel
110-
</button>,
111-
<button className="" onClick={() => registerApp(installationId, setModal)}>
112-
Try Again
113-
</button>,
114-
]}
115-
>
116-
<div className="pb-6 text-gray-500">Could not install the GitHub app.</div>
117-
<InfoBox>{modal}</InfoBox>
118-
</Modal>
11929
</>
12030
);
12131
}

0 commit comments

Comments
 (0)