Skip to content

Commit 9780f27

Browse files
committed
[dashboard] increase IDE awareness for onboarding user when starting workspace
1 parent 7c41afe commit 9780f27

12 files changed

+36
-3
lines changed

components/dashboard/src/settings/SelectIDEModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SelectIDE, { updateUserIDEInfo } from "./SelectIDE";
1111
import Modal from "../components/Modal";
1212
import { UserContext } from "../user-context";
1313

14-
export default function () {
14+
export default function (props: { onClose?: () => void }) {
1515
const { user, setUser } = useContext(UserContext);
1616
const [visible, setVisible] = useState(true);
1717

@@ -23,11 +23,13 @@ export default function () {
2323
const handleContinue = async () => {
2424
setVisible(false);
2525
if (!user || User.hasPreferredIde(user)) {
26+
props.onClose && props.onClose();
2627
return;
2728
}
2829
// TODO: We need to get defaultIde in ideOptions..
2930
const defaultIde = "code";
3031
await actualUpdateUserIDEInfo(user, defaultIde, false);
32+
props.onClose && props.onClose();
3133
};
3234

3335
return (

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import {
1515
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
1616
import Modal from "../components/Modal";
1717
import { getGitpodService, gitpodHostUrl } from "../service/service";
18-
import { UserContext } from "../user-context";
1918
import { StartPage, StartPhase, StartWorkspaceError } from "./StartPage";
2019
import StartWorkspace, { parseProps } from "./StartWorkspace";
2120
import { openAuthorizeWindow } from "../provider-utils";
2221
import { SelectAccountPayload } from "@gitpod/gitpod-protocol/lib/auth";
2322
import { SelectAccountModal } from "../settings/SelectAccountModal";
2423
import { watchHeadlessLogs } from "../components/PrebuildLogs";
2524
import CodeText from "../components/CodeText";
25+
import SelectIDEModal from "../settings/SelectIDEModal";
26+
import { UserContext } from "../user-context";
2627

2728
const WorkspaceLogs = React.lazy(() => import("../components/WorkspaceLogs"));
2829

@@ -250,6 +251,10 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
250251
onPrebuildSucceeded={() => this.createWorkspace(CreateWorkspaceMode.UsePrebuild)}
251252
/>
252253
);
254+
} else if (result?.needOnboardingIde) {
255+
statusMessage = (
256+
<SelectIDEModal onClose={() => this.createWorkspace(CreateWorkspaceMode.Default)}></SelectIDEModal>
257+
);
253258
}
254259

255260
return (

components/gitpod-protocol/go/gitpod-service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ type Repository struct {
15161516
type WorkspaceCreationResult struct {
15171517
CreatedWorkspaceID string `json:"createdWorkspaceId,omitempty"`
15181518
ExistingWorkspaces []*WorkspaceInfo `json:"existingWorkspaces,omitempty"`
1519+
NeedOnboardingIDE bool `json:"needOnboardingIde,omitempty"`
15191520
RunningPrebuildWorkspaceID string `json:"runningPrebuildWorkspaceID,omitempty"`
15201521
RunningWorkspacePrebuild *RunningWorkspacePrebuild `json:"runningWorkspacePrebuild,omitempty"`
15211522
WorkspaceURL string `json:"workspaceURL,omitempty"`

components/gitpod-protocol/src/protocol.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ export interface WorkspaceCreationResult {
11801180
createdWorkspaceId?: string;
11811181
workspaceURL?: string;
11821182
existingWorkspaces?: WorkspaceInfo[];
1183+
needOnboardingIde?: boolean;
11831184
runningWorkspacePrebuild?: {
11841185
prebuildID: string;
11851186
workspaceID: string;
@@ -1208,6 +1209,7 @@ export namespace WorkspaceCreationResult {
12081209
data &&
12091210
("createdWorkspaceId" in data ||
12101211
"existingWorkspaces" in data ||
1212+
"needOnboardingIde" in data ||
12111213
"runningWorkspacePrebuild" in data ||
12121214
"runningPrebuildWorkspaceID" in data)
12131215
);

components/server/ee/src/prebuilds/start-prebuild-context-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IPrefixContextParser } from "../../../src/workspace/context-parser";
1010

1111
@injectable()
1212
export class StartPrebuildContextParser implements IPrefixContextParser {
13+
readonly specifiedIDE: boolean = false;
1314
static PREFIX = ContextURL.PREBUILD_PREFIX + "/";
1415

1516
findPrefix(user: User, context: string): string | undefined {

components/server/src/workspace/additional-content-prefix-context-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IPrefixContextParser } from "./context-parser";
1616
*/
1717
@injectable()
1818
export class AdditionalContentPrefixContextParser implements IPrefixContextParser {
19+
readonly specifiedIDE: boolean = false;
1920
@inject(Config) protected readonly config: Config;
2021
static PREFIX = /^\/?additionalcontent\/([^\/]*)\//;
2122

components/server/src/workspace/context-parser-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { WorkspaceContext, User, CommitContext, GitCheckoutInfo, PullRequestContext } from "@gitpod/gitpod-protocol";
88
import { injectable, multiInject, inject } from "inversify";
99
import { HostContextProvider } from "../auth/host-context-provider";
10-
import { IPrefixContextParser, IContextParser } from "./context-parser";
10+
import { IPrefixContextParser, IContextParser, IPrefixContextParserContext } from "./context-parser";
1111
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing";
1212
import { ConfigProvider, InvalidGitpodYMLError } from "./config-provider";
1313

@@ -55,6 +55,7 @@ export class ContextParser {
5555

5656
if (prefixResult) {
5757
result = await prefixResult.parser.handle(user, prefixResult.prefix, result);
58+
(result as IPrefixContextParserContext).specifiedIDE = prefixResult.parser.specifiedIDE;
5859
}
5960
} catch (e) {
6061
span.logEvent("error", e);

components/server/src/workspace/context-parser.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,24 @@ export interface URLParts {
9696
* and expects "othercontext" to be parsed and passed back.
9797
*/
9898
export interface IPrefixContextParser {
99+
// readonly property to see if prefix context will specify an IDE
100+
specifiedIDE: boolean;
99101
normalize?(contextURL: string): string | undefined;
100102
findPrefix(user: User, context: string): string | undefined;
101103
handle(user: User, prefix: string, context: WorkspaceContext): Promise<WorkspaceContext>;
102104
}
103105
export const IPrefixContextParser = Symbol("IPrefixContextParser");
104106

107+
export interface IPrefixContextParserContext extends WorkspaceContext {
108+
specifiedIDE?: boolean;
109+
}
110+
111+
export namespace IPrefixContextParserContext {
112+
export function is(context: any): context is IPrefixContextParserContext {
113+
return context && "specifiedIDE" in context;
114+
}
115+
}
116+
105117
export namespace IssueContexts {
106118
export function toBranchName(user: User, issueTitle: string, issueNr: number): string {
107119
const titleWords = issueTitle

components/server/src/workspace/envvar-prefix-context-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { EnvVarWithValue } from "@gitpod/gitpod-protocol/src/protocol";
1111

1212
@injectable()
1313
export class EnvvarPrefixParser implements IPrefixContextParser {
14+
readonly specifiedIDE: boolean = false;
1415
public findPrefix(user: User, context: string): string | undefined {
1516
const result = this.parse(context);
1617
return result && result.prefix;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ import { ProjectEnvVar } from "@gitpod/gitpod-protocol/src/protocol";
157157
import { InstallationAdminSettings, TelemetryData } from "@gitpod/gitpod-protocol";
158158
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred";
159159
import { InstallationAdminTelemetryDataProvider } from "../installation-admin/telemetry-data-provider";
160+
import { IPrefixContextParserContext } from "./context-parser";
160161

161162
// shortcut
162163
export const traceWI = (ctx: TraceContext, wi: Omit<LogContext, "userId">) => TraceContext.setOWI(ctx, wi); // userId is already taken care of in WebsocketConnectionManager
@@ -1059,6 +1060,10 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
10591060
}).catch();
10601061
}
10611062

1063+
if (User.isOnboardingUser(user) && (!IPrefixContextParserContext.is(context) || !context.specifiedIDE)) {
1064+
return { needOnboardingIde: true };
1065+
}
1066+
10621067
// if we're forced to use the default config, mark the context as such
10631068
if (!!options.forceDefaultConfig) {
10641069
context = WithDefaultConfig.mark(context);

components/server/src/workspace/imagebuild-prefix-context-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IPrefixContextParser } from "./context-parser";
1010

1111
@injectable()
1212
export class ImageBuildPrefixContextParser implements IPrefixContextParser {
13+
readonly specifiedIDE: boolean = false;
1314
static PREFIX = ContextURL.IMAGEBUILD_PREFIX + "/";
1415

1516
findPrefix(user: User, context: string): string | undefined {

components/server/src/workspace/referrer-prefix-context-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { injectable } from "inversify";
1010

1111
@injectable()
1212
export class ReferrerPrefixParser implements IPrefixContextParser {
13+
readonly specifiedIDE: boolean = true;
1314
private readonly prefix = /^\/?referrer:([^\/:]*)(?::([^\/]*))?\//;
1415

1516
findPrefix(_: User, context: string): string | undefined {

0 commit comments

Comments
 (0)