diff --git a/components/dashboard/src/projects/InstallGitHubApp.tsx b/components/dashboard/src/projects/InstallGitHubApp.tsx index 356110c32b0cf8..8f4ef8cd7becdb 100644 --- a/components/dashboard/src/projects/InstallGitHubApp.tsx +++ b/components/dashboard/src/projects/InstallGitHubApp.tsx @@ -4,64 +4,10 @@ * See License.AGPL.txt in the project root for license information. */ -import { useLocation } from "react-router"; import InfoBox from "../components/InfoBox"; -import Modal from "../components/Modal"; -import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred"; -import { getGitpodService, gitpodHostUrl } from "../service/service"; -import { useState } from "react"; -import { openAuthorizeWindow } from "../provider-utils"; - -async function registerApp(installationId: string, setModal: (modal: "done" | string | undefined) => void) { - try { - await getGitpodService().server.registerGithubApp(installationId); - - const result = new Deferred(1000 * 60 * 10 /* 10 min */); - - openAuthorizeWindow({ - host: "github.com", - scopes: ["repo"], - onSuccess: () => { - setModal("done"); - result.resolve(); - }, - onError: (payload) => { - let errorMessage: string; - if (typeof payload === "string") { - errorMessage = payload; - } else { - errorMessage = payload.description ? payload.description : `Error: ${payload.error}`; - } - setModal(errorMessage); - }, - }); - - return result.promise; - } catch (e) { - setModal(e.message); - } -} +import { gitpodHostUrl } from "../service/service"; export default function InstallGitHubApp() { - const location = useLocation(); - const [modal, setModal] = useState<"done" | string | undefined>(); - const params = new URLSearchParams(location.search); - const installationId = params.get("installation_id") || undefined; - if (!installationId) { - return ( -
-
-
-

No Installation ID Found

-
- Did you come here from the GitHub app's page? -
-
-
-
- ); - } - const goToApp = () => (window.location.href = gitpodHostUrl.toString()); return ( @@ -69,53 +15,17 @@ export default function InstallGitHubApp() {
-

Install GitHub App

+

GitHub App 🌅

- You are about to install the GitHub app for Gitpod. + You likely tried to install the GitHub App for Gitpod.
- - This action will also allow Gitpod to access private repositories. You can edit Git provider - permissions later in user settings. - + Gitpod no longer requires to install the GitHub App on repositories.
- - +
- Go to Dashboard} - > -
- The GitHub app was installed successfully. Have a look at the{" "} - - documentation - {" "} - to find out how to configure it. -
-
- - Cancel - , - , - ]} - > -
Could not install the GitHub app.
- {modal} -
); } diff --git a/components/gitpod-protocol/src/gitpod-service.ts b/components/gitpod-protocol/src/gitpod-service.ts index 83806d376504ba..2e6816528497e2 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -213,10 +213,6 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, generateNewGitpodToken(options: GitpodServer.GenerateNewGitpodTokenOptions): Promise; deleteGitpodToken(tokenHash: string): Promise; - // misc - isGitHubAppEnabled(): Promise; - registerGithubApp(installationId: string): Promise; - /** * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`. * @return the snapshot id diff --git a/components/server/src/auth/rate-limiter.ts b/components/server/src/auth/rate-limiter.ts index 9fa533bb3217da..e756eba7411179 100644 --- a/components/server/src/auth/rate-limiter.ts +++ b/components/server/src/auth/rate-limiter.ts @@ -127,8 +127,6 @@ const defaultFunctions: FunctionsConfig = { getGitpodTokens: { group: "default", points: 1 }, generateNewGitpodToken: { group: "default", points: 1 }, deleteGitpodToken: { group: "default", points: 1 }, - isGitHubAppEnabled: { group: "default", points: 1 }, - registerGithubApp: { group: "default", points: 1 }, takeSnapshot: { group: "default", points: 1 }, waitForSnapshot: { group: "default", points: 1 }, getSnapshots: { group: "default", points: 1 }, diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 9a16b008d61ea5..0c21fb4ee0480a 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -5,7 +5,6 @@ */ import { - AppInstallationDB, UserDB, WorkspaceDB, DBWithTracing, @@ -224,8 +223,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { @inject(LinkedInService) private readonly linkedInService: LinkedInService, - @inject(AppInstallationDB) private readonly appInstallationDB: AppInstallationDB, - @inject(AuthProviderService) private readonly authProviderService: AuthProviderService, @inject(GitTokenScopeGuesser) private readonly gitTokenScopeGuesser: GitTokenScopeGuesser, @@ -1848,26 +1845,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { return { instance, workspace }; } - async isGitHubAppEnabled(ctx: TraceContext): Promise { - await this.checkAndBlockUser(); - return !!this.config.githubApp?.enabled; - } - - async registerGithubApp(ctx: TraceContext, installationId: string): Promise { - traceAPIParams(ctx, { installationId }); - - const user = await this.checkAndBlockUser(); - - if (!this.config.githubApp?.enabled) { - throw new ApplicationError( - ErrorCodes.NOT_FOUND, - "No GitHub app enabled for this installation. Please talk to your administrator.", - ); - } - - await this.appInstallationDB.recordNewInstallation("github", "user", installationId, user.id); - } - async takeSnapshot(ctx: TraceContext, options: GitpodServer.TakeSnapshotOptions): Promise { traceAPIParams(ctx, { options }); const { workspaceId, dontWait } = options;