Skip to content

Commit

Permalink
[dashboard] increase IDE awareness for onboarding user when starting …
Browse files Browse the repository at this point in the history
…workspace
  • Loading branch information
mustard-mh committed May 9, 2022
1 parent af26333 commit 8857762
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 16 additions & 2 deletions components/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import gitpodIcon from "./icons/gitpod.svg";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import { useHistory } from "react-router-dom";
import { trackButtonOrAnchor, trackPathChange, trackLocation } from "./Analytics";
import { LicenseInfo, User } from "@gitpod/gitpod-protocol";
import { ContextURL, LicenseInfo, User } from "@gitpod/gitpod-protocol";
import * as GitpodCookie from "@gitpod/gitpod-protocol/lib/util/gitpod-cookie";
import { Experiment } from "./experiments";
import { workspacesPathMain } from "./workspaces/workspaces.routes";
Expand All @@ -45,6 +45,8 @@ import {
import { refreshSearchData } from "./components/RepositoryFinder";
import { StartWorkspaceModal } from "./workspaces/StartWorkspaceModal";
import { parseProps } from "./start/StartWorkspace";
import SelectIDEModal from "./settings/SelectIDEModal";
import { StartPage, StartPhase } from "./start/StartPage";

const Setup = React.lazy(() => import(/* webpackPrefetch: true */ "./Setup"));
const Workspaces = React.lazy(() => import(/* webpackPrefetch: true */ "./workspaces/Workspaces"));
Expand Down Expand Up @@ -495,12 +497,24 @@ function App() {
);
return <div></div>;
}
// Prefix with `/#referrer` will specify an IDE for workspace
// We don't need to show IDE preference in this case
const shouldUserIdePreferenceShown = User.isOnboardingUser(user) && !hash.startsWith(ContextURL.REFERRER_PREFIX);

const isCreation = window.location.pathname === "/" && hash !== "";
const isWsStart = /\/start\/?/.test(window.location.pathname) && hash !== "";
if (isWhatsNewShown) {
toRender = <WhatsNew onClose={() => setWhatsNewShown(false)} />;
} else if (isCreation) {
toRender = <CreateWorkspace contextUrl={hash} />;
if (shouldUserIdePreferenceShown) {
toRender = (
<StartPage phase={StartPhase.Checking}>
<SelectIDEModal />
</StartPage>
);
} else {
toRender = <CreateWorkspace contextUrl={hash} />;
}
} else if (isWsStart) {
toRender = <StartWorkspace {...parseProps(hash, window.location.search)} />;
} else if (/^(github|gitlab)\.com\/.+?/i.test(window.location.pathname)) {
Expand Down
4 changes: 3 additions & 1 deletion components/dashboard/src/settings/SelectIDEModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SelectIDE, { updateUserIDEInfo } from "./SelectIDE";
import Modal from "../components/Modal";
import { UserContext } from "../user-context";

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

Expand All @@ -23,11 +23,13 @@ export default function () {
const handleContinue = async () => {
setVisible(false);
if (!user || User.hasPreferredIde(user)) {
props.onClose && props.onClose();
return;
}
// TODO: We need to get defaultIde in ideOptions..
const defaultIde = "code";
await actualUpdateUserIDEInfo(user, defaultIde, false);
props.onClose && props.onClose();
};

return (
Expand Down

0 comments on commit 8857762

Please sign in to comment.