Skip to content

Commit 31a8d02

Browse files
committed
[dashboard] update Install GitHub App
Also remove all related jsonrpc API methods.
1 parent 61d50ae commit 31a8d02

File tree

4 files changed

+5
-124
lines changed

4 files changed

+5
-124
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
}

components/gitpod-protocol/src/gitpod-service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
213213
generateNewGitpodToken(options: GitpodServer.GenerateNewGitpodTokenOptions): Promise<string>;
214214
deleteGitpodToken(tokenHash: string): Promise<void>;
215215

216-
// misc
217-
isGitHubAppEnabled(): Promise<boolean>;
218-
registerGithubApp(installationId: string): Promise<void>;
219-
220216
/**
221217
* Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
222218
* @return the snapshot id

components/server/src/auth/rate-limiter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ const defaultFunctions: FunctionsConfig = {
127127
getGitpodTokens: { group: "default", points: 1 },
128128
generateNewGitpodToken: { group: "default", points: 1 },
129129
deleteGitpodToken: { group: "default", points: 1 },
130-
isGitHubAppEnabled: { group: "default", points: 1 },
131-
registerGithubApp: { group: "default", points: 1 },
132130
takeSnapshot: { group: "default", points: 1 },
133131
waitForSnapshot: { group: "default", points: 1 },
134132
getSnapshots: { group: "default", points: 1 },

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import {
8-
AppInstallationDB,
98
UserDB,
109
WorkspaceDB,
1110
DBWithTracing,
@@ -224,8 +223,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
224223

225224
@inject(LinkedInService) private readonly linkedInService: LinkedInService,
226225

227-
@inject(AppInstallationDB) private readonly appInstallationDB: AppInstallationDB,
228-
229226
@inject(AuthProviderService) private readonly authProviderService: AuthProviderService,
230227

231228
@inject(GitTokenScopeGuesser) private readonly gitTokenScopeGuesser: GitTokenScopeGuesser,
@@ -1848,26 +1845,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
18481845
return { instance, workspace };
18491846
}
18501847

1851-
async isGitHubAppEnabled(ctx: TraceContext): Promise<boolean> {
1852-
await this.checkAndBlockUser();
1853-
return !!this.config.githubApp?.enabled;
1854-
}
1855-
1856-
async registerGithubApp(ctx: TraceContext, installationId: string): Promise<void> {
1857-
traceAPIParams(ctx, { installationId });
1858-
1859-
const user = await this.checkAndBlockUser();
1860-
1861-
if (!this.config.githubApp?.enabled) {
1862-
throw new ApplicationError(
1863-
ErrorCodes.NOT_FOUND,
1864-
"No GitHub app enabled for this installation. Please talk to your administrator.",
1865-
);
1866-
}
1867-
1868-
await this.appInstallationDB.recordNewInstallation("github", "user", installationId, user.id);
1869-
}
1870-
18711848
async takeSnapshot(ctx: TraceContext, options: GitpodServer.TakeSnapshotOptions): Promise<string> {
18721849
traceAPIParams(ctx, { options });
18731850
const { workspaceId, dontWait } = options;

0 commit comments

Comments
 (0)