diff --git a/components/dashboard/src/data/git-providers/github-queries.ts b/components/dashboard/src/data/git-providers/github-queries.ts index 2cd4dcfccaa03f..6a50b8c4e734b9 100644 --- a/components/dashboard/src/data/git-providers/github-queries.ts +++ b/components/dashboard/src/data/git-providers/github-queries.ts @@ -11,7 +11,8 @@ import { useCurrentUser } from "../../user-context"; export const useIsGithubAppEnabled = () => { return useQuery(["github-app-enabled"], async () => { - return await getGitpodService().server.isGitHubAppEnabled(); + // similar to `isGitpodio`, but the GH App is only configured on Cloud. + return window.location.hostname === "gitpod.io" || window.location.hostname === "gitpod-staging.com"; }); }; 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 e01080b2553435..3b87b735371e34 100644 --- a/components/gitpod-protocol/src/gitpod-service.ts +++ b/components/gitpod-protocol/src/gitpod-service.ts @@ -211,7 +211,9 @@ export interface GitpodServer extends JsonRpcServer, AdminServer, deleteGitpodToken(tokenHash: string): Promise; // misc + /** @deprecated always returns false */ isGitHubAppEnabled(): Promise; + /** @deprecated this is a no-op */ registerGithubApp(installationId: string): Promise; /** diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 4ac6a1af8e1463..8f53aa44086df4 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, @@ -223,8 +222,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, @@ -1725,24 +1722,10 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { } async isGitHubAppEnabled(ctx: TraceContext): Promise { - await this.checkAndBlockUser(); - return !!this.config.githubApp?.enabled; + return false; } - 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 registerGithubApp(ctx: TraceContext, installationId: string): Promise {} async takeSnapshot(ctx: TraceContext, options: GitpodServer.TakeSnapshotOptions): Promise { traceAPIParams(ctx, { options });