Skip to content

Commit 9149f66

Browse files
committed
[dashboard] start with options by default
1 parent eb6ca45 commit 9149f66

File tree

4 files changed

+363
-21
lines changed

4 files changed

+363
-21
lines changed

components/dashboard/src/app/AppRoutes.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SelectIDEModal from "../user-settings/SelectIDEModal";
1010
import { StartPage, StartPhase } from "../start/StartPage";
1111
import { getURLHash, isGitpodIo, isLocalPreview } from "../utils";
1212
import { shouldSeeWhatsNew, WhatsNew } from "../whatsnew/WhatsNew";
13-
import { Redirect, Route, Switch } from "react-router";
13+
import { Redirect, Route, Switch, useLocation } from "react-router";
1414
import Menu from "../menu/Menu";
1515
import { parseProps } from "../start/StartWorkspace";
1616
import { AppNotifications } from "../AppNotifications";
@@ -41,9 +41,10 @@ import { Blocked } from "./Blocked";
4141
import { BlockedRepositories } from "../admin/BlockedRepositories";
4242
import PersonalAccessTokenCreateView from "../user-settings/PersonalAccessTokensCreateView";
4343
import { StartWorkspaceModalContext } from "../workspaces/start-workspace-modal-context";
44-
import { StartWorkspaceOptions } from "../start/start-workspace-options";
4544
import { WebsocketClients } from "./WebsocketClients";
4645
import { OrgRequiredRoute } from "./OrgRequiredRoute";
46+
import { useFeatureFlags } from "../contexts/FeatureFlagContext";
47+
import { CreateWorkspacePage } from "../workspaces/CreateWorkspacePage";
4748

4849
const Setup = React.lazy(() => import(/* webpackPrefetch: true */ "../Setup"));
4950
const WorkspacesNew = React.lazy(() => import(/* webpackPrefetch: true */ "../workspaces/WorkspacesNew"));
@@ -97,6 +98,8 @@ export const AppRoutes: FunctionComponent<AppRoutesProps> = ({ user, teams }) =>
9798
const hash = getURLHash();
9899
const { startWorkspaceModalProps, setStartWorkspaceModalProps } = useContext(StartWorkspaceModalContext);
99100
const [isWhatsNewShown, setWhatsNewShown] = useState(shouldSeeWhatsNew(user));
101+
const { startWithOptions } = useFeatureFlags();
102+
const location = useLocation();
100103

101104
// Prefix with `/#referrer` will specify an IDE for workspace
102105
// We don't need to show IDE preference in this case
@@ -105,12 +108,12 @@ export const AppRoutes: FunctionComponent<AppRoutesProps> = ({ user, teams }) =>
105108
);
106109

107110
// TODO: Add a Route for this instead of inspecting location manually
108-
if (window.location.pathname.startsWith("/blocked")) {
111+
if (location.pathname.startsWith("/blocked")) {
109112
return <Blocked />;
110113
}
111114

112115
// TODO: Add a Route for this instead of inspecting location manually
113-
if (window.location.pathname.startsWith("/oauth-approval")) {
116+
if (location.pathname.startsWith("/oauth-approval")) {
114117
return <OAuthClientApproval />;
115118
}
116119

@@ -119,26 +122,24 @@ export const AppRoutes: FunctionComponent<AppRoutesProps> = ({ user, teams }) =>
119122
}
120123

121124
// TODO: Try and encapsulate this in a route for "/" (check for hash in route component, render or redirect accordingly)
122-
const isCreation = window.location.pathname === "/" && hash !== "";
125+
const isCreation = location.pathname === "/" && hash !== "";
123126
if (isCreation) {
124127
if (showUserIdePreference) {
125128
return (
126129
<StartPage phase={StartPhase.Checking}>
127130
<SelectIDEModal location="workspace_start" onClose={() => setShowUserIdePreference(false)} />
128131
</StartPage>
129132
);
130-
} else if (new URLSearchParams(window.location.search).has("showOptions")) {
131-
const props = StartWorkspaceOptions.parseSearchParams(window.location.search);
133+
} else if (
134+
new URLSearchParams(location.search).has("showOptions") ||
135+
startWithOptions ||
136+
user?.additionalData?.isMigratedToTeamOnlyAttribution
137+
) {
132138
return (
133-
<StartWorkspaceModal
134-
{...{
135-
contextUrl: hash,
136-
ide: props?.ideSettings?.defaultIde,
137-
uselatestIde: props?.ideSettings?.useLatestVersion,
138-
workspaceClass: props.workspaceClass,
139-
onClose: undefined,
140-
}}
141-
/>
139+
<div className="container">
140+
<Menu />
141+
<CreateWorkspacePage />
142+
</div>
142143
);
143144
} else {
144145
return <CreateWorkspace contextUrl={hash} />;

components/dashboard/src/contexts/FeatureFlagContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface FeatureFlagConfig {
1515
}
1616

1717
const FeatureFlagContext = createContext<{
18+
startWithOptions: boolean;
1819
showUsageView: boolean;
1920
isUsageBasedBillingEnabled: boolean;
2021
showUseLastSuccessfulPrebuild: boolean;
@@ -23,6 +24,7 @@ const FeatureFlagContext = createContext<{
2324
oidcServiceEnabled: boolean;
2425
orgGitAuthProviders: boolean;
2526
}>({
27+
startWithOptions: false,
2628
showUsageView: false,
2729
isUsageBasedBillingEnabled: false,
2830
showUseLastSuccessfulPrebuild: false,
@@ -37,6 +39,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
3739
const teams = useTeams();
3840
const { project } = useContext(ProjectContext);
3941
const team = useCurrentTeam();
42+
const [startWithOptions, setStartWithOptions] = useState<boolean>(false);
4043
const [showUsageView, setShowUsageView] = useState<boolean>(false);
4144
const [isUsageBasedBillingEnabled, setIsUsageBasedBillingEnabled] = useState<boolean>(false);
4245
const [showUseLastSuccessfulPrebuild, setShowUseLastSuccessfulPrebuild] = useState<boolean>(false);
@@ -49,6 +52,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
4952
if (!user) return;
5053
(async () => {
5154
const featureFlags: FeatureFlagConfig = {
55+
start_with_options: { defaultValue: false, setter: setStartWithOptions },
5256
usage_view: { defaultValue: false, setter: setShowUsageView },
5357
isUsageBasedBillingEnabled: { defaultValue: false, setter: setIsUsageBasedBillingEnabled },
5458
showUseLastSuccessfulPrebuild: { defaultValue: false, setter: setShowUseLastSuccessfulPrebuild },
@@ -98,6 +102,7 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
98102
return (
99103
<FeatureFlagContext.Provider
100104
value={{
105+
startWithOptions,
101106
showUsageView,
102107
isUsageBasedBillingEnabled,
103108
showUseLastSuccessfulPrebuild,

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export function CreateWorkspace({ contextUrl }: CreateWorkspaceProps) {
325325
);
326326
}
327327

328-
function SelectCostCenterModal(props: { onSelected?: () => void }) {
328+
export function SelectCostCenterModal(props: { onSelected?: () => void }) {
329329
return (
330330
<Modal visible={true} closeable={false} onClose={() => {}}>
331331
<h3>Choose Billing Organization</h3>
@@ -334,7 +334,7 @@ function SelectCostCenterModal(props: { onSelected?: () => void }) {
334334
);
335335
}
336336

337-
function LimitReachedModal(p: { children: React.ReactNode }) {
337+
export function LimitReachedModal(p: { children: React.ReactNode }) {
338338
const { user } = useContext(UserContext);
339339
return (
340340
// TODO: Use title and buttons props
@@ -358,7 +358,7 @@ function LimitReachedModal(p: { children: React.ReactNode }) {
358358
);
359359
}
360360

361-
function LimitReachedParallelWorkspacesModal() {
361+
export function LimitReachedParallelWorkspacesModal() {
362362
return (
363363
<LimitReachedModal>
364364
<p className="mt-1 mb-2 text-base dark:text-gray-400">
@@ -369,7 +369,7 @@ function LimitReachedParallelWorkspacesModal() {
369369
);
370370
}
371371

372-
function LimitReachedOutOfHours() {
372+
export function LimitReachedOutOfHours() {
373373
return (
374374
<LimitReachedModal>
375375
<p className="mt-1 mb-2 text-base dark:text-gray-400">
@@ -380,7 +380,7 @@ function LimitReachedOutOfHours() {
380380
);
381381
}
382382

383-
function RepositoryNotFoundView(p: { error: StartWorkspaceError }) {
383+
export function RepositoryNotFoundView(p: { error: StartWorkspaceError }) {
384384
const [statusMessage, setStatusMessage] = useState<React.ReactNode>();
385385
const { host, owner, repoName, userIsOwner, userScopes, lastUpdate } = p.error.data;
386386
const repoFullName = owner && repoName ? `${owner}/${repoName}` : "";

0 commit comments

Comments
 (0)