Skip to content

Commit f8a81e1

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

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

components/dashboard/src/App.tsx

Lines changed: 17 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,24 @@ function App() {
495498
);
496499
return <div></div>;
497500
}
501+
const shouldUserIdePreferenceShown = User.isOnboardingUser(user) && !hash.startsWith(ContextURL.REFERRER_PREFIX);
502+
if (shouldUserIdePreferenceShown !== showUserIdePreference) {
503+
setShowUserIdePreference(shouldUserIdePreferenceShown);
504+
}
498505
const isCreation = window.location.pathname === "/" && hash !== "";
499506
const isWsStart = /\/start\/?/.test(window.location.pathname) && hash !== "";
500507
if (isWhatsNewShown) {
501508
toRender = <WhatsNew onClose={() => setWhatsNewShown(false)} />;
502509
} else if (isCreation) {
503-
toRender = <CreateWorkspace contextUrl={hash} />;
510+
if (showUserIdePreference) {
511+
toRender = (
512+
<StartPage phase={StartPhase.Checking}>
513+
<SelectIDEModal onClose={() => setShowUserIdePreference(false)} />
514+
</StartPage>
515+
);
516+
} else {
517+
toRender = <CreateWorkspace contextUrl={hash} />;
518+
}
504519
} else if (isWsStart) {
505520
toRender = <StartWorkspace {...parseProps(hash, window.location.search)} />;
506521
} 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)