|
4 | 4 | * See License.AGPL.txt in the project root for license information.
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -import { useLocation } from "react-router"; |
8 | 7 | 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"; |
44 | 9 |
|
45 | 10 | 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 |
| - |
65 | 11 | const goToApp = () => (window.location.href = gitpodHostUrl.toString());
|
66 | 12 |
|
67 | 13 | return (
|
68 | 14 | <>
|
69 | 15 | <div className="app-container flex flex-col space-y-2">
|
70 | 16 | <div className="px-6 py-3 flex justify-between space-x-2 text-gray-400">
|
71 | 17 | <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> |
73 | 19 | <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. |
75 | 21 | </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> |
80 | 23 | <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> |
85 | 25 | </div>
|
86 | 26 | </div>
|
87 | 27 | </div>
|
88 | 28 | </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> |
119 | 29 | </>
|
120 | 30 | );
|
121 | 31 | }
|
0 commit comments