Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] increase IDE awareness for onboarding users when starting workspace #9663

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)} />;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to show Modal while restarting a workspace, because createWorkspace covered most cases

} 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