Skip to content

Commit

Permalink
[public-api] complete installation service (#19200)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov authored Dec 8, 2023
1 parent 1113e3c commit bfa7c6e
Show file tree
Hide file tree
Showing 17 changed files with 729 additions and 278 deletions.
2 changes: 1 addition & 1 deletion components/dashboard/src/data/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import * as UserClasses from "@gitpod/public-api/lib/gitpod/v1/user_pb";
// This is used to version the cache
// If data we cache changes in a non-backwards compatible way, increment this version
// That will bust any previous cache versions a client may have stored
const CACHE_VERSION = "17";
const CACHE_VERSION = "19";

export function noPersistence(queryKey: QueryKey): QueryKey {
return [...queryKey, "no-persistence"];
Expand Down
8 changes: 5 additions & 3 deletions components/dashboard/src/dedicated-setup/use-needs-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import { useQuery } from "@tanstack/react-query";
import { useFeatureFlag } from "../data/featureflag-query";
import { noPersistence } from "../data/setup";
import { getGitpodService } from "../service/service";
import { installationClient } from "../service/public-api";
import { GetOnboardingStateRequest } from "@gitpod/public-api/lib/gitpod/v1/installation_pb";

/**
* @description Returns a flage stating if the current installation still needs setup before it can be used. Also returns an isLoading indicator as the check is async
Expand All @@ -17,7 +18,7 @@ export const useNeedsSetup = () => {
const enableDedicatedOnboardingFlow = useFeatureFlag("enableDedicatedOnboardingFlow");

// This needs to only be true if we've loaded the onboarding state
let needsSetup = !isLoading && onboardingState && onboardingState.isCompleted !== true;
let needsSetup = !isLoading && onboardingState && onboardingState.completed !== true;

if (isCurrentHostExcludedFromSetup()) {
needsSetup = false;
Expand All @@ -36,7 +37,8 @@ const useOnboardingState = () => {
return useQuery(
noPersistence(["onboarding-state"]),
async () => {
return await getGitpodService().server.getOnboardingState();
const response = await installationClient.getOnboardingState(new GetOnboardingStateRequest());
return response.onboardingState!;
},
{
// Only query if feature flag is enabled
Expand Down
12 changes: 12 additions & 0 deletions components/dashboard/src/service/json-rpc-installation-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
CreateBlockedEmailDomainResponse,
GetInstallationWorkspaceDefaultImageRequest,
GetInstallationWorkspaceDefaultImageResponse,
GetOnboardingStateRequest,
GetOnboardingStateResponse,
} from "@gitpod/public-api/lib/gitpod/v1/installation_pb";
import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import { getGitpodService } from "./service";
Expand Down Expand Up @@ -111,4 +113,14 @@ export class JsonRpcInstallationClient implements PromiseClient<typeof Installat
// There's no way to get blockedEmailDomain, just ignore it since dashboard don't care about the response data
return new CreateBlockedEmailDomainResponse({});
}

async getOnboardingState(
request: PartialMessage<GetOnboardingStateRequest>,
_options?: CallOptions | undefined,
): Promise<GetOnboardingStateResponse> {
const info = await getGitpodService().server.getOnboardingState();
return new GetOnboardingStateResponse({
onboardingState: converter.toOnboardingState(info),
});
}
}
12 changes: 12 additions & 0 deletions components/public-api/gitpod/v1/installation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ service InstallationService {

// CreateBlockedEmailDomain creates a new blocked email domain.
rpc CreateBlockedEmailDomain(CreateBlockedEmailDomainRequest) returns (CreateBlockedEmailDomainResponse) {}

// GetOnboardingState returns the onboarding state of the installation.
rpc GetOnboardingState(GetOnboardingStateRequest) returns (GetOnboardingStateResponse) {}
}

message GetOnboardingStateRequest {}
message GetOnboardingStateResponse {
OnboardingState onboarding_state = 1;
}

message OnboardingState {
bool completed = 1;
}

message GetInstallationWorkspaceDefaultImageRequest {}
Expand Down
Loading

0 comments on commit bfa7c6e

Please sign in to comment.