Skip to content

Commit 2e186af

Browse files
committed
[dashboard] increase IDE awareness for onboarding user when starting workspace
1 parent af26333 commit 2e186af

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

components/dashboard/src/App.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import gitpodIcon from "./icons/gitpod.svg";
2020
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
2121
import { useHistory } from "react-router-dom";
2222
import { trackButtonOrAnchor, trackPathChange, trackLocation } from "./Analytics";
23-
import { LicenseInfo, User } from "@gitpod/gitpod-protocol";
23+
import { ContextURL, LicenseInfo, User } from "@gitpod/gitpod-protocol";
2424
import * as GitpodCookie from "@gitpod/gitpod-protocol/lib/util/gitpod-cookie";
2525
import { Experiment } from "./experiments";
2626
import { workspacesPathMain } from "./workspaces/workspaces.routes";
@@ -45,6 +45,8 @@ import {
4545
import { refreshSearchData } from "./components/RepositoryFinder";
4646
import { StartWorkspaceModal } from "./workspaces/StartWorkspaceModal";
4747
import { parseProps } from "./start/StartWorkspace";
48+
import SelectIDEModal from "./settings/SelectIDEModal";
49+
import { StartPage, StartPhase } from "./start/StartPage";
4850

4951
const Setup = React.lazy(() => import(/* webpackPrefetch: true */ "./Setup"));
5052
const Workspaces = React.lazy(() => import(/* webpackPrefetch: true */ "./workspaces/Workspaces"));
@@ -156,6 +158,7 @@ function App() {
156158

157159
const [loading, setLoading] = useState<boolean>(true);
158160
const [isWhatsNewShown, setWhatsNewShown] = useState(false);
161+
const [showUserIdePreference, setShowUserIdePreference] = useState(false);
159162
const [isSetupRequired, setSetupRequired] = useState(false);
160163
const history = useHistory();
161164

@@ -495,12 +498,26 @@ function App() {
495498
);
496499
return <div></div>;
497500
}
501+
// Prefix with `/#referrer` will specify an IDE for workspace
502+
// We don't need to show IDE preference in this case
503+
const shouldUserIdePreferenceShown = User.isOnboardingUser(user) && !hash.startsWith(ContextURL.REFERRER_PREFIX);
504+
if (shouldUserIdePreferenceShown !== showUserIdePreference) {
505+
setShowUserIdePreference(shouldUserIdePreferenceShown);
506+
}
498507
const isCreation = window.location.pathname === "/" && hash !== "";
499508
const isWsStart = /\/start\/?/.test(window.location.pathname) && hash !== "";
500509
if (isWhatsNewShown) {
501510
toRender = <WhatsNew onClose={() => setWhatsNewShown(false)} />;
502511
} else if (isCreation) {
503-
toRender = <CreateWorkspace contextUrl={hash} />;
512+
if (showUserIdePreference) {
513+
toRender = (
514+
<StartPage phase={StartPhase.Checking}>
515+
<SelectIDEModal onClose={() => setShowUserIdePreference(false)} />
516+
</StartPage>
517+
);
518+
} else {
519+
toRender = <CreateWorkspace contextUrl={hash} />;
520+
}
504521
} else if (isWsStart) {
505522
toRender = <StartWorkspace {...parseProps(hash, window.location.search)} />;
506523
} else if (/^(github|gitlab)\.com\/.+?/i.test(window.location.pathname)) {

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 (

0 commit comments

Comments
 (0)